0

I am running C++ code on macOS using Visual Studio Code and terminal. I am using CMAKE for compiling.

But my problem is that CMAKE does not seem to take the PATH from my MACOS environment. It only has /usr/bin:/bin:/usr/sbin:/sbin in it. I have added more paths to my normal path variable (echo $PATH) but CMAKE is not using those. Where is CMAKE sourcing its path from, and how it can be expanded? It can't find GoogleTest, Boost and any other libraries I am using. To keep it cross-platform I would like to not have to use include_directories() in CMakeLists.txt.

I have set the additional path manually in the macOS CMAKE GUI and this works, now it can find my libraries and compile, but whenever I reboot it is reset back to those basic paths. Also it only works for the CMAKE GUI, the terminal CMAKE or the one I am using in Visual Studio Code still don't work. Can anyone let me know where CMAKE is sourcing those paths from and how I can expand it?

  • pretty sure cmake doesn't use the `PATH` environment variable to locate libraries, try using [find_library](https://cmake.org/cmake/help/latest/command/find_library.html) – Alan Birtles Feb 10 '21 at 21:11
  • If you use `find_package` for locate Boost, GTest and other libraries, then setting `CMAKE_PREFIX_PATH` variable should help. – Tsyvarev Feb 10 '21 at 21:56

0 Answers0