CMake: Revamp CPack packaging
Vicki Pfau vi@endrift.com
Sat, 05 May 2018 13:55:56 -0700
2 files changed,
92 insertions(+),
18 deletions(-)
M
CMakeLists.txt
→
CMakeLists.txt
@@ -46,6 +46,7 @@ set(BUILD_GL ON CACHE STRING "Build with OpenGL")
set(BUILD_GLES2 OFF CACHE STRING "Build with OpenGL|ES 2") set(USE_EPOXY ON CACHE STRING "Build with libepoxy") set(DISABLE_DEPS OFF CACHE BOOL "Build without dependencies") +set(DISTBUILD OFF CACHE BOOL "Build distribution packages") if(WIN32) set(WIN32_UNIX_PATHS OFF CACHE BOOL "Use Unix-like paths") mark_as_advanced(WIN32_UNIX_PATHS)@@ -87,7 +88,7 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type (e.g. Release or Debug)" FORCE) endif() -if(NOT WIN32 OR WIN32_UNIX_PATHS) +if(UNIX OR WIN32_UNIX_PATHS) include(GNUInstallDirs) else() set(CMAKE_INSTALL_LIBDIR ".")@@ -110,6 +111,11 @@ set(OE_LIBDIR "${LIBDIR}" CACHE PATH "Installed library directory (OpenEmu)")
mark_as_advanced(OE_LIBDIR) endif() +if (DISTBUILD) + set(EXTRA_LICENSES "" CACHE FILEPATH "Extra licenses to include in distribution packaages") + mark_as_advanced(EXTRA_LICENSES) +endif() +mark_as_advanced(DISTBUILD) set(CMAKE_INSTALL_RPATH "${LIBDIR}")@@ -276,6 +282,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format")
endif() if(DEFINED 3DS OR DEFINED PSP2 OR DEFINED WII) + set(IS_EMBEDDED ON) set(USE_DEBUGGERS OFF) set(USE_SQLITE3 OFF) endif()@@ -331,9 +338,11 @@ set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,setlocale)
check_function_exists(setlocale HAVE_SETLOCALE) unset(CMAKE_REQUIRED_FLAGS) endif() - if(NOT DEFINED 3DS AND NOT DEFINED PSP2 AND NOT DEFINED WII) + if(NOT IS_EMBEDDED) set(DISABLE_DEPS ON CACHE BOOL "This platform cannot build with dependencies" FORCE) endif() + set(BUILD_STATIC ON CACHE BOOL "" FORCE) + set(BUILD_SHARED OFF CACHE BOOL "" FORCE) set(DISABLE_FRONTENDS ON) set(MINIMAL_CORE ON) set(ENABLE_EXTRA ON)@@ -761,15 +770,15 @@
target_link_libraries(${BINARY_NAME} ${DEBUGGER_LIB} ${DEPENDENCY_LIB} ${OS_LIB}) install(TARGETS ${BINARY_NAME} LIBRARY DESTINATION ${LIBDIR} COMPONENT lib${BINARY_NAME} NAMELINK_SKIP ARCHIVE DESTINATION ${LIBDIR} RUNTIME DESTINATION ${LIBDIR} COMPONENT lib${BINARY_NAME}) if(UNIX AND NOT APPLE AND NOT HAIKU) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-16.png DESTINATION share/icons/hicolor/16x16/apps RENAME mgba.png COMPONENT lib${BINARY_NAME}) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-24.png DESTINATION share/icons/hicolor/24x24/apps RENAME mgba.png COMPONENT lib${BINARY_NAME}) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-32.png DESTINATION share/icons/hicolor/32x32/apps RENAME mgba.png COMPONENT lib${BINARY_NAME}) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-48.png DESTINATION share/icons/hicolor/48x48/apps RENAME mgba.png COMPONENT lib${BINARY_NAME}) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-64.png DESTINATION share/icons/hicolor/64x64/apps RENAME mgba.png COMPONENT lib${BINARY_NAME}) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-96.png DESTINATION share/icons/hicolor/96x96/apps RENAME mgba.png COMPONENT lib${BINARY_NAME}) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-128.png DESTINATION share/icons/hicolor/128x128/apps RENAME mgba.png COMPONENT lib${BINARY_NAME}) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-256.png DESTINATION share/icons/hicolor/256x256/apps RENAME mgba.png COMPONENT lib${BINARY_NAME}) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-512.png DESTINATION share/icons/hicolor/512x512/apps RENAME mgba.png COMPONENT lib${BINARY_NAME}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-16.png DESTINATION share/icons/hicolor/16x16/apps RENAME mgba.png COMPONENT ${BINARY_NAME}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-24.png DESTINATION share/icons/hicolor/24x24/apps RENAME mgba.png COMPONENT ${BINARY_NAME}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-32.png DESTINATION share/icons/hicolor/32x32/apps RENAME mgba.png COMPONENT ${BINARY_NAME}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-48.png DESTINATION share/icons/hicolor/48x48/apps RENAME mgba.png COMPONENT ${BINARY_NAME}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-64.png DESTINATION share/icons/hicolor/64x64/apps RENAME mgba.png COMPONENT ${BINARY_NAME}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-96.png DESTINATION share/icons/hicolor/96x96/apps RENAME mgba.png COMPONENT ${BINARY_NAME}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-128.png DESTINATION share/icons/hicolor/128x128/apps RENAME mgba.png COMPONENT ${BINARY_NAME}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-256.png DESTINATION share/icons/hicolor/256x256/apps RENAME mgba.png COMPONENT ${BINARY_NAME}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/res/mgba-512.png DESTINATION share/icons/hicolor/512x512/apps RENAME mgba.png COMPONENT ${BINARY_NAME}) endif() else() set(BUILD_SHARED OFF)@@ -891,20 +900,35 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/core/flags.h.in ${CMAKE_CURRENT_BINARY_DIR}/flags.h)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/flags.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mgba COMPONENT lib${BINARY_NAME}) # Packaging -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/licenses DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT lib${BINARY_NAME}) -if(DEFINED EXTRA_LICENSES) - install(FILES ${EXTRA_LICENSES} DESTINATION ${CMAKE_INSTALL_DOCDIR}/licenses COMPONENT lib${BINARY_NAME}) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/licenses DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT ${BINARY_NAME}) +if(EXTRA_LICENSES) + install(FILES ${EXTRA_LICENSES} DESTINATION ${CMAKE_INSTALL_DOCDIR}/licenses COMPONENT ${BINARY_NAME}) endif() file(GLOB READMES ${CMAKE_CURRENT_SOURCE_DIR}/README*.md) -install(FILES ${READMES} ${CMAKE_CURRENT_SOURCE_DIR}/CHANGES DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT lib${BINARY_NAME}) +find_program(DOS2UNIX NAMES dos2unix) find_program(MARKDOWN NAMES markdown kramdown pandoc) + +if(UNIX OR NOT DOS2UNIX) + if(UNIX OR NOT MARKDOWN) + install(FILES ${READMES} DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT ${BINARY_NAME}) + endif() + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/CHANGES" "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT ${BINARY_NAME}) +else() + add_custom_command(OUTPUT CHANGES.txt COMMAND ${DOS2UNIX} -n "${CMAKE_CURRENT_SOURCE_DIR}/CHANGES" "${CMAKE_CURRENT_BINARY_DIR}/CHANGES.txt" MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/CHANGES") + add_custom_command(OUTPUT LICENSE.txt COMMAND ${DOS2UNIX} -n "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") + add_custom_target(CHANGES ALL DEPENDS CHANGES.txt) + add_custom_target(LICENSE ALL DEPENDS LICENSE.txt) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CHANGES.txt ${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT ${BINARY_NAME}) +endif() + if(MARKDOWN) foreach(README ${READMES}) get_filename_component(README_BASE "${README}" NAME_WE) - set(README_HTML "${README_BASE}.html") - install(CODE "execute_process(COMMAND \"${MARKDOWN}\" \"${README}\" OUTPUT_FILE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DOCDIR}/${README_HTML}\")") + add_custom_command(OUTPUT ${README_BASE}.html COMMAND ${MARKDOWN} "${README}" > ${README_BASE}.html MAIN_DEPENDENCY "${README}") + add_custom_target(${README_BASE} ALL DEPENDS ${README_BASE}.html) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${README_BASE}.html DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT ${BINARY_NAME}) endforeach() endif()@@ -925,7 +949,57 @@ SET(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_STRIP_FILES ${BINARY_NAME}) +if(DISTBUILD) + set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) + if(WIN32 OR APPLE) + set(CPACK_COMPONENTS_ALL ${BINARY_NAME} ${BINARY_NAME}-qt ${BINARY_NAME}-sdl ${BINARY_NAME}-perf) + set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE) + elseif(3DS) + set(CPACK_COMPONENTS_ALL ${BINARY_NAME} ${BINARY_NAME}-3ds ${BINARY_NAME}-perf) + elseif(WII) + set(CPACK_COMPONENTS_ALL ${BINARY_NAME} ${BINARY_NAME}-wii) + elseif(PSP2) + set(CPACK_COMPONENTS_ALL ${BINARY_NAME} ${BINARY_NAME}-psp2) + endif() +endif() + include(CPack) + +cpack_add_component_group(base) +cpack_add_component(${BINARY_NAME} GROUP base) + +cpack_add_component_group(dev PARENT_GROUP base) +if(BUILD_SHARED) + cpack_add_component(lib${BINARY_NAME} GROUP base) + if(BUILD_STATIC) + cpack_add_component(lib${BINARY_NAME}-static GROUP dev) + endif() +elseif(BUILD_STATIC) + cpack_add_component(lib${BINARY_NAME} GROUP dev) +endif() + +if(3DS) + cpack_add_component(${BINARY_NAME}-3ds GROUP base) +elseif(PSP2) + cpack_add_component(${BINARY_NAME}-psp2 GROUP base) +elseif(WII) + cpack_add_component(${BINARY_NAME}-wii GROUP base) +endif() + +if(BUILD_QT) + cpack_add_component_group(qt PARENT_GROUP base) + cpack_add_component(${BINARY_NAME}-qt GROUP qt DEPENDS base) +endif() + +if(BUILD_SDL) + cpack_add_component_group(sdl PARENT_GROUP base) + cpack_add_component(${BINARY_NAME}-sdl GROUP sdl DEPENDS base) +endif() + +cpack_add_component_group($test PARENT_GROUP dev) +cpack_add_component(${BINARY_NAME}-perf GROUP test DEPENDS dev) +cpack_add_component(${BINARY_NAME}-fuzz GROUP test DEPENDS dev) +cpack_add_component(tbl-fuzz GROUP test DEPENDS dev) # Summaries set(SUMMARY_GL_LIST)
M
src/platform/3ds/CMakeLists.txt
→
src/platform/3ds/CMakeLists.txt
@@ -109,7 +109,7 @@ ${3DSXTOOL} ../${BINARY_NAME}-perf ${BINARY_NAME}-perf.3dsx --smdh=${BINARY_NAME}.smdh
DEPENDS ${BINARY_NAME}-perf ${BINARY_NAME}.smdh) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}-perf.3dsx - DESTINATION . COMPONENT ${BINARY_NAME}-3ds) + DESTINATION . COMPONENT ${BINARY_NAME}-perf) endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cia.rsf.in ${CMAKE_CURRENT_BINARY_DIR}/cia.rsf)