Skip to content

Commit

Permalink
feat: register a simple cpack deferred execution (#120)
Browse files Browse the repository at this point in the history
Add a cpack module to be included when directory CMAKE_SOURCE_DIR ends.

Signed-off-by: msclock <[email protected]>
  • Loading branch information
msclock authored Sep 2, 2024
1 parent 08e6c7b commit 37b66c7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmake/ProjectDefault.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@ cmake_language(DEFER DIRECTORY ${CMAKE_SOURCE_DIR} CALL show_project_version)
cmake_language(DEFER DIRECTORY ${CMAKE_SOURCE_DIR} CALL
show_vcpkg_configuration)
cmake_language(DEFER DIRECTORY ${CMAKE_SOURCE_DIR} CALL show_installation)

# Cpack
set(__cpack_cmake_module
${CMAKE_CURRENT_LIST_DIR}/install/Cpack.cmake
CACHE
INTERNAL
"Cpack module path to be included when directory CMAKE_SOURCE_DIR ends"
FORCE)
cmake_language(DEFER DIRECTORY ${CMAKE_SOURCE_DIR} CALL include
${__cpack_cmake_module})
38 changes: 38 additions & 0 deletions cmake/install/Cpack.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#[[
Package generation using CPack

References:
- https://github.com/MangaD/cpp-project-template/blob/main/cmake/cpack_module.cmake
- https://github.com/gabime/spdlog/blob/v1.x/cmake/spdlogCPack.cmake
- https://github.com/retifrav/cmake-cpack-example/tree/master
]]
include_guard(GLOBAL)

set(CPACK_RESOURCE_FILE_README
"${CMAKE_CURRENT_SOURCE_DIR}/README.md"
CACHE STRING "Readme")
set(CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
CACHE STRING "License")
set(CPACK_SOURCE_GENERATOR
"TGZ;ZIP"
CACHE STRING "Source generator")
set(CPACK_PACKAGE_VERSION
${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH}
)
if(CMAKE_PROJECT_VERSION_TWEAK)
set(CPACK_PACKAGE_VERSION
${CPACK_PACKAGE_VERSION}.${CMAKE_PROJECT_VERSION_TWEAK})
endif()
# cmake-format: off
set(CPACK_SOURCE_IGNORE_FILES
/.git
/dist
/.*build.*
/out
/\\\\.DS_Store
CACHE STRING "CPack source ignore files"
)
# cmake-format: on

include(CPack)

0 comments on commit 37b66c7

Please sign in to comment.