我有一个cmake项目,它取决于生成dll的其他cmake项目:
include(ExternalProject)
...
set(COMMON_BASE_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../CommonBase)
...
ExternalProject_Add(CommonBaseProject
SOURCE_DIR ${COMMON_BASE_PROJECT_DIR}
BINARY_DIR ${COMMON_BASE_PROJECT_DIR}/build
STEP_TARGETS build
EXCLUDE_FROM_ALL TRUE
)
...
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${COMMON_BASE_PROJECT_DIR}/include)
...
add_executable(${EXECUTABLE_NAME} ${SRC_FILES} ${INCLUDE_FILES})
...
target_link_libraries (${EXECUTABLE_NAME} ${COMMON_BASE_PROJECT_DIR}/build/libCommonBase.dll)
...
add_dependencies(${EXECUTABLE_NAME} CommonBaseProject-build)
我需要制作一个包含exe文件和所有库文件的发行版。 我还需要打包到一些依赖项目所依赖的qt库的分发:
find_package(Qt5Core ${QT_VERSION_REQ} REQUIRED)
find_package(Qt5Quick ${QT_VERSION_REQ} REQUIRED)
find_package(Qt5Widgets ${QT_VERSION_REQ} REQUIRED)
find_package(Qt5DBus ${QT_VERSION_REQ} REQUIRED)
...
list(APPEND LIBS
Qt5::Core
Qt5::Quick
Qt5::Widgets
Qt5::DBus
)
target_link_libraries (${EXECUTABLE_NAME} ${LIBS})
怎么做?我已经尝试过cpack但是需要为每个dll创建一个目标,但该目标是在lib项目构建文件中。
我会接受cpack和非cpack解决方案。