-
Notifications
You must be signed in to change notification settings - Fork 41
/
CMakeLists.txt
138 lines (99 loc) · 4.2 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Copyright 2012-2024 Ronald Römer
#
# 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.12 FATAL_ERROR)
project(vtkbool
VERSION 3.0
HOMEPAGE_URL https://github.com/zippy84/vtkbool)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
if(MSVC)
add_compile_options(/EHsc)
add_compile_definitions(_SCL_SECURE_NO_WARNINGS)
add_compile_definitions(_USE_MATH_DEFINES)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
else()
add_compile_options(-Wall -Wextra -fPIC -Wconversion)
endif()
option(VTKBOOL_PARAVIEW "" OFF)
option(VTKBOOL_DEBUG "" OFF)
option(VTKBOOL_COVERAGE "" OFF)
mark_as_advanced(VTKBOOL_DEBUG)
mark_as_advanced(VTKBOOL_COVERAGE)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND VTKBOOL_COVERAGE)
set(CMAKE_C_FLAGS_PROFILE --coverage)
set(CMAKE_CXX_FLAGS_PROFILE --coverage)
add_link_options("--coverage")
endif()
include_directories(".")
if(VTKBOOL_DEBUG)
add_definitions(-DDEBUG)
endif()
if(VTKBOOL_PARAVIEW)
find_package(ParaView REQUIRED)
if(ParaView_FOUND)
paraview_plugin_scan(
PLUGIN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/paraview/paraview.plugin"
PROVIDES_PLUGINS plugins
ENABLE_BY_DEFAULT ON)
set(BUILD_SHARED_LIBS ON)
include(GNUInstallDirs)
paraview_plugin_build(
PLUGINS ${plugins})
endif()
else()
find_package(VTK REQUIRED COMPONENTS FiltersSources IOLegacy FiltersExtraction FiltersGeometry FiltersModeling FiltersFlowPaths OPTIONAL_COMPONENTS WrappingPythonCore NO_MODULE)
if(VTK_FOUND)
if(VTK_VERSION VERSION_LESS "9.0.0")
message(FATAL_ERROR "vtkbool requires VTK 9.0.0 or newer.")
endif()
vtk_module_scan(
MODULE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/module/vtk.module"
REQUEST_MODULES vtkBool
PROVIDES_MODULES modules
ENABLE_TESTS ON)
set(BUILD_SHARED_LIBS ON)
include(GNUInstallDirs)
vtk_module_build(MODULES ${modules})
if (VTK_WrappingPythonCore_FOUND)
vtk_module_wrap_python(
MODULES ${modules}
PYTHON_PACKAGE "vtkbool"
BUILD_STATIC OFF
INSTALL_HEADERS OFF)
include(CTest)
vtk_module_python_default_destination(python_default_destination)
add_test(NAME "import_vtkbool"
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/testing/test_python.py)
set_property(TEST "import_vtkbool" APPEND PROPERTY ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/${python_default_destination}/vtkbool")
add_test(NAME "test_filter"
COMMAND ${Python3_EXECUTABLE} -m pytest
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/testing)
set_property(TEST "test_filter" APPEND PROPERTY ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/${python_default_destination}/vtkbool")
add_executable(test_merger testing/test_merger.cxx)
target_link_libraries(test_merger PRIVATE vtkBool ${VTK_LIBRARIES})
vtk_module_autoinit(
TARGETS test_merger
MODULES ${VTK_LIBRARIES}
)
add_test(NAME "test_merger"
COMMAND test_merger
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/testing)
add_test(NAME "generate_frieze"
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/testing/generate_frieze.py
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/testing)
set_property(TEST "generate_frieze" APPEND PROPERTY ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/${python_default_destination}/vtkbool")
endif()
endif()
endif()