diff options
Diffstat (limited to 'cmake/scripts/common/AddonHelpers.cmake')
| -rw-r--r-- | cmake/scripts/common/AddonHelpers.cmake | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/cmake/scripts/common/AddonHelpers.cmake b/cmake/scripts/common/AddonHelpers.cmake index c11923e..5470940 100644 --- a/cmake/scripts/common/AddonHelpers.cmake +++ b/cmake/scripts/common/AddonHelpers.cmake | |||
| @@ -6,15 +6,20 @@ | |||
| 6 | # Sadly we cannot extend the 'package' target, as it is a builtin target, see | 6 | # Sadly we cannot extend the 'package' target, as it is a builtin target, see |
| 7 | # http://public.kitware.com/Bug/view.php?id=8438 | 7 | # http://public.kitware.com/Bug/view.php?id=8438 |
| 8 | # Thus, we have to add an 'addon-package' target. | 8 | # Thus, we have to add an 'addon-package' target. |
| 9 | add_custom_target(addon-package | 9 | get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) |
| 10 | COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target package) | 10 | if(_isMultiConfig) |
| 11 | add_custom_target(addon-package DEPENDS PACKAGE) | ||
| 12 | else() | ||
| 13 | add_custom_target(addon-package | ||
| 14 | COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target package) | ||
| 15 | endif() | ||
| 11 | 16 | ||
| 12 | macro(add_cpack_workaround target version ext) | 17 | macro(add_cpack_workaround target version ext) |
| 13 | if(NOT PACKAGE_DIR) | 18 | if(NOT PACKAGE_DIR) |
| 14 | set(PACKAGE_DIR "${CMAKE_INSTALL_PREFIX}/zips") | 19 | set(PACKAGE_DIR "${CMAKE_INSTALL_PREFIX}/zips") |
| 15 | endif() | 20 | endif() |
| 16 | 21 | ||
| 17 | add_custom_command(TARGET addon-package PRE_BUILD | 22 | add_custom_command(TARGET addon-package POST_BUILD |
| 18 | COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIR} | 23 | COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGE_DIR} |
| 19 | COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_PACKAGE_DIRECTORY}/addon-${target}-${version}.${ext} ${PACKAGE_DIR}/${target}-${version}.${ext}) | 24 | COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_PACKAGE_DIRECTORY}/addon-${target}-${version}.${ext} ${PACKAGE_DIR}/${target}-${version}.${ext}) |
| 20 | endmacro() | 25 | endmacro() |
| @@ -194,7 +199,7 @@ macro (build_addon target prefix libs) | |||
| 194 | endif() | 199 | endif() |
| 195 | 200 | ||
| 196 | string(CONFIGURE "${addon_file}" addon_file_conf @ONLY) | 201 | string(CONFIGURE "${addon_file}" addon_file_conf @ONLY) |
| 197 | file(GENERATE OUTPUT ${PROJECT_SOURCE_DIR}/${target}/addon.xml CONTENT "${addon_file_conf}") | 202 | file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target}/addon.xml CONTENT "${addon_file_conf}") |
| 198 | if(${APP_NAME_UC}_BUILD_DIR) | 203 | if(${APP_NAME_UC}_BUILD_DIR) |
| 199 | file(GENERATE OUTPUT ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/addon.xml CONTENT "${addon_file_conf}") | 204 | file(GENERATE OUTPUT ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/addon.xml CONTENT "${addon_file_conf}") |
| 200 | endif() | 205 | endif() |
| @@ -207,7 +212,7 @@ macro (build_addon target prefix libs) | |||
| 207 | 212 | ||
| 208 | file(READ ${PROJECT_SOURCE_DIR}/${target}/resources/settings.xml.in settings_file) | 213 | file(READ ${PROJECT_SOURCE_DIR}/${target}/resources/settings.xml.in settings_file) |
| 209 | string(CONFIGURE "${settings_file}" settings_file_conf @ONLY) | 214 | string(CONFIGURE "${settings_file}" settings_file_conf @ONLY) |
| 210 | file(GENERATE OUTPUT ${PROJECT_SOURCE_DIR}/${target}/resources/settings.xml CONTENT "${settings_file_conf}") | 215 | file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target}/resources/settings.xml CONTENT "${settings_file_conf}") |
| 211 | if(${APP_NAME_UC}_BUILD_DIR) | 216 | if(${APP_NAME_UC}_BUILD_DIR) |
| 212 | file(GENERATE OUTPUT ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/resources/settings.xml CONTENT "${settings_file_conf}") | 217 | file(GENERATE OUTPUT ${${APP_NAME_UC}_BUILD_DIR}/addons/${target}/resources/settings.xml CONTENT "${settings_file_conf}") |
| 213 | endif() | 218 | endif() |
| @@ -230,7 +235,7 @@ macro (build_addon target prefix libs) | |||
| 230 | set(CPACK_COMPONENTS_IGNORE_GROUPS 1) | 235 | set(CPACK_COMPONENTS_IGNORE_GROUPS 1) |
| 231 | list(APPEND CPACK_COMPONENTS_ALL ${target}-${${prefix}_VERSION}) | 236 | list(APPEND CPACK_COMPONENTS_ALL ${target}-${${prefix}_VERSION}) |
| 232 | # Pack files together to create an archive | 237 | # Pack files together to create an archive |
| 233 | install(DIRECTORY ${target} DESTINATION ./ | 238 | install(DIRECTORY ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target} DESTINATION ./ |
| 234 | COMPONENT ${target}-${${prefix}_VERSION} | 239 | COMPONENT ${target}-${${prefix}_VERSION} |
| 235 | REGEX ".+\\.xml\\.in(clude)?$" EXCLUDE) | 240 | REGEX ".+\\.xml\\.in(clude)?$" EXCLUDE) |
| 236 | if(WIN32) | 241 | if(WIN32) |
| @@ -247,21 +252,15 @@ macro (build_addon target prefix libs) | |||
| 247 | endif() | 252 | endif() |
| 248 | endif() | 253 | endif() |
| 249 | 254 | ||
| 250 | # in case of a VC++ project the installation location contains a $(Configuration) VS variable | ||
| 251 | # we replace it with ${CMAKE_BUILD_TYPE} (which doesn't cover the case when the build configuration | ||
| 252 | # is changed within Visual Studio) | ||
| 253 | string(REPLACE "$(Configuration)" "${CMAKE_BUILD_TYPE}" LIBRARY_LOCATION "${LIBRARY_LOCATION}") | ||
| 254 | |||
| 255 | if(${prefix}_SOURCES) | 255 | if(${prefix}_SOURCES) |
| 256 | # install the generated DLL file | 256 | # install the generated DLL file |
| 257 | install(PROGRAMS ${LIBRARY_LOCATION} DESTINATION ${target} | 257 | install(PROGRAMS ${LIBRARY_LOCATION} DESTINATION ${target} |
| 258 | COMPONENT ${target}-${${prefix}_VERSION}) | 258 | COMPONENT ${target}-${${prefix}_VERSION}) |
| 259 | 259 | ||
| 260 | if(CMAKE_BUILD_TYPE MATCHES Debug) | 260 | # for debug builds also install the PDB file |
| 261 | # for debug builds also install the PDB file | 261 | install(FILES $<TARGET_PDB_FILE:${target}> DESTINATION ${target} |
| 262 | install(FILES $<TARGET_PDB_FILE:${target}> DESTINATION ${target} | 262 | CONFIGURATIONS Debug RelWithDebInfo |
| 263 | COMPONENT ${target}-${${prefix}_VERSION}) | 263 | COMPONENT ${target}-${${prefix}_VERSION}) |
| 264 | endif() | ||
| 265 | endif() | 264 | endif() |
| 266 | if(${prefix}_CUSTOM_BINARY) | 265 | if(${prefix}_CUSTOM_BINARY) |
| 267 | install(FILES ${LIBRARY_LOCATION} DESTINATION ${target} RENAME ${LIBRARY_FILENAME}) | 266 | install(FILES ${LIBRARY_LOCATION} DESTINATION ${target} RENAME ${LIBRARY_FILENAME}) |
| @@ -325,7 +324,7 @@ macro (build_addon target prefix libs) | |||
| 325 | if (${prefix}_CUSTOM_BINARY) | 324 | if (${prefix}_CUSTOM_BINARY) |
| 326 | install(FILES ${LIBRARY_LOCATION} DESTINATION ${CMAKE_INSTALL_LIBDIR}/addons/${target} RENAME ${LIBRARY_FILENAME}) | 325 | install(FILES ${LIBRARY_LOCATION} DESTINATION ${CMAKE_INSTALL_LIBDIR}/addons/${target} RENAME ${LIBRARY_FILENAME}) |
| 327 | endif() | 326 | endif() |
| 328 | install(DIRECTORY ${target} DESTINATION ${CMAKE_INSTALL_DATADIR}/addons | 327 | install(DIRECTORY ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target} DESTINATION ${CMAKE_INSTALL_DATADIR}/addons |
| 329 | REGEX ".+\\.xml\\.in(clude)?$" EXCLUDE) | 328 | REGEX ".+\\.xml\\.in(clude)?$" EXCLUDE) |
| 330 | if(${prefix}_CUSTOM_DATA) | 329 | if(${prefix}_CUSTOM_DATA) |
| 331 | install(DIRECTORY ${${prefix}_CUSTOM_DATA} DESTINATION ${CMAKE_INSTALL_DATADIR}/addons/${target}/resources) | 330 | install(DIRECTORY ${${prefix}_CUSTOM_DATA} DESTINATION ${CMAKE_INSTALL_DATADIR}/addons/${target}/resources) |
