-
Notifications
You must be signed in to change notification settings - Fork 32
/
CMakeLists.txt
187 lines (150 loc) · 6 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
181
182
183
184
185
186
187
cmake_minimum_required(VERSION 3.3)
project(SMESH VERSION 9.8.0.2 LANGUAGES C CXX)
# --------------------------------------------------------------------------- #
# OPTIONS
# --------------------------------------------------------------------------- #
option(ENABLE_NETGEN "Enable Netgen" ON)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE PATH "Installation directory")
set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries")
# --------------------------------------------------------------------------- #
# SETTINGS
# --------------------------------------------------------------------------- #
set(SMESH_VERSION_MAJOR 9)
set(SMESH_VERSION_MINOR 8)
set(SMESH_VERSION_PATCH 0)
set(SMESH_VERSION_TWEAK 2)
# Build shared libraries
set(BUILD_SHARED_LIBS TRUE)
# Force C++ 17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# To get std::set_unexpected for Clang
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS)
endif()
# Warning and errors
if(MSVC)
add_compile_options(/W1)
add_compile_options(/wd4715 /wd4091 /wd4503 /wd4805 /wd4267 /wd4477 /wd4138 /wd4273 /wd4311 /wd4806)
else()
add_compile_options(-Wno-deprecated)
endif()
# Definitions
if(UNIX)
# Same settings are used for both MacOSX and Unix/Linux
add_definitions(-DHAVE_LIMITS_H -DCSFDB -DLIN -DOCC_CONVERT_SIGNALS)
else(UNIX)
if(WIN32)
# Define NOMINMAX to avoid conflice with Windows.h max and min
add_definitions(-DNOMINMAX)
if(MSVC)
add_definitions(-DWNT -DWIN32 -D_WINDOWS -DCSFDB -DUSE_CLOCK -DMSDOS -DNO_ONEXIT -DNO_My_ctype -DNO_ISATTY -DNO_FPINIT)
else(MSVC)
add_definitions(-DWNT -DWIN32 -D_WINDOWS -DCSFDB)
endif(MSVC)
else(WIN32)
message(FATAL_ERROR "Unknown platform")
endif(WIN32)
endif(UNIX)
if(CMAKE_SIZEOF_VOID_P STREQUAL 8)
add_definitions(-D_OCC64)
add_definitions(-DSALOME_USE_64BIT_IDS)
endif(CMAKE_SIZEOF_VOID_P STREQUAL 8)
# --------------------------------------------------------------------------- #
# OpenCASCADE
# --------------------------------------------------------------------------- #
message(STATUS "Searching for OpenCASCADE...")
find_package(OpenCASCADE REQUIRED)
include_directories(${OpenCASCADE_INCLUDE_DIR})
link_directories(${OpenCASCADE_LIBRARY_DIR})
# --------------------------------------------------------------------------- #
# VTK
# --------------------------------------------------------------------------- #
message(STATUS "Searching for VTK...")
find_package(VTK REQUIRED COMPONENTS CommonCore CommonDataModel FiltersVerdict)
# --------------------------------------------------------------------------- #
# BOOST
# --------------------------------------------------------------------------- #
message(STATUS "Searching for Boost...")
find_package(Boost REQUIRED COMPONENTS filesystem thread serialization regex)
if (MSVC)
# find the shared boost libs
add_definitions(-DBOOST_ALL_DYN_LINK)
# set postfix for debug libs
if(NOT CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX d)
endif()
endif()
# --------------------------------------------------------------------------- #
# PTHREAD
# --------------------------------------------------------------------------- #
if(UNIX)
find_package(Threads REQUIRED)
else(UNIX)
set(PTHREAD_INCLUDE_DIRS "" CACHE PATH "pthread include directory.")
if(NOT EXISTS ${PTHREAD_INCLUDE_DIRS})
message(FATAL_ERROR "pthread include directory is required.")
endif()
include_directories(${PTHREAD_INCLUDE_DIRS})
set(PTHREAD_LIB_DIRS "" CACHE PATH "pthread library directory.")
if(NOT EXISTS ${PTHREAD_LIB_DIRS})
message(FATAL_ERROR "pthread library directory is required.")
endif()
link_directories(${PTHREAD_LIB_DIRS})
endif(UNIX)
# --------------------------------------------------------------------------- #
# SMESH
# --------------------------------------------------------------------------- #
# Kernel
set(Kernel_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/Kernel/src)
# Geom
set(Geom_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/Geom/src)
# Netgen
if(ENABLE_NETGEN)
set(NETGEN_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/Netgen)
endif(ENABLE_NETGEN)
# Add subdirectories
add_subdirectory(src)
# Retrieve variables
if(ENABLE_NETGEN)
get_directory_property(Netgen_LIBRARIES
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/Netgen
DEFINITION Netgen_LIBRARIES
)
else()
set(Netgen_LIBRARIES)
message(STATUS "Netgen is not enabled and will not be available in the resulting library.")
endif(ENABLE_NETGEN)
get_directory_property(Kernel_LIBRARIES
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/Kernel
DEFINITION Kernel_LIBRARIES
)
get_directory_property(Geom_LIBRARIES
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/Geom
DEFINITION Geom_LIBRARIES
)
get_directory_property(SMESH_LIBRARIES
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/SMESH
DEFINITION SMESH_LIBRARIES
)
# --------------------------------------------------------------------------- #
# Install
# --------------------------------------------------------------------------- #
install(TARGETS ${Netgen_LIBRARIES} ${Kernel_LIBRARIES} ${Geom_LIBRARIES} ${SMESH_LIBRARIES} EXPORT SMESH-targets
ARCHIVE DESTINATION "lib"
RUNTIME DESTINATION "bin"
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(EXPORT SMESH-targets DESTINATION cmake)
# --------------------------------------------------------------------------- #
# Configuration files
# --------------------------------------------------------------------------- #
include(CMakePackageConfigHelpers)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/SMESHConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/SMESHConfig.cmake @ONLY)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/SMESHConfigVersion.cmake
VERSION ${SMESH_VERSION_MAJOR}.${SMESH_VERSION_MINOR}.${SMESH_VERSION_PATCH}
COMPATIBILITY SameMinorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/SMESHConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/SMESHConfigVersion.cmake
DESTINATION cmake)