3
votes

I simply don't want to set an environment variable every time i need a library, let a lone the paths searched are not standardized at all (at least on windows). Generally the Find*.cmake doesn't specify any locations with association on windows.

Is there some way to make CMake search a specified directory (forcing bad configured Find*.cmake to search paths they otherwise wouldn't set at the system level)? Say i want it to search on "C:\" or just "/" on windows? That way i can just put all my libraries in "C:\".

1

1 Answers

9
votes

You can try to append paths to CMAKE_PREFIX_PATH in your project CMakeLists.txt, something like this:

list(APPEND CMAKE_PREFIX_PATH "/tmp/test" "/another/library/path")

According to the documentation, it will append "/lib" to the end of each path in the list and search for libraries there, but with some quick testing, it seems like cmake should find things alright if it's directly in a path you specify. For example, if I have /tmp/test/libtest.so and add the line above, I can find it like so:

find_library(libtest_LIBRARY test)

Running cmake should set the cache variable libtest_LIBRARY with the right path.