CMake cannot resolve runtime directory path

前端 未结 2 1008
悲哀的现实
悲哀的现实 2020-12-18 22:10

After running cmake CMakeLists.txt

I get the following warning

CMake Warning at src/CMakeLists.txt:32 (add_executable):
  Cannot generate a safe runt         


        
2条回答
  •  感动是毒
    2020-12-18 22:35

    If you're dealing with find_library

    find_library(LIBRARY_NAME PATHS "/usr/lib/x86_64-linux-gnu" NO_DEFAULT_PATH) where

    • PATHS stands for the exact path to the libs
    • NO_DEFAULT_PATH means, that cmake will not search anywhere else

    check the values of lib and include paths with message(status, ${LIBRARY_NAME})


    If you're dealing with find_package:

    It's a bit more complicated than the previous example, but it's essentially the same.

    For each package you have to run find_package for:

    1. Create file with name Find.cmake, e. g. if you're looking for cppunit, you'll have to create FindCPPUNIT.cmake.

    2. In that file, you'll have to run find_path on include files and find_library on lib files, like in "If you're dealing with find_library".

      find_path(CPPUNIT_INCLUDE_DIR PATHS "/usr/include/x86_64-linux-gnu" NO_DEFAULT_PATH)       
      find_library(CPPUNIT_LIBRARY PATHS "/usr/lib/x86_64-linux-gnu" NO_DEFAULT_PATH)
      

      And then you have to add the path to the file to CMAKE_MODULE_PATH.

提交回复
热议问题