-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.cmake.in
116 lines (97 loc) · 3.74 KB
/
config.cmake.in
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
##################################################################
#
# TPF - Two Phase Flow
#
# Header-only library to fascilitate the development of
# post-processing tools for multiphase flow simulation data,
# integrated in visualization tools, such as ParaView and
# MegaMol.
#
# Copyright 2016-2019
# Visualization Research Center, University of Stuttgart, Germany
#
# Author(s): Alexander Straub
# Moritz Heinemann
#
##################################################################
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
# Let user select options
option(tpf_option_debug "Write debug output, fascilitating the debugging of code" OFF)
option(tpf_option_detailed "Write detailed output to console, file or within other tools" OFF)
option(tpf_option_performance "Measure and log performance where supported" OFF)
option(tpf_option_range_checks "Perform range checks to increase security (increases execution time)" OFF)
option(tpf_option_sanity_checks "Perform sanity checks to increase security (recommended)" ON)
option(tpf_option_use_openmp "Use OpenMP for parallelization" ON)
option(tpf_option_use_mpi "Use MPI for parallelization" OFF)
option(tpf_option_use_mpi_io "Use MPI-IO for parallelized read-in" OFF)
if(tpf_option_debug)
add_definitions(-D__tpf_debug)
endif()
if(tpf_option_detailed)
add_definitions(-D__tpf_detailed)
endif()
if(tpf_option_performance)
add_definitions(-D__tpf_performance)
endif()
if(tpf_option_range_checks)
add_definitions(-D__tpf_range_checks)
endif()
if(tpf_option_sanity_checks)
add_definitions(-D__tpf_sanity_checks)
endif()
# Check for being on a supercomputer
if(ENV{PLATFORM})
string(COMPARE EQUAL $ENV{PLATFORM} "CRAY" tpf_option_supercomputer)
endif()
if(NOT tpf_option_supercomputer)
option(tpf_option_supercomputer "Is this compiled on a supercomputer?" OFF)
endif()
# Find dependencies
set(optional_includes)
set(optional_compile_options)
set(optional_compile_definitions)
set(optional_link_libraries)
# Find Eigen
find_package(Eigen3 REQUIRED NO_MODULE)
if(NOT TARGET Eigen3::Eigen)
message(FATAL_ERROR "Target for eigen3 not found")
endif()
# Find CGAL
find_package(CGAL REQUIRED)
if(NOT TARGET CGAL::CGAL)
message(FATAL_ERROR "Target for CGAL not found")
endif()
if (TARGET CGAL)
set_target_properties(CGAL PROPERTIES MAP_IMPORTED_CONFIG_MINSIZEREL Release)
set_target_properties(CGAL PROPERTIES MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release)
endif()
# Find OpenMP
if(tpf_option_use_openmp OR tpf_option_supercomputer)
find_package(OpenMP REQUIRED)
set(optional_link_libraries ${optional_link_libraries} OpenMP::OpenMP_CXX)
endif()
# Find MPI
if(tpf_option_use_mpi AND NOT tpf_option_supercomputer)
find_package(MPI REQUIRED)
set(optional_link_libraries ${optional_link_libraries} ${MPI_LIBRARIES})
set(optional_includes ${optional_includes} ${MPI_CXX_INCLUDE_PATH})
endif()
if(tpf_option_use_mpi)
set(optional_compile_definitions ${optional_compile_definitions} __tpf_use_mpi)
endif()
if(tpf_option_use_mpi AND tpf_option_use_mpi_io)
set(optional_compile_definitions ${optional_compile_definitions} __tpf_use_mpiio)
endif()
# Create imported target
if(NOT TARGET tpf)
get_filename_component(tpf_config_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${tpf_config_dir}/tpf-export.cmake)
# Add properties of imported target based on dependencies
get_target_property(tpf_includes tpf INTERFACE_INCLUDE_DIRECTORIES)
set_target_properties(tpf PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${tpf_includes};${CGAL_INCLUDE_DIRS};${CGAL_3RD_PARTY_INCLUDE_DIRS};${optional_includes}"
INTERFACE_COMPILE_OPTIONS "${optional_compile_options}"
INTERFACE_COMPILE_DEFINITIONS "${optional_compile_definitions}"
INTERFACE_LINK_LIBRARIES "Eigen3::Eigen;CGAL::CGAL;${optional_link_libraries}"
)
endif()