我有两个使用CMake的项目.项目A构建一个静态库,然后链接到项目B.问题是,当我从项目A更改源文件并构建两个项目时,项目B将不会再自动链接.如何将项目A(静态库)的输出添加到项目B?
编辑:这是我的问题的一个例子:
ProjectA CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
PROJECT(PROJECTA)
ADD_LIBRARY(projectA STATIC "src/foo.cpp")
Run Code Online (Sandbox Code Playgroud)
ProjectB CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
PROJECT(PROJECTB)
set(PROJECTA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../ProjectA)
include_directories(${PROJECTA_DIR}/include)
link_directories(${PROJECTA_DIR}/build)
ADD_EXECUTABLE(projectB "src/main.cpp")
target_link_libraries(projectB projectA)
Run Code Online (Sandbox Code Playgroud)
重现问题:
cmake ×1