Browse Source

* refactored cmake files

master
bergmann 5 years ago
parent
commit
6f2e62ba87
3 changed files with 25 additions and 30 deletions
  1. +2
    -10
      CMakeLists.txt
  2. +9
    -0
      src/CMakeLists.txt
  3. +14
    -20
      test/CMakeLists.txt

+ 2
- 10
CMakeLists.txt View File

@@ -1,19 +1,11 @@
# Initialize CMake ################################################################################

CMake_Minimum_Required ( VERSION 3.5.1 FATAL_ERROR )

If ( NOT CMAKE_BUILD_TYPE )
Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE )
EndIf ( NOT CMAKE_BUILD_TYPE )

CMake_Minimum_Required ( VERSION 3.5.1 FATAL_ERROR )
Set ( CMAKE_CXX_STANDARD 17 )
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../../inc/cmake/")
Include ( GlobalCompilerFlags OPTIONAL )
Include ( cotire OPTIONAL )

# Tests ###########################################################################################

Include ( CTest )
Enable_Testing ( )

# Projects ########################################################################################



+ 9
- 0
src/CMakeLists.txt View File

@@ -1,3 +1,12 @@
# Initialize ######################################################################################

Include ( cotire OPTIONAL )
Include ( pedantic OPTIONAL )

Set ( CMAKE_CXX_STANDARD 17 )
Set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PEDANTIC_C_FLAGS}" )
Set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PEDANTIC_CXX_FLAGS}" )

# Project: cpputils ###############################################################################

Project ( cpputils VERSION 1.0.0.0 LANGUAGES CXX )


+ 14
- 20
test/CMakeLists.txt View File

@@ -1,11 +1,18 @@
# Initialize ######################################################################################

Include ( cotire OPTIONAL )
Include ( pedantic OPTIONAL )
Include ( cmake_tests OPTIONAL )

Set ( CMAKE_CXX_STANDARD 17 )
Set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PEDANTIC_C_FLAGS}" )
Set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PEDANTIC_CXX_FLAGS}" )

# Project: test_cpputils ##########################################################################

Project ( test_cpputils )
File ( GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp )
Add_Executable ( test_cpputils EXCLUDE_FROM_ALL ${SOURCE_FILES} )
If ( __COTIRE_INCLUDED )
Cotire ( test_cpputils )
EndIf ( )
Target_Link_Libraries (
test_cpputils
cpputils
@@ -14,22 +21,9 @@ Target_Link_Libraries (
gmock_main
pthread
)

# Build Tests #####################################################################################

If ( NOT TARGET build_tests)
Add_Custom_Target ( build_tests )
If ( __COTIRE_INCLUDED )
Cotire ( test_cpputils )
EndIf ( )
Add_Dependencies ( build_tests test_cpputils )

# Run Tests #######################################################################################

If ( NOT TARGET tests)
Add_Custom_Target ( tests )
If ( __CMAKE_TESTS_INCLUDED )
Add_CMake_Test ( cpputils test_cpputils )
EndIf ( )
Add_Custom_Target ( run_test_cpputils DEPENDS test_cpputils COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_cpputils )
Add_Dependencies ( tests run_test_cpputils )

# CTest ###########################################################################################

Add_Test ( NAME cpputils COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_cpputils )

Loading…
Cancel
Save