CMake install (TARGETS in subdirectories)

后端 未结 3 456
梦毁少年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 05:07

    Even though it would help seeing the CMakeLists.txt files contained in the subdirectories, I guess they contain add_executable and/or add_library statements to create your stuff.
    Also, because of your example, I guess you are using the same name of your directories for your targets.
    That said, you should know that symbols defined in a CMakeLists.txt file in a subdirectory are not visible by default within the context of the CMakeLists.txt file in the parent directory. Because of that, you should rather move your install statements within the CMakeLists.txt files within your subdirectories.
    This should solve the problem, if my thoughts were right. Otherwise, I strongly suggest you to post in your question also the content of the other files above mentioned.

    Anyway, the error is quite clear.
    The file that contains the install statement for the target named X does not contain a target creation statement (add_executable and the others) that gives birth to that target, so it goes on saying that that target does not exist in that directory.

提交回复
热议问题