diff --git a/CMakeLists.txt b/CMakeLists.txt index c0b0a19..6b07206 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,19 +20,25 @@ EndIf ( ) # Project ######################################################################################### +Include ( CTest ) +Include ( GNUInstallDirs ) Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppmicrohttpd-options.cmake ) +Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppmicrohttpd-const.cmake ) Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppmicrohttpd-var.cmake ) -Project ( cppmicrohttpd - DESCRIPTION "A simple library" +Project ( ${CPPMICROHTTPD_PROJECT_NAME} + DESCRIPTION "${CPPMICROHTTPD_PROJECT_DESCRIPTION}" VERSION "${CPPMICROHTTPD_VERSION}" ) -Include ( CTest ) -Include ( GNUInstallDirs ) # Subdirectories Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) # Install +If ( NOT CPPMICROHTTPD_HAS_EXPORT + OR NOT CPPMICROHTTPD_INSTALL_PACKAGE ) + Return ( ) +EndIf ( ) + Include ( CMakePackageConfigHelpers ) Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppmicrohttpd-config-version.cmake" VERSION ${CPPMICROHTTPD_VERSION} diff --git a/cmake/cppmicrohttpd-const.cmake b/cmake/cppmicrohttpd-const.cmake new file mode 100644 index 0000000..8d19c15 --- /dev/null +++ b/cmake/cppmicrohttpd-const.cmake @@ -0,0 +1,28 @@ +# This file contains constant variables that are fixed to this project + +# Version +Set ( CPPMICROHTTPD_VERSION_MAJOR 1 ) +Set ( CPPMICROHTTPD_VERSION_MINOR 0 ) +Set ( CPPMICROHTTPD_VERSION_PATCH 0 ) +Set ( CPPMICROHTTPD_VERSION_BUILD 0 ) +Set ( CPPMICROHTTPD_VERSION_HASH "" ) +Set ( CPPMICROHTTPD_VERSION_BEHIND 0 ) +Set ( CPPMICROHTTPD_VERSION_DIRTY 0 ) + +# Names +Set ( CPPMICROHTTPD_PROJECT_NAME "cppmicrohttpd" ) +Set ( CPPMICROHTTPD_PROJECT_DESCRIPTION "A simple hello world library" ) + +# Include generated variables for further usage +Include ( ${CMAKE_CURRENT_LIST_DIR}/cppmicrohttpd-var.cmake ) + +# Install directories +Set ( CPPMICROHTTPD_INSTALL_DIR_INCLUDE "${CMAKE_INSTALL_INCLUDEDIR}/${CPPMICROHTTPD_NAME}" ) +Set ( CPPMICROHTTPD_INSTALL_DIR_LIB "${CMAKE_INSTALL_LIBDIR}" ) +Set ( CPPMICROHTTPD_INSTALL_DIR_SHARE "${CMAKE_INSTALL_DATAROOTDIR}/${CPPMICROHTTPD_NAME}" ) + +# C Standard +Set ( CMAKE_C_STANDARD 11 ) +Set ( CMAKE_CXX_STANDARD 17 ) +Set ( CMAKE_C_STANDARD_REQUIRED ON ) +Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) diff --git a/cmake/cppmicrohttpd-options.cmake b/cmake/cppmicrohttpd-options.cmake index f2727a0..4f28727 100644 --- a/cmake/cppmicrohttpd-options.cmake +++ b/cmake/cppmicrohttpd-options.cmake @@ -1,3 +1,5 @@ +# This file contains options that can be passed to the cmake command + Option ( CPPMICROHTTPD_INSTALL_HEADER "Install headers of cppmicrohttpd." ON ) @@ -10,6 +12,9 @@ Option ( CPPMICROHTTPD_INSTALL_SHARED Option ( CPPMICROHTTPD_INSTALL_DEBUG "Install the stripped debug informations of cppmicrohttpd." OFF ) +Option ( CPPMICROHTTPD_INSTALL_PACKAGE + "Install the cmake package of cppmicrohttpd." + ON ) Option ( CPPMICROHTTPD_NO_STRIP "Do not strip debug symbols from binary." OFF ) diff --git a/cmake/cppmicrohttpd-var.cmake b/cmake/cppmicrohttpd-var.cmake index 6675c89..c09a34e 100644 --- a/cmake/cppmicrohttpd-var.cmake +++ b/cmake/cppmicrohttpd-var.cmake @@ -1,11 +1,4 @@ -# Version -Set ( CPPMICROHTTPD_VERSION_MAJOR 1 ) -Set ( CPPMICROHTTPD_VERSION_MINOR 0 ) -Set ( CPPMICROHTTPD_VERSION_PATCH 0 ) -Set ( CPPMICROHTTPD_VERSION_BUILD 0 ) -Set ( CPPMICROHTTPD_VERSION_HASH "" ) -Set ( CPPMICROHTTPD_VERSION_BEHIND 0 ) -Set ( CPPMICROHTTPD_VERSION_DIRTY 0 ) +# This file contains generated variables that are needed for the project # Git Version If ( CPPMICROHTTPD_USE_GIT_VERSION ) @@ -26,19 +19,8 @@ EndIf ( ) Set ( CPPMICROHTTPD_VERSION_SHORT "${CPPMICROHTTPD_VERSION_MAJOR}.${CPPMICROHTTPD_VERSION_MINOR}" ) Set ( CPPMICROHTTPD_VERSION "${CPPMICROHTTPD_VERSION_SHORT}.${CPPMICROHTTPD_VERSION_PATCH}.${CPPMICROHTTPD_VERSION_BUILD}" ) Set ( CPPMICROHTTPD_VERSION_COMPLETE "${CPPMICROHTTPD_VERSION}" ) -Set ( CPPMICROHTTPD_NAME "cppmicrohttpd-${CPPMICROHTTPD_VERSION_SHORT}" ) -Set ( CPPMICROHTTPD_OUTPUTNAME "cppmicrohttpd" ) +Set ( CPPMICROHTTPD_NAME "${CPPMICROHTTPD_PROJECT_NAME}-${CPPMICROHTTPD_VERSION_SHORT}" ) +Set ( CPPMICROHTTPD_OUTPUTNAME "${CPPMICROHTTPD_PROJECT_NAME}" ) If ( CPPMICROHTTPD_VERSION_BEHIND ) Set ( CPPMICROHTTPD_VERSION_COMPLETE "${CPPMICROHTTPD_VERSION_COMPLETE}+${CPPMICROHTTPD_VERSION_BEHIND}" ) EndIf ( ) - -# Install directories -Set ( CPPMICROHTTPD_INSTALL_DIR_INCLUDE "include/${CPPMICROHTTPD_NAME}" ) -Set ( CPPMICROHTTPD_INSTALL_DIR_LIB "lib" ) -Set ( CPPMICROHTTPD_INSTALL_DIR_SHARE "share/${CPPMICROHTTPD_NAME}" ) - -# C Standard -Set ( CMAKE_C_STANDARD 11 ) -Set ( CMAKE_CXX_STANDARD 17 ) -Set ( CMAKE_C_STANDARD_REQUIRED ON ) -Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) diff --git a/cmake/modules b/cmake/modules index 1a32531..ebbae4f 160000 --- a/cmake/modules +++ b/cmake/modules @@ -1 +1 @@ -Subproject commit 1a32531aef2deeebd5637b1873bc4e976628801c +Subproject commit ebbae4fbb42d671331b4c6e9d1d142f41dcacc1b diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 05fd49b..e1232cc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -112,6 +112,8 @@ EndIf ( ) # Install ######################################################################################### +Set ( CPPMICROHTTPD_HAS_EXPORT False PARENT_SCOPE ) + # Header If ( CPPMICROHTTPD_INSTALL_HEADER ) Install ( FILES ${CPPMICROHTTPD_INCLUDE_DIR}/cppmicrohttpd.h @@ -124,6 +126,7 @@ EndIf ( ) # Static If ( CPPMICROHTTPD_INSTALL_STATIC ) + Set ( CPPMICROHTTPD_HAS_EXPORT True PARENT_SCOPE ) Install ( TARGETS cppmicrohttpd-static EXPORT cppmicrohttpd DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_LIB} ) @@ -131,6 +134,7 @@ EndIf ( ) # Shared If ( CPPMICROHTTPD_INSTALL_SHARED ) + Set ( CPPMICROHTTPD_HAS_EXPORT True PARENT_SCOPE ) Install ( TARGETS cppmicrohttpd-shared EXPORT cppmicrohttpd DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_LIB} ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1c9d275..72a0b8c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -59,11 +59,6 @@ ForEach ( FILE IN LISTS CPPMICROHTTPD_TEST_SOURCE_FILES ) Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) EndIf ( ) - # optimization - If ( HAS_COTIRE ) - Cotire ( ${TEST_NAME} ) - EndIf ( ) - # test If ( HAS_CMAKE_TESTS ) Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} )