CMake 创建自定义目标:在构建前复制文件
创建自定义目标
1
2
3
4
5
6
add_custom_target(TargetCopy3rdPartyLibs ALL
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
COMMAND cp_3rd_libs.bat "${PROJECT_SOURCE_DIR}/3rd_libs" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src/cmake"
COMMENT "Copying 3rd party libraries to bin directory"
)
引用自定义目标
在编译APP,LIB的CMakeLists.txt文件中,添加:
1
set_target_properties(${target_app} PROPERTIES DEPENDS Copy3rdPartyLibs)
本文由作者按照 CC BY 4.0 进行授权