From ded6285249bd994ee88a9b77cd88ec5f649525f9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 7 Jun 2020 18:35:33 -0400 Subject: [PATCH] CMAKE improvements: optional asset install; exe.debug for RelWithDebInfo --- CMakeLists.txt | 1 + assets/CMakeLists.txt | 32 +++++++++++++++++++++----------- src/sdl/CMakeLists.txt | 20 +++++++++++++++----- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e46f5dc3..480baa7ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,4 +131,5 @@ set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR}) set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR}) set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH}) set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}") +SET(CPACK_OUTPUT_FILE_PREFIX package) include(CPack) diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index 095349418..3ea7c28df 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -12,6 +12,9 @@ ENDFUNCTION(PREPEND) set(SRB2_ASSET_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/installer" CACHE STRING "Path to directory that contains all asset files for the installer.") +set(SRB2_ASSET_INSTALL ON + CACHE BOOL "Insert asset files into the install directory or package.") + #################### # POST-V2.2 NOTE: Do not forget to add patch.pk3 to the end of this list! #################### @@ -43,20 +46,27 @@ endforeach() if(${CMAKE_SYSTEM} MATCHES Darwin) get_target_property(outname SRB2SDL2 OUTPUT_NAME) - install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" - DESTINATION "${outname}.app/Contents/Resources" - ) + if(${SRB2_ASSET_INSTALL}) + install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" + DESTINATION "${outname}.app/Contents/Resources" + ) + endif() + # Always install the doc files, even in non-asset packages. install(FILES ${SRB2_ASSET_DOCS} DESTINATION . OPTIONAL ) else() - install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" - DESTINATION . - ) - # Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install again - #install(FILES ${SRB2_ASSET_DOCS} - # DESTINATION . - # OPTIONAL - #) + if(${SRB2_ASSET_INSTALL}) + install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" + DESTINATION . + ) + # Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install them in their own call. + else() + # Always install the doc files, even in non-asset packages. + install(FILES ${SRB2_ASSET_DOCS} + DESTINATION . + OPTIONAL + ) + endif() endif() diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index d5a5fc950..1e3d0f7a6 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -269,14 +269,18 @@ if(${SDL2_FOUND}) -DHAVE_SDL ) - ## strip debug symbols into separate file when using gcc - if(CMAKE_COMPILER_IS_GNUCC) - if(${CMAKE_BUILD_TYPE} MATCHES Debug) + ## strip debug symbols into separate file when using gcc. + ## to be consistent with Makefile, don't generate for OS X. + if((CMAKE_COMPILER_IS_GNUCC) AND NOT (${CMAKE_SYSTEM} MATCHES Darwin)) + if((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo)) + if(${CMAKE_BUILD_TYPE} MATCHES Debug) + set(OBJCOPY_ONLY_KEEP_DEBUG "--only-keep-debug") + endif() message(STATUS "Will make separate debug symbols in *.debug") add_custom_command(TARGET SRB2SDL2 POST_BUILD - COMMAND ${OBJCOPY} --only-keep-debug $ $.debug + COMMAND ${OBJCOPY} ${OBJCOPY_ONLY_KEEP_DEBUG} $ $.debug COMMAND ${OBJCOPY} --strip-debug $ - COMMAND ${OBJCOPY} --add-gnu-debuglink=$.debug $ + COMMAND ${OBJCOPY} --add-gnu-debuglink=$.debug $ ) endif() endif() @@ -290,6 +294,12 @@ if(${SDL2_FOUND}) install(TARGETS SRB2SDL2 SRB2SDL2 RUNTIME DESTINATION . ) + if ((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo)) + install(FILES $.debug + DESTINATION . + OPTIONAL + ) + endif() endif() if(${CMAKE_SYSTEM} MATCHES Windows)