CMake install (TARGETS in subdirectories)

后端 未结 3 464
梦毁少年i
梦毁少年i 2020-12-06 04:14

Consider the following CMakeLists.txt file:

add_subdirectory(execA)
add_subdirectory(libB)

install(TARGETS execA libB
        RUNTIME DESTINATI         


        
3条回答
  •  生来不讨喜
    2020-12-06 04:55

    According to this bugreport, install(TARGETS) command flow accepts only targets created within the same directory.

    So you need either move the add_library() call into the top-level directory, or split install(TARGETS) call into per-target ones, and move each of them into the corresponding subdirectory.

    Since CMake 3.13 install(TARGETS) can work even with targets created in other directories.

    install(TARGETS) can install targets that were created in other directories. When using such cross-directory install rules, running make install (or similar) from a subdirectory will not guarantee that targets from other directories are up-to-date.

提交回复
热议问题