Skip to content

Commit de35ab6

Browse files
committed
Add CPack configuration for packaging with OS and architecture detection
1 parent d1ecd86 commit de35ab6

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,33 @@ else()
156156
COMPONENT MadsApps
157157
)
158158
endif()
159+
160+
161+
# PACKAGE #######################################################################
162+
string(TOLOWER "${CMAKE_SYSTEM_NAME}" PACKAGE_OS_NAME)
163+
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
164+
list(LENGTH CMAKE_OSX_ARCHITECTURES PACKAGE_OSX_ARCHITECTURES_COUNT)
165+
if(PACKAGE_OSX_ARCHITECTURES_COUNT GREATER 1)
166+
set(PACKAGE_ARCH_NAME "universal")
167+
else()
168+
set(PACKAGE_ARCH_NAME "${CMAKE_OSX_ARCHITECTURES}")
169+
endif()
170+
else()
171+
set(PACKAGE_ARCH_NAME "${CMAKE_SYSTEM_PROCESSOR}")
172+
endif()
173+
if(PACKAGE_ARCH_NAME STREQUAL "")
174+
set(PACKAGE_ARCH_NAME "${CMAKE_HOST_SYSTEM_PROCESSOR}")
175+
endif()
176+
if(PACKAGE_ARCH_NAME STREQUAL "")
177+
set(PACKAGE_ARCH_NAME "unknown")
178+
endif()
179+
string(TOLOWER "${PACKAGE_ARCH_NAME}" PACKAGE_ARCH_NAME)
180+
181+
set(CPACK_GENERATOR "ZIP")
182+
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
183+
set(CPACK_PACKAGE_VENDOR "MADS")
184+
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
185+
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY ON)
186+
set(CPACK_PACKAGE_FILE_NAME
187+
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${PACKAGE_OS_NAME}-${PACKAGE_ARCH_NAME}")
188+
include(CPack)

0 commit comments

Comments
 (0)