CMake Set Default Search Path?

后端 未结 1 706
陌清茗
陌清茗 2021-01-14 12:12

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 t

相关标签:
1条回答
  • 2021-01-14 12:40

    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.

    0 讨论(0)
提交回复
热议问题