@@ -18,6 +18,11 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows")
1818 message (STATUS "Specifying YY_NO_UNISTD_H" )
1919endif ()
2020
21+ # Define macro to identify macOS system
22+ if (CMAKE_SYSTEM_NAME MATCHES "Darwin" )
23+ set (CMT_SYSTEM_MACOS On )
24+ add_definitions (-DCMT_SYSTEM_MACOS)
25+ endif ()
2126
2227if (NOT MSVC )
2328 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall" )
@@ -26,7 +31,7 @@ endif()
2631# CMetrics Version
2732set (CMT_VERSION_MAJOR 0)
2833set (CMT_VERSION_MINOR 3)
29- set (CMT_VERSION_PATCH 1 )
34+ set (CMT_VERSION_PATCH 4 )
3035set (CMT_VERSION_STR "${CMT_VERSION_MAJOR} .${CMT_VERSION_MINOR} .${CMT_VERSION_PATCH} " )
3136
3237# Define __FILENAME__ consistently across Operating Systems
@@ -222,6 +227,7 @@ endif()
222227# Enable components
223228set (CPACK_DEB_COMPONENT_INSTALL ON )
224229set (CPACK_RPM_COMPONENT_INSTALL ON )
230+ set (CPACK_productbuild_COMPONENT_INSTALL ON )
225231set (CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} binary library headers)
226232set (CPACK_COMPONENTS_GROUPING "ONE_PER_GROUP" )
227233
@@ -275,4 +281,40 @@ if(CPACK_GENERATOR MATCHES "ZIP")
275281 set (CPACK_PACKAGE_INSTALL_DIRECTORY "cmetrics" )
276282endif ()
277283
284+ # CPack: macOS w/ productbuild
285+ if (CMT_SYSTEM_MACOS)
286+ # Determine the platform suffix
287+ execute_process (
288+ COMMAND uname -m
289+ RESULT_VARIABLE UNAME_M_RESULT
290+ OUTPUT_VARIABLE UNAME_ARCH
291+ OUTPUT_STRIP_TRAILING_WHITESPACE
292+ )
293+ if (UNAME_M_RESULT EQUAL 0 AND UNAME_ARCH STREQUAL "arm64" )
294+ set (CMETRICS_PKG ${CMAKE_CURRENT_BINARY_DIR} /${CPACK_PACKAGE_NAME} -${CMT_VERSION_STR} -apple )
295+ elseif (UNAME_M_RESULT EQUAL 0 AND UNAME_ARCH STREQUAL "x86_64" )
296+ set (CMETRICS_PKG ${CMAKE_CURRENT_BINARY_DIR} /${CPACK_PACKAGE_NAME} -${CMT_VERSION_STR} -intel)
297+ else ()
298+ set (CMETRICS_PKG ${CMAKE_CURRENT_BINARY_DIR} /${CPACK_PACKAGE_NAME} -${CMT_VERSION_STR} -${UNAME_ARCH} )
299+ endif ()
300+
301+ if (CPACK_GENERATOR MATCHES "productbuild" )
302+ set (CPACK_SET_DESTDIR "ON" )
303+ configure_file (cpack/macos/welcome.txt.cmakein ${CMAKE_CURRENT_BINARY_DIR} /welcome.txt)
304+ configure_file (LICENSE ${CMAKE_CURRENT_BINARY_DIR} /LICENSE.txt)
305+ find_program (CONVERTER textutil)
306+ if (NOT CONVERTER)
307+ message (FATAL_ERROR "textutil not found." )
308+ endif ()
309+ if (CONVERTER)
310+ execute_process (COMMAND ${CONVERTER} -convert html "${CMAKE_SOURCE_DIR} /README.md" -output "${CMAKE_BINARY_DIR} /README.html" )
311+ endif ()
312+ set (CPACK_PACKAGE_FILE_NAME "${CMETRICS_PKG} " )
313+ set (CPACK_RESOURCE_FILE_WELCOME ${CMAKE_CURRENT_BINARY_DIR} /welcome.txt)
314+ set (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_BINARY_DIR} /LICENSE.txt)
315+ set (CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_BINARY_DIR} /README.html)
316+ set (CPACK_PRODUCTBUILD_IDENTIFIER "com.calyptia.${CPACK_PACKAGE_NAME} " )
317+ endif ()
318+ endif ()
319+
278320include (CPack)
0 commit comments