Created
September 5, 2022 09:23
-
-
Save Junch/210cc2584025815a48d7a6ed81ae3d84 to your computer and use it in GitHub Desktop.
cmake 将第三方库文件复制到项目运行时文件夹
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://www.cnblogs.com/JoyPoint/p/11629521.html | |
| #=============Copy Source files to Build Runtime Dir=============== | |
| #该内容一般放在项目顶层CMakelists.txt的最后, | |
| #目的是将项目生成后的执行文件所需的第三方库复制到执行程序目录, | |
| #并区分Debug和Release版本。 | |
| #该方法中的COMMAND_EXPAND_LISTS参数值得关注,可以复制列表内所有文件。 | |
| FILE(GLOB Plugin_Runtime_Debug_DLL_FILES CONFIGURE_DEPENDS | |
| ${CMAKE_CURRENT_SOURCE_DIR}/Plugin_Runtime_Dir/Debug/*.* | |
| ) | |
| FILE(GLOB Plugin_Runtime_Release_DLL_FILES CONFIGURE_DEPENDS | |
| ${CMAKE_CURRENT_SOURCE_DIR}/Plugin_Runtime_Dir/Release/*.* | |
| ) | |
| FILE(GLOB Plugin_Runtime_Debug_Resources_FILES CONFIGURE_DEPENDS | |
| ${CMAKE_CURRENT_SOURCE_DIR}/Plugin_Runtime_Dir/Debug/Resources/icos/*.* | |
| ) | |
| FILE(GLOB Plugin_Runtime_Release_Resources_FILES CONFIGURE_DEPENDS | |
| ${CMAKE_CURRENT_SOURCE_DIR}/Plugin_Runtime_Dir/Release/Resources/icos/*.* | |
| ) | |
| add_custom_target(CopyRuntimeFiles ALL | |
| VERBATIM | |
| COMMAND_EXPAND_LISTS | |
| COMMAND ${CMAKE_COMMAND} -E | |
| make_directory "${PROJECT_BINARY_DIR}/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>/" | |
| COMMAND ${CMAKE_COMMAND} -E | |
| copy_if_different | |
| "$<$<CONFIG:Release>:${Plugin_Runtime_Release_DLL_FILES}>" | |
| "$<$<CONFIG:Debug>:${Plugin_Runtime_Debug_DLL_FILES}>" | |
| "${PROJECT_BINARY_DIR}/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>/" | |
| COMMAND ${CMAKE_COMMAND} -E | |
| make_directory "${PROJECT_BINARY_DIR}/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>/Resources/icos/" | |
| COMMAND ${CMAKE_COMMAND} -E | |
| copy_if_different | |
| "$<$<CONFIG:Release>:${Plugin_Runtime_Release_Resources_FILES}>" | |
| "$<$<CONFIG:Debug>:${Plugin_Runtime_Debug_Resources_FILES}>" | |
| "${PROJECT_BINARY_DIR}/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>/Resources/icos/" | |
| COMMAND ${CMAKE_COMMAND} -E | |
| make_directory "${PROJECT_BINARY_DIR}/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>/Plugins/org_test_plugins/" | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment