0

I want every CMake project that uses boost (or any other lib) to find it in custom directory, for example /home/someuser/mylibs or C:/mylibs.

To achieve this I may add in CMakeLists.txt following command:

list(APPEND CMAKE_PREFIX_PATH "/home/someuser/mylibs")

This is not very comfortable when I cooperate with different people on different projects. The question is: can I use some environment variable to set it or there's another way to do this?

Kevin
  • 16,549
  • 8
  • 60
  • 74
Mariusz Jaskółka
  • 4,137
  • 2
  • 21
  • 47

1 Answers1

1

The usual way is to add -DCMAKE_PREFIX_PATH=/path/to/boost/ when calling CMake to configure your project. But, of course, you can also set an environment variable, e.g. BOOST_DIR and then read it out using CMake:

list(APPEND CMAKE_PREFIX_PATH $ENV{BOOST_DIR})
Kevin
  • 16,549
  • 8
  • 60
  • 74
user3726947
  • 501
  • 5
  • 16