Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
CMake|OS X: Fixed issues with the CPack installation procedure
In custom install scripts, CMAKE_INSTALL_PREFIX will be different
when running CPack so the variable must not be evaluated already at
configuration time.
  • Loading branch information
skyjake committed Feb 27, 2015
1 parent dc209f5 commit 995fda4
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 24 deletions.
10 changes: 6 additions & 4 deletions doomsday/apps/client/CMakeLists.txt
Expand Up @@ -117,11 +117,13 @@ if (APPLE)
# installed app before the plugins are there so it won't do unnecessary
# work on them -- plugins are already self-contained.
get_property (outName TARGET client PROPERTY OUTPUT_NAME)
set (stageDir "${CMAKE_INSTALL_PREFIX}/${DENG_INSTALL_STAGING_DIR}/DengPlugins")
set (destDir "${CMAKE_INSTALL_PREFIX}/${outName}.app/Contents/DengPlugins")
install (CODE "execute_process (COMMAND ${CMAKE_COMMAND} -E remove_directory \"${destDir}\")")
set (stageDir "${DENG_BUILD_STAGING_DIR}/DengPlugins")
set (destDir "${outName}.app/Contents/DengPlugins")
install (CODE "execute_process (COMMAND ${CMAKE_COMMAND} -E remove_directory
\"\${CMAKE_INSTALL_PREFIX}/${destDir}\")")
deng_install_deployqt (client)
install (CODE "execute_process (COMMAND ${CMAKE_COMMAND} -E copy_directory \"${stageDir}\" \"${destDir}\")")
install (CODE "execute_process (COMMAND ${CMAKE_COMMAND} -E copy_directory \"${stageDir}\"
\"\${CMAKE_INSTALL_PREFIX}/${destDir}\")")
else ()
deng_install_deployqt (client)
endif ()
Expand Down
6 changes: 4 additions & 2 deletions doomsday/apps/plugins/PluginConfig.cmake
Expand Up @@ -44,7 +44,7 @@ macro (deng_add_plugin target)
# This is needed because we want access to these even in a build where the
# plugins are not installed yet -- the staging directory symlinks to the
# individual build directories.
set (stage "${CMAKE_INSTALL_PREFIX}/${DENG_INSTALL_STAGING_DIR}/DengPlugins")
set (stage "${DENG_BUILD_STAGING_DIR}/DengPlugins")
add_custom_command (TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${stage}"
COMMAND ${CMAKE_COMMAND} -E create_symlink
Expand All @@ -68,7 +68,9 @@ macro (deng_add_plugin target)
deng_target_rpath (${target})
endif ()

install (TARGETS ${target} LIBRARY DESTINATION ${DENG_INSTALL_PLUGIN_DIR})
install (TARGETS ${target}
LIBRARY DESTINATION ${DENG_INSTALL_PLUGIN_DIR}
)
set (_src)
set (_script)
endmacro (deng_add_plugin)
6 changes: 4 additions & 2 deletions doomsday/cmake/Config.cmake
Expand Up @@ -38,8 +38,10 @@ if (ARCH_BITS EQUAL 64)
endif ()
endif ()
set (DENG_INSTALL_PLUGIN_DIR "${DENG_INSTALL_LIB_DIR}/doomsday")
set (DENG_INSTALL_STAGING_DIR "bundle-staging")
set (CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "runtime")

set (DENG_BUILD_STAGING_DIR "${CMAKE_BINARY_DIR}/bundle-staging")

set (CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "client")

# Qt Configuration -----------------------------------------------------------

Expand Down
38 changes: 24 additions & 14 deletions doomsday/cmake/Macros.cmake
Expand Up @@ -273,7 +273,10 @@ function (deng_add_package packName)
LOCATION "${outDir}/${outName}"
FOLDER Packages
)
install (FILES ${outDir}/${outName} DESTINATION ${DENG_INSTALL_DATA_DIR})
install (FILES ${outDir}/${outName}
DESTINATION ${DENG_INSTALL_DATA_DIR}
COMPONENT packs
)
set (DENG_REQUIRED_PACKAGES ${DENG_REQUIRED_PACKAGES} ${packName} PARENT_SCOPE)
endfunction (deng_add_package)

Expand Down Expand Up @@ -301,6 +304,7 @@ function (deng_find_packages fullPaths)
set (${fullPaths} ${result} PARENT_SCOPE)
endfunction (deng_find_packages)

# Adds an SDK library target.
macro (deng_add_library target)
# Form the list of source files.
sublist (_src 1 -1 ${ARGV})
Expand Down Expand Up @@ -339,13 +343,17 @@ endmacro (deng_add_library)
macro (deng_deploy_library target name)
install (TARGETS ${target}
EXPORT ${name}
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${DENG_INSTALL_LIB_DIR}
INCLUDES DESTINATION include)
install (EXPORT ${name} DESTINATION lib/cmake/${name} NAMESPACE Deng::)
install (FILES ${name}Config.cmake DESTINATION lib/cmake/${name})
RUNTIME DESTINATION bin COMPONENT libs
LIBRARY DESTINATION ${DENG_INSTALL_LIB_DIR} COMPONENT libs
INCLUDES DESTINATION include COMPONENT sdk
ARCHIVE DESTINATION lib COMPONENT sdk
)
install (EXPORT ${name} DESTINATION lib/cmake/${name} NAMESPACE Deng::
COMPONENT sdk
)
install (FILES ${name}Config.cmake DESTINATION lib/cmake/${name} COMPONENT sdk)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/de)
install (DIRECTORY include/de DESTINATION include)
install (DIRECTORY include/de DESTINATION include COMPONENT sdk)
endif ()
endmacro (deng_deploy_library)

