-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCMakeLists.txt
180 lines (141 loc) · 6.59 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(
ViennaPS
LANGUAGES CXX C
VERSION 3.2.0)
# --------------------------------------------------------------------------------------------------------
# Library switches
# --------------------------------------------------------------------------------------------------------
option(VIENNAPS_BUILD_EXAMPLES "Build examples" OFF)
option(VIENNAPS_BUILD_TESTS "Build tests" OFF)
option(VIENNAPS_BUILD_PYTHON "Build python bindings" OFF)
option(VIENNAPS_PACKAGE_PYTHON "Build python bindings with intent to publish wheel" OFF)
option(VIENNAPS_BUILD_APPLICATION "Build application" OFF)
option(VIENNAPS_USE_DOUBLE "Use double precision floating point numbers in application" OFF)
# --------------------------------------------------------------------------------------------------------
# Library options
# --------------------------------------------------------------------------------------------------------
set(VIENNAPS_LOOKUP_DIRS
""
CACHE STRING "Directories to account for when searching installed dependencies")
list(APPEND CMAKE_PREFIX_PATH ${VIENNAPS_LOOKUP_DIRS})
# --------------------------------------------------------------------------------------------------------
# Global CMake Configuration
# └ We depend on the vtk python package for our python build and re-use
# their existing vtk libraries, which are not versioned. Because we (possibly) pull in VTK ourselves
# during build time though, we disable the soname versioning so that we can easily set the rpath to
# link against the vtk-python libs
# --------------------------------------------------------------------------------------------------------
if(VIENNAPS_PACKAGE_PYTHON)
message(
STATUS
"[ViennaPS] Using remote packages due to 'VIENNAPS_PACKAGE_PYTHON', the build will take a long time!"
)
# CIBUILDWHEEL is absolutely cursed and won't work when this is turned on.
# I don't know why...
if(NOT VIENNAPS_IS_CI)
set(CPM_DOWNLOAD_ALL ON)
endif()
set(VIENNAPS_BUILD_PYTHON ON)
endif()
if(VIENNAPS_BUILD_PYTHON)
set(CMAKE_PLATFORM_NO_VERSIONED_SONAME ON)
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -openmp:llvm /bigobj")
endif()
# --------------------------------------------------------------------------------------------------------
# Setup Library
# --------------------------------------------------------------------------------------------------------
add_library(${PROJECT_NAME} INTERFACE)
add_library(ViennaTools::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
set_target_properties(
${PROJECT_NAME}
PROPERTIES CXX_STANDARD 17
CXX_EXTENSIONS OFF
CXX_STANDARD_REQUIRED ON
WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(MSVC)
# https://learn.microsoft.com/cpp/c-runtime-library/math-constants TODO: In case C++20 is adpoted
# any time soon: https://cppreference.com/w/cpp/numeric/constants
target_compile_definitions(${PROJECT_NAME} INTERFACE _USE_MATH_DEFINES=1)
endif()
# --------------------------------------------------------------------------------------------------------
# Include directories
# --------------------------------------------------------------------------------------------------------
target_include_directories(
${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/viennaps>
$<INSTALL_INTERFACE:include/viennaps-${PROJECT_VERSION}>)
# --------------------------------------------------------------------------------------------------------
# Setup Dependencies
# --------------------------------------------------------------------------------------------------------
include("cmake/cpm.cmake")
CPMAddPackage(
NAME ViennaCore
VERSION 1.1.0
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCore"
OPTIONS "VIENNACORE_FORMAT_EXCLUDE docs/"
EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON})
CPMAddPackage(
NAME PackageProject
VERSION 1.11.2
GIT_REPOSITORY "https://github.com/TheLartians/PackageProject.cmake")
CPMFindPackage(
NAME ViennaRay
VERSION 3.1.0
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaRay"
EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON})
CPMFindPackage(
NAME ViennaLS
VERSION 4.1.0
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaLS"
EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON})
CPMFindPackage(
NAME ViennaCS
VERSION 1.0.0
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCS"
EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON})
target_link_libraries(${PROJECT_NAME} INTERFACE ViennaTools::ViennaCore ViennaTools::ViennaLS
ViennaTools::ViennaRay ViennaTools::ViennaCS)
# --------------------------------------------------------------------------------------------------------
# Setup Application
# --------------------------------------------------------------------------------------------------------
if(VIENNAPS_BUILD_APPLICATION)
message(STATUS "[ViennaPS] Building Application")
add_subdirectory(app)
endif()
# --------------------------------------------------------------------------------------------------------
# Setup Examples
# --------------------------------------------------------------------------------------------------------
if(VIENNAPS_BUILD_EXAMPLES)
message(STATUS "[ViennaPS] Building Examples")
add_subdirectory(examples)
endif()
# --------------------------------------------------------------------------------------------------------
# Setup Tests
# --------------------------------------------------------------------------------------------------------
if(VIENNAPS_BUILD_TESTS)
message(STATUS "[ViennaPS] Building Tests")
enable_testing()
add_subdirectory(tests)
endif()
# --------------------------------------------------------------------------------------------------------
# Setup Python Bindings
# --------------------------------------------------------------------------------------------------------
if(VIENNAPS_BUILD_PYTHON)
message(STATUS "[ViennaPS] Building Python Bindings")
add_subdirectory(python)
return()
endif()
# --------------------------------------------------------------------------------------------------------
# Install Target
# --------------------------------------------------------------------------------------------------------
packageProject(
NAME ${PROJECT_NAME} NAMESPACE ViennaTools
VERSION ${PROJECT_VERSION}
BINARY_DIR ${PROJECT_BINARY_DIR}
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include/viennaps
INCLUDE_DESTINATION include/viennaps-${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
DEPENDENCIES "ViennaCore;ViennaLS;ViennaRay;ViennaCS")