diff --git a/CMakeLists.txt b/CMakeLists.txt index 99708d6..b6906e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,19 +20,25 @@ EndIf ( ) # Project ######################################################################################### +Include ( CTest ) +Include ( GNUInstallDirs ) Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-options.cmake ) +Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-const.cmake ) Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppcore-var.cmake ) -Project ( cppcore - DESCRIPTION "A simple library" +Project ( ${CPPCORE_PROJECT_NAME} + DESCRIPTION "${CPPCORE_PROJECT_DESCRIPTION}" VERSION "${CPPCORE_VERSION}" ) -Include ( CTest ) -Include ( GNUInstallDirs ) # Subdirectories Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) # Install +If ( NOT CPPCORE_HAS_EXPORT + OR NOT CPPCORE_INSTALL_PACKAGE ) + Return ( ) +EndIf ( ) + Include ( CMakePackageConfigHelpers ) Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/cppcore-config-version.cmake" VERSION ${CPPCORE_VERSION} diff --git a/cmake/cppcore-const.cmake b/cmake/cppcore-const.cmake new file mode 100644 index 0000000..58a5d14 --- /dev/null +++ b/cmake/cppcore-const.cmake @@ -0,0 +1,28 @@ +# This file contains constant variables that are fixed to this project + +# Version +Set ( CPPCORE_VERSION_MAJOR 1 ) +Set ( CPPCORE_VERSION_MINOR 0 ) +Set ( CPPCORE_VERSION_PATCH 0 ) +Set ( CPPCORE_VERSION_BUILD 0 ) +Set ( CPPCORE_VERSION_HASH "" ) +Set ( CPPCORE_VERSION_BEHIND 0 ) +Set ( CPPCORE_VERSION_DIRTY 0 ) + +# Names +Set ( CPPCORE_PROJECT_NAME "cppcore" ) +Set ( CPPCORE_PROJECT_DESCRIPTION "C++ core library" ) + +# Include generated variables for further usage +Include ( ${CMAKE_CURRENT_LIST_DIR}/cppcore-var.cmake ) + +# Install directories +Set ( CPPCORE_INSTALL_DIR_INCLUDE "${CMAKE_INSTALL_INCLUDEDIR}/${CPPCORE_NAME}" ) +Set ( CPPCORE_INSTALL_DIR_LIB "${CMAKE_INSTALL_LIBDIR}" ) +Set ( CPPCORE_INSTALL_DIR_SHARE "${CMAKE_INSTALL_DATAROOTDIR}/${CPPCORE_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/cppcore-options.cmake b/cmake/cppcore-options.cmake index f86a19d..5e3cdd0 100644 --- a/cmake/cppcore-options.cmake +++ b/cmake/cppcore-options.cmake @@ -1,6 +1,11 @@ +# This file contains options that can be passed to the cmake command + Option ( CPPCORE_INSTALL_HEADER "Install headers of cppcore." ON ) +Option ( CPPCORE_INSTALL_PACKAGE + "Install the cmake package of cppcore." + ON ) Option ( CPPCORE_USE_GIT_VERSION "Read the git tags to get the version of cppcore" ON ) diff --git a/cmake/cppcore-var.cmake b/cmake/cppcore-var.cmake index 98af065..ed14dc6 100644 --- a/cmake/cppcore-var.cmake +++ b/cmake/cppcore-var.cmake @@ -1,11 +1,4 @@ -# Version -Set ( CPPCORE_VERSION_MAJOR 1 ) -Set ( CPPCORE_VERSION_MINOR 0 ) -Set ( CPPCORE_VERSION_PATCH 0 ) -Set ( CPPCORE_VERSION_BUILD 0 ) -Set ( CPPCORE_VERSION_HASH "" ) -Set ( CPPCORE_VERSION_BEHIND 0 ) -Set ( CPPCORE_VERSION_DIRTY 0 ) +# This file contains generated variables that are needed for the project # Git Version If ( CPPCORE_USE_GIT_VERSION ) @@ -26,19 +19,8 @@ EndIf ( ) Set ( CPPCORE_VERSION_SHORT "${CPPCORE_VERSION_MAJOR}.${CPPCORE_VERSION_MINOR}" ) Set ( CPPCORE_VERSION "${CPPCORE_VERSION_SHORT}.${CPPCORE_VERSION_PATCH}.${CPPCORE_VERSION_BUILD}" ) Set ( CPPCORE_VERSION_COMPLETE "${CPPCORE_VERSION}" ) -Set ( CPPCORE_NAME "cppcore-${CPPCORE_VERSION_SHORT}" ) -Set ( CPPCORE_OUTPUTNAME "cppcore" ) +Set ( CPPCORE_NAME "${CPPCORE_PROJECT_NAME}-${CPPCORE_VERSION_SHORT}" ) +Set ( CPPCORE_OUTPUTNAME "${CPPCORE_PROJECT_NAME}" ) If ( CPPCORE_VERSION_BEHIND ) Set ( CPPCORE_VERSION_COMPLETE "${CPPCORE_VERSION_COMPLETE}+${CPPCORE_VERSION_BEHIND}" ) EndIf ( ) - -# Install directories -Set ( CPPCORE_INSTALL_DIR_INCLUDE "include/${CPPCORE_NAME}" ) -Set ( CPPCORE_INSTALL_DIR_LIB "lib" ) -Set ( CPPCORE_INSTALL_DIR_SHARE "share/${CPPCORE_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 4953cd4..ebbae4f 160000 --- a/cmake/modules +++ b/cmake/modules @@ -1 +1 @@ -Subproject commit 4953cd4cc849afdfa02a6057b5a2011fb62e91a6 +Subproject commit ebbae4fbb42d671331b4c6e9d1d142f41dcacc1b diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0a68ef3..d2d6d61 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,13 +15,16 @@ Target_Include_Directories ( cppcore # Install ######################################################################################### +Set ( CPPCORE_HAS_EXPORT False PARENT_SCOPE ) + # Header If ( CPPCORE_INSTALL_HEADER ) + Set ( CPPCORE_HAS_EXPORT True PARENT_SCOPE ) Install ( FILES ${CPPCORE_INCLUDE_DIR}/cppcore.h - DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) + DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) Install ( DIRECTORY ${CPPCORE_INCLUDE_DIR}/cppcore - DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) + DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) Install ( TARGETS cppcore - EXPORT cppcore - DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) + EXPORT cppcore + DESTINATION ${CPPCORE_INSTALL_DIR_INCLUDE} ) EndIf ( ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 36702e5..8eebbcf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -43,11 +43,6 @@ ForEach ( FILE IN LISTS CPPCORE_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} )