diff --git a/cmake/ProjectDefault.cmake b/cmake/ProjectDefault.cmake index 586f73f..8ac26ee 100644 --- a/cmake/ProjectDefault.cmake +++ b/cmake/ProjectDefault.cmake @@ -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}) diff --git a/cmake/install/Cpack.cmake b/cmake/install/Cpack.cmake new file mode 100644 index 0000000..80878ee --- /dev/null +++ b/cmake/install/Cpack.cmake @@ -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)