Expand Down Expand Up @@ -494,7 +502,7 @@ macro (deng_install_bundle_deps target)
if (APPLE)
sublist (_deps 1 -1 ${ARGV})
get_property (_outName TARGET ${target} PROPERTY OUTPUT_NAME)
set (_fwDir "${CMAKE_INSTALL_PREFIX}/${_outName}.app/Contents/Frameworks")
set (_fwDir "${_outName}.app/Contents/Frameworks")
foreach (_dep ${_deps})
if (TARGET ${_dep})
if (_dep MATCHES "Deng::(.*)")
Expand Down Expand Up @@ -523,8 +531,10 @@ function (deng_install_deployqt target)
if (NOT MACDEPLOYQT_COMMAND)
message (FATAL_ERROR "macdeployqt not available")
endif ()
install (CODE "message (STATUS \"Running macdeployqt on ${_outName}.app...\")
execute_process (COMMAND ${MACDEPLOYQT_COMMAND} \"${CMAKE_INSTALL_PREFIX}/${_outName}.app\"
install (CODE "
message (STATUS \"Running macdeployqt on ${_outName}.app...\")
execute_process (COMMAND ${MACDEPLOYQT_COMMAND}
\"\${CMAKE_INSTALL_PREFIX}/${_outName}.app\"
OUTPUT_QUIET ERROR_QUIET)")
elseif (WIN32)
if (NOT WINDEPLOYQT_COMMAND)
Expand All @@ -534,10 +544,10 @@ function (deng_install_deployqt target)
string (REPLACE "/" "\\" qtPath ${QT_PREFIX_DIR})
file (WRITE ${script} "
set PATH=${qtPath}\\bin
windeployqt --no-translations \"${CMAKE_INSTALL_PREFIX}/bin/${_outName}.exe\"
windeployqt --no-translations \"%1/bin/${_outName}.exe\"
")
install (CODE "message (STATUS \"Running windeployqt on ${_outName}.exe...\")
execute_process (COMMAND ${script} OUTPUT_QUIET ERROR_QUIET)")
execute_process (COMMAND ${script} \"\${CMAKE_INSTALL_PREFIX}\" OUTPUT_QUIET ERROR_QUIET)")
endif ()
endfunction (deng_install_deployqt)

Expand All @@ -557,7 +567,7 @@ function (deng_install_tool target)
install (CODE "
include (${DENG_SOURCE_DIR}/cmake/Macros.cmake)
set (CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL})
fix_bundled_install_names (\"${CMAKE_INSTALL_PREFIX}/${dest}/${name}\"
fix_bundled_install_names (\"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${dest}/${name}\"
QtCore.framework/Versions/5/QtCore
QtNetwork.framework/Versions/5/QtNetwork
VERBATIM)
Expand All @@ -579,7 +589,7 @@ macro (deng_install_library library)
)
elseif (MSVC)
message (STATUS "Library will be installed: ${library}")
install (FILES ${library} DESTINATION ${DENG_INSTALL_LIB_DIR})
install (PROGRAMS ${library} DESTINATION ${DENG_INSTALL_LIB_DIR})
endif ()
endmacro (deng_install_library)

Expand Down
20 changes: 20 additions & 0 deletions doomsday/cmake/Packaging.cmake
@@ -0,0 +1,20 @@
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Doomsday Engine")
set (CPACK_PACKAGE_VENDOR "Jaakko Keränen (skyjake)")
set (CPACK_PACKAGE_VERSION_MAJOR ${DENG_VERSION_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${DENG_VERSION_MINOR})
if (DENG_BUILD AND NOT DENG_STABLE)
set (CPACK_PACKAGE_VERSION_PATCH "${DENG_VERSION_PATCH}-build${DENG_BUILD}")
else ()
set (CPACK_PACKAGE_VERSION_PATCH ${DENG_VERSION_PATCH})
endif ()
set (CPACK_PACKAGE_INSTALL_DIRECTORY "Doomsday ${DENG_VERSION_MAJOR}.${DENG_VERSION_MINOR}")

set (CPACK_GENERATOR ZIP)

# Source packaging.
set (CPACK_SOURCE_GENERATOR TXZ;ZIP)
set (CPACK_SOURCE_IGNORE_FILES "\\\\.DS_Store$;\\\\.user$;\\\\.user\\\\.")

if (NOT CPack_CMake_INCLUDED)
include (CPack)
endif ()
6 changes: 5 additions & 1 deletion doomsday/cmake/Version.cmake
@@ -1,4 +1,8 @@
set (DENG_VERSION 1.15.0)
set (DENG_VERSION_MAJOR 1)
set (DENG_VERSION_MINOR 15)
set (DENG_VERSION_PATCH 0)

set (DENG_VERSION ${DENG_VERSION_MAJOR}.${DENG_VERSION_MINOR}.${DENG_VERSION_PATCH})

# Binary compatibility version for shared libraries / APIs.
set (DENG_COMPAT_VERSION 1.15)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/tests/TestConfig.cmake
Expand Up @@ -12,5 +12,5 @@ macro (deng_test target)
target_link_libraries (${target} Deng::libcore)
deng_target_defaults (${target})
set_property (TARGET ${target} PROPERTY FOLDER Tests)
install (TARGETS ${target} DESTINATION bin)
install (TARGETS ${target} DESTINATION bin COMPONENT test)
endmacro (deng_test)

0 comments on commit 995fda4

Please sign in to comment.