-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCMakeLists.txt
91 lines (66 loc) · 3.16 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
cmake_minimum_required( VERSION 3.3 )
project( CppUMockGen.Top )
include( CTest )
option( CI_MODE "Enable continuous integration mode" OFF )
if( WIN32 AND (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.2.0") )
message( FATAL_ERROR "MinGW must be at least version 8.2.0" )
endif()
if( NOT WIN32 AND (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0") )
message( FATAL_ERROR "GCC must be at least version 8.0.0" )
endif()
if( CMAKE_CONFIGURATION_TYPES )
option( COVERAGE "Enable coverage analysis" ON )
else()
set( DEFAULT_BUILD_TYPE "Release" )
set( BUILD_TYPES_LIST "Debug" "Release" "RelWithDebInfo" "MinSizeRel" "Coverage" )
set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS "Debug;Coverage" )
string( REPLACE ";" " " BUILD_TYPES_STRLIST "${BUILD_TYPES_LIST}" )
if( NOT CMAKE_BUILD_TYPE )
message( STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified" )
set( CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build, options are: ${BUILD_TYPES_STRLIST}" FORCE )
else()
set( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Choose the type of build, options are: ${BUILD_TYPES_STRLIST}" FORCE )
endif()
if( NOT CMAKE_BUILD_TYPE IN_LIST BUILD_TYPES_LIST )
message( FATAL_ERROR "Unknown build type '${CMAKE_BUILD_TYPE}', please choose a supported build type: ${BUILD_TYPES_STRLIST}" )
endif()
set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${BUILD_TYPES_LIST} )
if( CMAKE_BUILD_TYPE STREQUAL "Coverage" )
set( COVERAGE ON )
else()
set( COVERAGE OFF )
endif()
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG" )
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG" )
set( CMAKE_RC_FLAGS_DEBUG "${CMAKE_RC_FLAGS_DEBUG} -D_DEBUG" )
set( CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} )
set( CMAKE_C_FLAGS_COVERAGE ${CMAKE_C_FLAGS_DEBUG} )
set( CMAKE_RC_FLAGS_COVERAGE ${CMAKE_RC_FLAGS_DEBUG} )
set( CMAKE_EXE_LINKER_FLAGS_COVERAGE ${CMAKE_EXE_LINKER_FLAGS_DEBUG} )
endif()
option( COVERAGE_VERBOSE "Coverage analysis is performed in verbose mode" OFF )
if( WIN32 AND NOT MSVC )
add_definitions( -DWIN32 )
endif()
add_custom_target( build )
add_subdirectory( app )
add_subdirectory( test )
set( CONFIG_MSG "
--------------------------------------------------------------------------
CONFIGURATION
--------------------------------------------------------------------------
Build Options:" )
if( DEFINED CMAKE_BUILD_TYPE )
set( CONFIG_MSG "${CONFIG_MSG}
CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}" )
endif()
set( CONFIG_MSG "${CONFIG_MSG}
CI_MODE: ${CI_MODE}
Configured Features:
BUILD_TESTING: ${BUILD_TESTING}
COVERAGE: ${COVERAGE}
COVERAGE_VERBOSE: ${COVERAGE_VERBOSE}
CHECK_COMPILATION: ${CHECK_COMPILATION}
--------------------------------------------------------------------------
" )
message( STATUS ${CONFIG_MSG} )