diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e9e0ed..32428f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,11 +7,17 @@ project(EventBusDev) option(ENABLE_TEST "Enable test" ON) option(ENABLE_PERFORMANCE "Enable performance subproject" OFF) +option(ENABLE_CPACK "Enable CPack packaging" ON) set(CMAKE_CXX_STANDARD 14) add_subdirectory(lib/) +if(ENABLE_CPACK) + include("lib/cmake/EventBus_CPack.cmake") + enable_cpack("RPM;DEB;TGZ") +endif() + if(ENABLE_TEST) enable_testing() add_subdirectory(test/) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index dbb7c19..8671ff4 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -109,20 +109,3 @@ install(EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${config_install_dir}" NAMESPACE "${namespace}" ) - -# CPack Configuration -set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) -set(CPACK_GENERATOR "RPM;DEB;TGZ") -set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) -set(CPACK_PACKAGE_RELEASE 1) -set(CPACK_PACKAGE_CONTACT "gelldur") -set(CPACK_PACKAGE_VENDOR "gelldur") -set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) -set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}") -set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION -"${CMAKE_INSTALL_PREFIX}" -"${CMAKE_INSTALL_PREFIX}/include" -"${CMAKE_INSTALL_PREFIX}/lib64" -"${CMAKE_INSTALL_PREFIX}/lib" -) -include(CPack) \ No newline at end of file diff --git a/lib/cmake/EventBus_CPack.cmake b/lib/cmake/EventBus_CPack.cmake new file mode 100644 index 0000000..c47b861 --- /dev/null +++ b/lib/cmake/EventBus_CPack.cmake @@ -0,0 +1,18 @@ +# CPack Configuration +function(enable_cpack generator) + set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) + set(CPACK_GENERATOR ${generator}) + set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) + set(CPACK_PACKAGE_RELEASE 1) + set(CPACK_PACKAGE_CONTACT "gelldur") + set(CPACK_PACKAGE_VENDOR "gelldur") + set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) + set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}") + set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION + "${CMAKE_INSTALL_PREFIX}" + "${CMAKE_INSTALL_PREFIX}/include" + "${CMAKE_INSTALL_PREFIX}/lib64" + "${CMAKE_INSTALL_PREFIX}/lib" + ) + include(CPack) +endfunction()