From f63d297e53ad536b3635b2bd3afce6210e7ff86d Mon Sep 17 00:00:00 2001 From: "Fletcher T. Penney" Date: Mon, 9 Nov 2015 07:42:50 -0500 Subject: [PATCH] restructure CMakeLists; support Zip package generator flag --- CMakeLists.txt | 102 +++++++++++++++++++++++++++++++------------------ 1 file changed, 64 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44e0320..76b20fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,9 +59,9 @@ configure_file ( ) -# ============= -# Build Targets -# ============= +# ============ +# Source Files +# ============ # src_files are the primary files, and will be included in doxygen documentation set(src_files @@ -82,31 +82,6 @@ set(header_utility_files ${PROJECT_BINARY_DIR}/version.h ) -# Create a library? -# add_library(libFOO STATIC -# ${src_files} -# ${src_utility_files} -# ${header_files} -# ${header_utility_files} -# ) - -# remove the extra "lib" from "liblibFOO" -# SET_TARGET_PROPERTIES(libFOO PROPERTIES PREFIX "") - -# Create a command-line app? -# if (NOT DEFINED TEST) -# add_executable(main -# src/main.c -# src/GLibFacade.c -# src/GLibFacade.h -# ${header_files} -# ) -# -# Link the library to the app? -# target_link_libraries(main libFOO) -# endif() - - # Generate doxygen configuration file string(REPLACE ";" " " doxygen_src_files "${src_files}" ) string(REPLACE ";" " " doxygen_header_files "${header_files}" ) @@ -161,11 +136,11 @@ endif() # Configure for Target OS # ======================= -# OS X Machines +# OS X Builds if (APPLE) # Configure backwards-compatible support (if your project allows it) - # SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.4" CACHE STRING "Deployment target for OSX" FORCE) + SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.4" CACHE STRING "Deployment target for OSX" FORCE) # Compile for x86_64 and i386. ppc no longer supported if(CMAKE_BUILD_TYPE MATCHES "Release") @@ -173,20 +148,25 @@ if (APPLE) endif(CMAKE_BUILD_TYPE MATCHES "Release") # Use PackageMaker for installers? - # set (CPACK_GENERATOR PackageMaker) - set (CPACK_GENERATOR ZIP) - + if (DEFINED ZIP) + set (CPACK_GENERATOR ZIP) + else (DEFINED ZIP) + set (CPACK_GENERATOR PackageMaker) + endif (DEFINED ZIP) endif (APPLE) -# Windows Machines +# Windows Builds if (WIN32) # Use NSIS to generate installers? - # set (CPACK_GENERATOR NSIS) - set (CPACK_GENERATOR ZIP) + if (DEFINED ZIP) + set (CPACK_GENERATOR ZIP) + else (DEFINED ZIP) + set (CPACK_GENERATOR NSIS) + endif (DEFINED ZIP) -# Linux (but not cross-compiling for Windows) +# Linux Builds (not cross-compiling for Windows) elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") # Create zip archive @@ -200,6 +180,35 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") endif (WIN32) +# ============== +# Define targets +# ============== + +# Create a library? +# add_library(libFOO STATIC +# ${src_files} +# ${src_utility_files} +# ${header_files} +# ${header_utility_files} +# ) + +# remove the extra "lib" from "liblibFOO" +# SET_TARGET_PROPERTIES(libFOO PROPERTIES PREFIX "") + +# Create a command-line app? +# if (NOT DEFINED TEST) +# add_executable(main +# src/main.c +# src/GLibFacade.c +# src/GLibFacade.h +# ${header_files} +# ) +# +# Link the library to the app? +# target_link_libraries(main libFOO) +# endif() + + # ========================== # Build Installer with CPack # ========================== @@ -216,6 +225,23 @@ set (CPACK_PACKAGE_VERSION "${My_Project_Version_Major}.${My_Project_Version_Min set (CPACK_PACKAGE_VERSION_MAJOR "${My_Project_Version_Major}") set (CPACK_PACKAGE_VERSION_MINOR "${My_Project_Version_Minor}") set (CPACK_PACKAGE_VERSION_PATCH "My_Project_Version_Patch") - + +set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt") + +if (APPLE) + set (CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-Mac-${CPACK_PACKAGE_VERSION}") +else (APPLE) + set (CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CMAKE_SYSTEM_NAME}-${CPACK_PACKAGE_VERSION}") +endif (APPLE) + +# Use some default install locations (if appropriate) +if (WIN32) + set (CPACK_INSTALL_PREFIX "") + set (CPACK_NSIS_MODIFY_PATH ON) +else (WIN32) + set (CPACK_INSTALL_PREFIX /usr/local) +endif (WIN32) + +set (CPACK_PACKAGE_INSTALL_DIRECTORY ${PROJECT}) include (CPack) -- 2.40.0