-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
109 lines (86 loc) · 3.83 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# This file is part of PTN Engine
#
# Copyright (c) 2017 Eduardo Valgôde
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required (VERSION 3.8)
# The version number.
set (PTN_ENGINE_VERSION_MAJOR x)
set (PTN_ENGINE_VERSION_MINOR x)
set (PTN_ENGINE_VERSION_PATCH x)
project (PTN_Engine)
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
set(CMAKE_DEBUG_POSTFIX _d)
set(CMAKE_STATIC_LIBRARY_PREFIX lib)
set(EXECUTABLE_STATIC_POSTFIX _s)
set (CMAKE_CXX_STANDARD 20)
if(CMAKE_COMPILER_IS_GNUCXX)
#set(MULTITHREADED_BUILD 8 CACHE STRING "How many threads are used to build the project")
#set(CMAKE_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM} -j${MULTITHREADED_BUILD}")
set(GCC_PTHREAD_COMPILE_FLAGS "-pthread")
set(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage -fprofile-update=atomic")
set(GCC_COVERAGE_LINK_FLAGS "-lgcov")
set(GCC_PTHREAD_LINK_FLAGS "-lpthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_PTHREAD_COMPILE_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_PTHREAD_LINK_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake)
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251 /MP")
endif(MSVC)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/)
set(INCLUDE_DIR ${PROJECT_SOURCE_DIR}/PTN_Engine/include)
option(BUILD_IMPORT_EXPORT "Builds importer and exporters")
option(BUILD_TESTS "Builds the unit tests" OFF)
option(BUILD_EXAMPLES "Builds the examples" OFF)
#Projects
add_subdirectory(PTN_Engine)
if(BUILD_TESTS)
option(INSTALL_TESTS "Install tests" OFF)
enable_testing()
###
# from https://crascit.com/2015/07/25/cmake-gtest/
# Download and unpack googletest at configure time
configure_file(cmake/gtest.CMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download" )
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download" )
# Prevent GoogleTest from overriding our compiler/linker options
# when building with Visual Studio
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Add googletest directly to our build. This adds
# the following targets: gtest, gtest_main, gmock
# and gmock_main
add_subdirectory("${CMAKE_BINARY_DIR}/googletest-src"
"${CMAKE_BINARY_DIR}/googletest-build")
# The gtest/gmock targets carry header search path
# dependencies automatically when using CMake 2.8.11 or
# later. Otherwise we have to add them here ourselves.
if(CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories("${gtest_SOURCE_DIR}/include"
"${gmock_SOURCE_DIR}/include")
endif()
###
add_subdirectory(Tests/WhiteBoxTests)
add_subdirectory(Tests/BlackBoxTests)
endif(BUILD_TESTS)
if(BUILD_EXAMPLES)
option(INSTALL_EXAMPLES "Install examples" OFF)
add_subdirectory(Examples)
endif(BUILD_EXAMPLES)
option(INSTALL_PTN_ENGINE "Enable installation of PTN Engine. (Projects embedding PTN Engine may want to turn this OFF.)" ON )
include(CMakeDependentOption)
include(GNUInstallDirs)