From c1e9a8fa8188075be060726e95e6bc9592cbccbb Mon Sep 17 00:00:00 2001 From: bergmann Date: Wed, 6 Nov 2019 23:35:02 +0100 Subject: [PATCH] * Updated project structure --- .gitmodules | 2 +- CMakeLists.txt | 98 ++++++------ README.md | 3 + cmake/cppmicrohttpd-const.cmake | 34 ++-- cmake/cppmicrohttpd-options.cmake | 54 +++---- cmake/cppmicrohttpd-var.cmake | 48 +++--- cmake/modules | 2 +- src/CMakeLists.txt | 253 ++++++++++++++++-------------- test/CMakeLists.txt | 113 ++++++------- 9 files changed, 316 insertions(+), 291 deletions(-) create mode 100644 README.md diff --git a/.gitmodules b/.gitmodules index a89889c..37e8830 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "cmake/modules"] path = cmake/modules - url = b3rgmann@git.bergmann89.de:cpp/CmakeModules.git + url = b3rgmann@git.bergmann89.de:cpp/CMakeModules.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b07206..c91cd15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,63 +1,63 @@ # Initialize CMake ################################################################################ -CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR ) +CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR ) # Set CMAKE_BUILD_TYPE -If ( NOT CMAKE_BUILD_TYPE ) - Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) -EndIf ( NOT CMAKE_BUILD_TYPE ) -Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel ) +If ( NOT CMAKE_BUILD_TYPE ) + Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) +EndIf ( NOT CMAKE_BUILD_TYPE ) +Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel ) # Set CMAKE_MODULE_PATH -If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) - Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) -EndIf ( ) -If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) - Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) -EndIf ( ) +If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) + Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) +EndIf ( ) +If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake" ) + Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake" ) +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_PROJECT_NAME} - DESCRIPTION "${CPPMICROHTTPD_PROJECT_DESCRIPTION}" - VERSION "${CPPMICROHTTPD_VERSION}" ) +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_PROJECT_NAME} + DESCRIPTION "${CPPMICROHTTPD_PROJECT_DESCRIPTION}" + VERSION "${CPPMICROHTTPD_VERSION}" ) +Include ( CTest ) # Subdirectories -Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) -Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) +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} - COMPATIBILITY AnyNewerVersion ) -Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppmicrohttpd-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppmicrohttpd-config.cmake" - @ONLY ) - -Set ( ConfigPackageLocation "${CPPMICROHTTPD_INSTALL_DIR_SHARE}/cmake" ) -Install ( EXPORT - cppmicrohttpd - NAMESPACE - cppmicrohttpd:: - DESTINATION - ${ConfigPackageLocation} ) -Install ( FILES +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} + COMPATIBILITY AnyNewerVersion ) +Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppmicrohttpd-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppmicrohttpd-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppmicrohttpd-config-version.cmake" - DESTINATION - ${ConfigPackageLocation} - COMPONENT - Devel ) + @ONLY ) + +Set ( ConfigPackageLocation "${CPPMICROHTTPD_INSTALL_DIR_SHARE}/cmake" ) +Install ( EXPORT + cppmicrohttpd + NAMESPACE + cppmicrohttpd:: + DESTINATION + ${ConfigPackageLocation} ) +Install ( FILES + "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppmicrohttpd-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppmicrohttpd-config-version.cmake" + DESTINATION + ${ConfigPackageLocation} + COMPONENT + Devel ) diff --git a/README.md b/README.md new file mode 100644 index 0000000..249b4f1 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# cppmicrohttpd + +C++ warpper library for libmicrohttpd. diff --git a/cmake/cppmicrohttpd-const.cmake b/cmake/cppmicrohttpd-const.cmake index 8d19c15..dbe8615 100644 --- a/cmake/cppmicrohttpd-const.cmake +++ b/cmake/cppmicrohttpd-const.cmake @@ -1,28 +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 ) +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" ) +Set ( CPPMICROHTTPD_PROJECT_NAME "cppmicrohttpd" ) +Set ( CPPMICROHTTPD_PROJECT_DESCRIPTION "C++ wrapper library for libmicrohttpd" ) # Include generated variables for further usage -Include ( ${CMAKE_CURRENT_LIST_DIR}/cppmicrohttpd-var.cmake ) +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}" ) +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 ) +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 4f28727..d877a08 100644 --- a/cmake/cppmicrohttpd-options.cmake +++ b/cmake/cppmicrohttpd-options.cmake @@ -1,29 +1,29 @@ # This file contains options that can be passed to the cmake command -Option ( CPPMICROHTTPD_INSTALL_HEADER - "Install headers of cppmicrohttpd." - ON ) -Option ( CPPMICROHTTPD_INSTALL_STATIC - "Install static library of cppmicrohttpd." - ON ) -Option ( CPPMICROHTTPD_INSTALL_SHARED - "Install shared library of cppmicrohttpd." - ON ) -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 ) -Option ( CPPMICROHTTPD_USE_GIT_VERSION - "Read the git tags to get the version of cppmicrohttpd" - ON ) -If ( NOT CPPMICROHTTPD_LOGGING ) - Set ( CPPMICROHTTPD_LOGGING none - CACHE STRING "Specify how cppmicrohttpd should write log entries." ) - Set_Property ( CACHE CPPMICROHTTPD_LOGGING - PROPERTY STRINGS none stdout cpplogging ) -EndIf ( ) +Option ( CPPMICROHTTPD_INSTALL_HEADER + "Install headers of cppmicrohttpd." + ON ) +Option ( CPPMICROHTTPD_INSTALL_STATIC + "Install static library of cppmicrohttpd." + ON ) +Option ( CPPMICROHTTPD_INSTALL_SHARED + "Install shared library of cppmicrohttpd." + ON ) +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 ) +Option ( CPPMICROHTTPD_USE_GIT_VERSION + "Read the git tags to get the version of cppmicrohttpd" + ON ) +If ( NOT CPPMICROHTTPD_LOGGING ) + Set ( CPPMICROHTTPD_LOGGING none + CACHE STRING "Specify how cppmicrohttpd should write log entries." ) + Set_Property ( CACHE CPPMICROHTTPD_LOGGING + PROPERTY STRINGS none stdout cpplogging ) +EndIf ( ) diff --git a/cmake/cppmicrohttpd-var.cmake b/cmake/cppmicrohttpd-var.cmake index c09a34e..8c34d2d 100644 --- a/cmake/cppmicrohttpd-var.cmake +++ b/cmake/cppmicrohttpd-var.cmake @@ -1,26 +1,32 @@ # This file contains generated variables that are needed for the project # Git Version -If ( CPPMICROHTTPD_USE_GIT_VERSION ) - Include ( git_helper OPTIONAL RESULT_VARIABLE HAS_GIT_HELPER ) - If ( HAS_GIT_HELPER ) - GitGetVersion ( ${CMAKE_CURRENT_LIST_DIR}/.. - CPPMICROHTTPD_VERSION_MAJOR - CPPMICROHTTPD_VERSION_MINOR - CPPMICROHTTPD_VERSION_PATCH - CPPMICROHTTPD_VERSION_BUILD - CPPMICROHTTPD_VERSION_HASH - CPPMICROHTTPD_VERSION_BEHIND - CPPMICROHTTPD_VERSION_DIRTY ) - EndIf ( ) -EndIf ( ) +If ( CPPMICROHTTPD_USE_GIT_VERSION ) + Include ( git_helper OPTIONAL RESULT_VARIABLE HAS_GIT_HELPER ) + If ( HAS_GIT_HELPER ) + GitGetVersion ( ${CMAKE_CURRENT_LIST_DIR}/.. + CPPMICROHTTPD_VERSION_MAJOR + CPPMICROHTTPD_VERSION_MINOR + CPPMICROHTTPD_VERSION_PATCH + CPPMICROHTTPD_VERSION_BUILD + CPPMICROHTTPD_VERSION_HASH + CPPMICROHTTPD_VERSION_BEHIND + CPPMICROHTTPD_VERSION_DIRTY ) + EndIf ( ) +EndIf ( ) # Strings -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_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 ( ) +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_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 ( ) diff --git a/cmake/modules b/cmake/modules index ebbae4f..94b9877 160000 --- a/cmake/modules +++ b/cmake/modules @@ -1 +1 @@ -Subproject commit ebbae4fbb42d671331b4c6e9d1d142f41dcacc1b +Subproject commit 94b9877d65e46c9d8169ebc46f163d02e4d9dcf3 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e1232cc..c654ed0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,150 +1,159 @@ # Initialize ###################################################################################### -Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) -Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) -Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) - -Find_Package ( cppcore REQUIRED ) -Find_Package ( libmicrohttpd REQUIRED ) - -If ( CPPMICROHTTPD_LOGGING MATCHES none ) - Set ( CPPMICROHTTPD_LOGGING_NONE true ) -ElseIf ( CPPMICROHTTPD_LOGGING MATCHES stdcout ) - Set ( CPPMICROHTTPD_LOGGING_STDCOUT true ) -ElseIf ( CPPMICROHTTPD_LOGGING MATCHES cpplogging ) - Find_Package ( cpplogging QUIET ) - If ( cpplogging_FOUND ) - Set ( CPPMICROHTTPD_LOGGING_CPPLOGGING true ) - Else ( ) - Set ( CPPMICROHTTPD_LOGGING_STDCOUT true ) - EndIf ( ) -EndIf ( ) +Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) +Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) +Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) + +Find_Package ( Sanitizers QUIET ) +Find_Package ( cppcore REQUIRED ) +Find_Package ( libmicrohttpd REQUIRED ) + +If ( CPPMICROHTTPD_LOGGING MATCHES none ) + Set ( CPPMICROHTTPD_LOGGING_NONE true ) +ElseIf ( CPPMICROHTTPD_LOGGING MATCHES stdcout ) + Set ( CPPMICROHTTPD_LOGGING_STDCOUT true ) +ElseIf ( CPPMICROHTTPD_LOGGING MATCHES cpplogging ) + Find_Package ( cpplogging QUIET ) + If ( cpplogging_FOUND ) + Set ( CPPMICROHTTPD_LOGGING_CPPLOGGING true ) + Else ( ) + Set ( CPPMICROHTTPD_LOGGING_STDCOUT true ) + EndIf ( ) +EndIf ( ) + # Object Library ################################################################################## -Set ( CMAKE_POSITION_INDEPENDENT_CODE ON ) -Set ( CPPMICROHTTPD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include ) -Set ( CPPMICROHTTPD_GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated/include ) -Configure_File ( ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/config.h.in - ${CPPMICROHTTPD_GENERATED_INCLUDE_DIR}/cppmicrohttpd/config.h ) -File ( GLOB_RECURSE CPPMICROHTTPD_HEADER_FILES ${CPPMICROHTTPD_INCLUDE_DIR}/*.h ) -File ( GLOB_RECURSE CPPMICROHTTPD_INLINE_FILES ${CPPMICROHTTPD_INCLUDE_DIR}/*.inl ) -File ( GLOB_RECURSE CPPMICROHTTPD_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) -Add_Library ( cppmicrohttpd-objects - OBJECT - ${CPPMICROHTTPD_HEADER_FILES} - ${CPPMICROHTTPD_INLINE_FILES} - ${CPPMICROHTTPD_SOURCE_FILES} ) -Target_Include_Directories ( cppmicrohttpd-objects - PUBLIC - $ - $ - $ ) -Target_Link_Libraries ( cppmicrohttpd-objects - PUBLIC - cppcore::cppcore ) -If ( CPPMICROHTTPD_LOGGING_CPPLOGGING ) - Target_Link_Libraries ( cppmicrohttpd-objects - PUBLIC - cpplogging::cpplogging-shared ) -EndIf ( ) +Set ( CPPMICROHTTPD_GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated/include ) +Configure_File ( ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/config.h.in + ${CPPMICROHTTPD_GENERATED_INCLUDE_DIR}/cppmicrohttpd/config.h ) + +Set ( CMAKE_POSITION_INDEPENDENT_CODE ON ) +Set ( CPPMICROHTTPD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include ) +File ( GLOB_RECURSE CPPMICROHTTPD_HEADER_FILES ${CPPMICROHTTPD_INCLUDE_DIR}/*.h ) +File ( GLOB_RECURSE CPPMICROHTTPD_INLINE_FILES ${CPPMICROHTTPD_INCLUDE_DIR}/*.inl ) +File ( GLOB_RECURSE CPPMICROHTTPD_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) +Add_Library ( cppmicrohttpd-objects + OBJECT + ${CPPMICROHTTPD_HEADER_FILES} + ${CPPMICROHTTPD_INLINE_FILES} + ${CPPMICROHTTPD_SOURCE_FILES} ) +Target_Include_Directories ( cppmicrohttpd-objects + PUBLIC + $ + $ + $ ) +Target_Link_Libraries ( cppmicrohttpd-objects + PUBLIC + cppcore::cppcore ) +If ( CPPMICROHTTPD_LOGGING_CPPLOGGING ) + Target_Link_Libraries ( cppmicrohttpd-objects + PUBLIC + cpplogging::cpplogging-shared ) +EndIf ( ) + # Static Library ################################################################################## -Add_Library ( cppmicrohttpd-static STATIC $ ) -Set_Target_Properties ( cppmicrohttpd-static - PROPERTIES - OUTPUT_NAME "${CPPMICROHTTPD_OUTPUTNAME}" - VERSION ${CPPMICROHTTPD_VERSION} ) -Target_Include_Directories ( cppmicrohttpd-static - PUBLIC - $ - $ - $ ) -Target_Link_Libraries ( cppmicrohttpd-static - PUBLIC - cppcore::cppcore - libmicrohttpd::libmicrohttpd-static ) -If ( CPPMICROHTTPD_LOGGING_CPPLOGGING ) - Target_Link_Libraries ( cppmicrohttpd-static - PUBLIC - cpplogging::cpplogging-static ) -EndIf ( ) +Add_Library ( cppmicrohttpd-static STATIC $ ) +Set_Target_Properties ( cppmicrohttpd-static + PROPERTIES + OUTPUT_NAME "${CPPMICROHTTPD_OUTPUTNAME}" + VERSION ${CPPMICROHTTPD_VERSION} ) +Target_Include_Directories ( cppmicrohttpd-static + PUBLIC + $ + $ + $ ) +Target_Link_Libraries ( cppmicrohttpd-static + PUBLIC + cppcore::cppcore + libmicrohttpd::libmicrohttpd-static ) +If ( CPPMICROHTTPD_LOGGING_CPPLOGGING ) + Target_Link_Libraries ( cppmicrohttpd-static + PUBLIC + cpplogging::cpplogging-static ) +EndIf ( ) # Shared Library ################################################################################## -Add_Library ( cppmicrohttpd-shared SHARED $ ) -Set_Target_Properties ( cppmicrohttpd-shared - PROPERTIES - OUTPUT_NAME "${CPPMICROHTTPD_OUTPUTNAME}" - VERSION ${CPPMICROHTTPD_VERSION} - SOVERSION ${CPPMICROHTTPD_VERSION_SHORT} ) -Target_Include_Directories ( cppmicrohttpd-shared - PUBLIC - $ - $ - $ ) -Target_Link_Libraries ( cppmicrohttpd-shared - PUBLIC - cppcore::cppcore - libmicrohttpd::libmicrohttpd-shared ) -If ( CPPMICROHTTPD_LOGGING_CPPLOGGING ) - Target_Link_Libraries ( cppmicrohttpd-shared - PUBLIC - cpplogging::cpplogging-shared ) -EndIf ( ) +Add_Library ( cppmicrohttpd-shared SHARED $ ) +Set_Target_Properties ( cppmicrohttpd-shared + PROPERTIES + OUTPUT_NAME "${CPPMICROHTTPD_OUTPUTNAME}" + VERSION ${CPPMICROHTTPD_VERSION} + SOVERSION ${CPPMICROHTTPD_VERSION_SHORT} ) +Target_Include_Directories ( cppmicrohttpd-shared + PUBLIC + $ + $ + $ ) +Target_Link_Libraries ( cppmicrohttpd-shared + PUBLIC + cppcore::cppcore + libmicrohttpd::libmicrohttpd-shared ) +If ( CPPMICROHTTPD_LOGGING_CPPLOGGING ) + Target_Link_Libraries ( cppmicrohttpd-shared + PUBLIC + cpplogging::cpplogging-shared ) +EndIf ( ) # Optimization #################################################################################### +# sanitizers +If ( Sanitizers_FOUND ) + Add_Sanitizers ( cppmicrohttpd-objects ) +EndIf ( ) + # pedantic -If ( HAS_PEDANTIC ) - Pedantic_Apply_Flags_Target ( cppmicrohttpd-objects ALL ) - Pedantic_Apply_Flags_Target ( cppmicrohttpd-static ALL ) - Pedantic_Apply_Flags_Target ( cppmicrohttpd-shared ALL ) -EndIf ( ) +If ( HAS_PEDANTIC ) + Pedantic_Apply_Flags_Target ( cppmicrohttpd-objects ALL ) + Pedantic_Apply_Flags_Target ( cppmicrohttpd-static ALL ) + Pedantic_Apply_Flags_Target ( cppmicrohttpd-shared ALL ) +EndIf ( ) # cotire -If ( HAS_COTIRE ) - Cotire ( cppmicrohttpd-objects ) - Cotire ( cppmicrohttpd-static ) - Cotire ( cppmicrohttpd-shared ) -EndIf ( ) +If ( HAS_COTIRE ) + Cotire ( cppmicrohttpd-objects ) + Cotire ( cppmicrohttpd-static ) + Cotire ( cppmicrohttpd-shared ) +EndIf ( ) # Install ######################################################################################### -Set ( CPPMICROHTTPD_HAS_EXPORT False PARENT_SCOPE ) +Set ( CPPMICROHTTPD_HAS_EXPORT False PARENT_SCOPE ) # Header -If ( CPPMICROHTTPD_INSTALL_HEADER ) - Install ( FILES ${CPPMICROHTTPD_INCLUDE_DIR}/cppmicrohttpd.h - DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_INCLUDE} ) - Install ( DIRECTORY ${CPPMICROHTTPD_INCLUDE_DIR}/cppmicrohttpd - DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_INCLUDE} ) - Install ( DIRECTORY ${CPPMICROHTTPD_GENERATED_INCLUDE_DIR}/cppmicrohttpd - DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_INCLUDE} ) -EndIf ( ) +If ( CPPMICROHTTPD_INSTALL_HEADER ) + Install ( FILES ${CPPMICROHTTPD_INCLUDE_DIR}/cppmicrohttpd.h + DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_INCLUDE} ) + Install ( DIRECTORY ${CPPMICROHTTPD_INCLUDE_DIR}/cppmicrohttpd + DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_INCLUDE} ) + Install ( DIRECTORY ${CPPMICROHTTPD_GENERATED_INCLUDE_DIR}/cppmicrohttpd + DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_INCLUDE} ) +EndIf ( ) # Static -If ( CPPMICROHTTPD_INSTALL_STATIC ) - Set ( CPPMICROHTTPD_HAS_EXPORT True PARENT_SCOPE ) - Install ( TARGETS cppmicrohttpd-static - EXPORT cppmicrohttpd - DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_LIB} ) -EndIf ( ) +If ( CPPMICROHTTPD_INSTALL_STATIC ) + Set ( CPPMICROHTTPD_HAS_EXPORT True PARENT_SCOPE ) + Install ( TARGETS cppmicrohttpd-static + EXPORT cppmicrohttpd + DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_LIB} ) +EndIf ( ) # Shared -If ( CPPMICROHTTPD_INSTALL_SHARED ) - Set ( CPPMICROHTTPD_HAS_EXPORT True PARENT_SCOPE ) - Install ( TARGETS cppmicrohttpd-shared - EXPORT cppmicrohttpd - DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_LIB} ) -EndIf ( ) +If ( CPPMICROHTTPD_INSTALL_SHARED ) + Set ( CPPMICROHTTPD_HAS_EXPORT True PARENT_SCOPE ) + Install ( TARGETS cppmicrohttpd-shared + EXPORT cppmicrohttpd + DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_LIB} ) +EndIf ( ) # Debug -If ( HAS_STRIP_SYMBOLS AND NOT CPPMICROHTTPD_NO_STRIP ) - Strip_Symbols ( cppmicrohttpd-shared CPPMICROHTTPD_DBG_FILE ) - If ( CPPMICROHTTPD_INSTALL_DEBUG ) - Install ( FILES ${CPPMICROHTTPD_DBG_FILE} - DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_LIB} ) - EndIf ( ) -EndIf ( ) +If ( HAS_STRIP_SYMBOLS AND NOT CPPMICROHTTPD_NO_STRIP ) + Strip_Symbols ( cppmicrohttpd-shared CPPMICROHTTPD_DBG_FILE ) + If ( CPPMICROHTTPD_INSTALL_DEBUG ) + Install ( FILES ${CPPMICROHTTPD_DBG_FILE} + DESTINATION ${CPPMICROHTTPD_INSTALL_DIR_LIB} ) + EndIf ( ) +EndIf ( ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d175483..673b616 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,68 +1,75 @@ # Initialize ###################################################################################### -Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) -Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) -Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) +Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) +Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) +Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) -Find_Package ( GTest ) -If ( NOT "${GTest_FOUND}" ) - Return ( ) -EndIf ( ) +Find_Package ( Sanitizers QUIET ) + +Find_Package ( GTest ) +If ( NOT "${GTest_FOUND}" ) + Return ( ) +EndIf ( ) # Test Helper ##################################################################################### -File ( GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/helper/*.cpp ) -Add_Library ( cppmicrohttpd-test-helper STATIC ${SOURCE_FILES} ) -Target_Include_Directories ( cppmicrohttpd-test-helper - PUBLIC - $ - $ ) -Target_Include_Directories ( cppmicrohttpd-test-helper - SYSTEM PUBLIC - ${MICROHTTPD_INCLUDE_DIRS} ) -Target_Link_Libraries ( cppmicrohttpd-test-helper - PUBLIC - cppmicrohttpd-objects - GMock::GMock ) +File ( GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/helper/*.cpp ) +Add_Library ( cppmicrohttpd-test-helper STATIC ${SOURCE_FILES} ) +Target_Include_Directories ( cppmicrohttpd-test-helper + PUBLIC + $ + $ ) +Target_Include_Directories ( cppmicrohttpd-test-helper + SYSTEM PUBLIC + ${MICROHTTPD_INCLUDE_DIRS} ) +Target_Link_Libraries ( cppmicrohttpd-test-helper + PUBLIC + cppmicrohttpd-objects + GMock::GMock ) # Test ############################################################################################ -File ( GLOB_RECURSE CPPMICROHTTPD_TEST_HEADER_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/*.h ) -File ( GLOB_RECURSE CPPMICROHTTPD_TEST_INLINE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) -File ( GLOB_RECURSE CPPMICROHTTPD_TEST_SOURCE_FILES - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/cppmicrohttpd/*.cpp ) +File ( GLOB_RECURSE CPPMICROHTTPD_TEST_HEADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/*.h ) +File ( GLOB_RECURSE CPPMICROHTTPD_TEST_INLINE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) +File ( GLOB_RECURSE CPPMICROHTTPD_TEST_SOURCE_FILES + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) -ForEach ( FILE IN LISTS CPPMICROHTTPD_TEST_SOURCE_FILES ) +ForEach ( FILE IN LISTS CPPMICROHTTPD_TEST_SOURCE_FILES ) # add test - Get_Filename_Component ( TEST_DIR ${FILE} DIRECTORY ) - Get_Filename_Component ( TEST_NAME ${FILE} NAME_WE ) - Set ( TEST_NAME "${TEST_DIR}/${TEST_NAME}" ) - String ( REPLACE "\\" "-" TEST_NAME "${TEST_NAME}" ) - String ( REPLACE "/" "-" TEST_NAME "${TEST_NAME}" ) - String ( REPLACE "_" "-" TEST_NAME "${TEST_NAME}" ) - Set ( TEST_NAME "test-${TEST_NAME}" ) - Add_Executable ( ${TEST_NAME} - EXCLUDE_FROM_ALL - ${CPPMICROHTTPD_TEST_HEADER_FILES} - ${CPPMICROHTTPD_TEST_INLINE_FILES} - ${FILE} ) - Target_Link_Libraries ( ${TEST_NAME} - PUBLIC - cppmicrohttpd-test-helper - GMock::Main ) + Get_Filename_Component ( TEST_DIR ${FILE} DIRECTORY ) + Get_Filename_Component ( TEST_NAME ${FILE} NAME_WE ) + Set ( TEST_NAME "${TEST_DIR}/${TEST_NAME}" ) + String ( REPLACE "\\" "-" TEST_NAME "${TEST_NAME}" ) + String ( REPLACE "/" "-" TEST_NAME "${TEST_NAME}" ) + String ( REPLACE "_" "-" TEST_NAME "${TEST_NAME}" ) + Set ( TEST_NAME "test-${TEST_NAME}" ) + Add_Executable ( ${TEST_NAME} + EXCLUDE_FROM_ALL + ${CPPMICROHTTPD_TEST_HEADER_FILES} + ${CPPMICROHTTPD_TEST_INLINE_FILES} + ${FILE} ) + Target_Link_Libraries ( ${TEST_NAME} + PUBLIC + cppmicrohttpd-test-helper + GMock::Main ) + + # Sanitizers + If ( Sanitizers_FOUND ) + Add_Sanitizers ( ${TEST_NAME} ) + EndIf ( ) # pedantic - If ( HAS_PEDANTIC ) - Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) - EndIf ( ) + If ( HAS_PEDANTIC ) + Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) + EndIf ( ) # test - If ( HAS_CMAKE_TESTS ) - Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} GROUP cppmicrohttpd ) - Else ( ) - Add_Test ( NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) - EndIf ( ) -EndForEach ( ) + If ( HAS_CMAKE_TESTS ) + Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} GROUP cppmicrohttpd ) + Else ( ) + Add_Test ( NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) + EndIf ( ) +EndForEach ( )