考虑以下CMakeLists.txt
文件:
add_subdirectory(execA) add_subdirectory(libB) install(TARGETS execA libB RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
我收到以下错误:
install TARGETS given target "execA" which does not exist in this directory
execA
并libB
拥有自己的CMakeList.txt
文件,位于project
目录下,以及我正在运行的构建目录cmake
(cmake ..
):
project |------ CMakeList.txt (the one with the code) |----execA | \- .cpp, .hpp and CMakelist.txt |----libB | \- .cpp, .hpp and CMakelist.txt |---- lib |---- bin \---- build (where I´m commanding: $ cmake ..
我该如何解决这个错误?
根据此bug报告,install(TARGETS)
命令流仅接受在同一目录中创建的目标.
因此,您需要将add_library()
调用移动到顶级目录,或将install(TARGETS)
调用拆分为每个目标,并将每个调用移动到相应的子目录中.