-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
113 lines (101 loc) · 3.24 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
110
111
112
113
cmake_minimum_required(VERSION 3.12)
cmake_policy(SET CMP0074 NEW)
project(vtkdiff)
# C++ standard setup
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# --- CPM ---
include(cmake/CPM.cmake)
CPMFindPackage(
NAME tclap
GITHUB_REPOSITORY ufz/tclap
VERSION 1.2.4
GIT_TAG 098dd0fe07a31618f3c2a9f8727bb01c8c5d61e2
DOWNLOAD_ONLY YES
)
if(tclap_ADDED AND NOT TARGET tclap)
add_library(tclap INTERFACE IMPORTED)
target_include_directories(
tclap SYSTEM INTERFACE ${tclap_SOURCE_DIR}/include
)
endif()
set(VTK_COMPONENTS IOXML)
find_package(VTK 9 QUIET COMPONENTS ${VTK_COMPONENTS})
if(NOT VTK_FOUND)
list(
APPEND
VTK_OPTIONS
"BUILD_SHARED_LIBS OFF"
"BUILD_TESTING OFF"
"VTK_BUILD_EXAMPLES OFF"
"VTK_BUILD_TESTING OFF"
"VTK_ENABLE_WRAPPING OFF"
"VTK_GROUP_ENABLE_Rendering DONT_WANT"
"VTK_GROUP_ENABLE_StandAlone DONT_WANT"
"VTK_USE_64BIT_IDS ON"
"VTK_MODULE_ENABLE_VTK_IOXML YES"
)
CPMAddPackage(
NAME VTK
GITHUB_REPOSITORY kitware/vtk
VERSION 9.1.0
OPTIONS ${VTK_OPTIONS}
EXCLUDE_FROM_ALL YES GIT_SUBMODULES "" # Disable submodules
)
endif()
# --- CPM end ---
# Coverage (enabled by Debug-config)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND ${PROJECT_SOURCE_DIR} STREQUAL
${CMAKE_SOURCE_DIR}
)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_CXX_FLAGS_DEBUG "-g -Og --coverage")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -fprofile-abs-path")
endif()
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "--coverage")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "--coverage")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "--coverage")
message(STATUS "Setting coverage flags!")
message(
STATUS
"Run executables and the run:\n gcovr -r ${PROJECT_SOURCE_DIR}"
)
else()
message(FATAL_ERROR "OGS_COVERAGE requires clang or gcc compiler!")
endif()
endif()
add_executable(vtkdiff vtkdiff.cpp)
target_link_libraries(vtkdiff tclap VTK::IOXML)
# Set compiler helper variables
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
set(COMPILER_IS_CLANG TRUE)
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(COMPILER_IS_GCC TRUE)
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
set(COMPILER_IS_INTEL TRUE)
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
set(COMPILER_IS_MSVC TRUE)
endif() # CMAKE_CXX_COMPILER_ID
if(COMPILER_IS_GCC OR COMPILER_IS_CLANG)
target_compile_options(vtkdiff PUBLIC -Wall -Wextra)
endif()
if(COMPILER_IS_INTEL)
target_compile_options(vtkdiff PUBLIC -xHOST -no-prec-div)
endif()
if(COMPILER_IS_MSVC)
target_compile_options(
vtkdiff
PUBLIC -D_CRT_SECURE_NO_WARNINGS
-D_CRT_NONSTDC_NO_WARNINGS
-D_CRT_XNONSTDC_NO_WARNINGS
-D__restrict__=__restrict # this fixes #5
-DNOMINMAX # This fixes compile errors with
# std::numeric_limits<T>::min() / max()
/W3
/wd4290
/wd4267
/wd4996
)
endif()