-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
82 lines (64 loc) · 2.71 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
# Require a certain version of cmake
cmake_minimum_required(VERSION 3.0)
# Set the name of the project
project(ThermoHubClient VERSION 0.2.0 LANGUAGES CXX)
# Set the cmake module path of the project
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
# Use ccache to speed up repeated compilations
include(CCache)
# Define variables with the GNU standard installation directories
include(GNUInstallDirs)
# Ensure proper configuration if in a conda environment
include(CondaAware)
# Define which types of libraries to build
option(THERMOHUBCLIENT_BUILD_SHARED_LIBS "Build shared libraries." ON)
option(THERMOHUBCLIENT_BUILD_STATIC_LIBS "Build static libraries." ON)
option(THERMOHUBCLIENT_BUILD_PYTHON "Build the python wrappers and python package thermohubclient." ON)
#option(REFRESH_THIRDPARTY "Refresh thirdparty libraries." OFF)
# Modify the HUBCLIENT_BUILD_* variables accordingly to BUILD_ALL
if(THERMOHUBCLIENT_BUILD_ALL MATCHES ON)
set(THERMOHUBCLIENT_BUILD_SHARED_LIBS ON)
set(THERMOHUBCLIENT_BUILD_STATIC_LIBS ON)
set(THERMOHUBCLIENT_BUILD_PYTHON ON)
endif()
# Set the default build type to Release
if(NOT CMAKE_BUILD_TYPE)
# The build type selection for the project
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the build type for ${PROJECT_NAME}." FORCE)
# The build type options for the project
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release MinSizeRel RelWithDebInfo)
endif()
# Define if shared library should be build instead of static.
option(BUILD_SHARED_LIBS "Build shared libraries." ON)
# Set libraries to be compiled with position independent code mode (i.e., fPIC option in GNU compilers)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Set the list of compiler flags for MSVC compiler
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
add_compile_options(
/D_SCL_SECURE_NO_WARNINGS
/D_CRT_SECURE_NO_WARNINGS=1
/MP4
/EHsc
/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
/DNOMINMAX
)
endif()
# Set the ThermoHubClient source directory path
set(THERMOHUBCLIENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/ThermoHubClient)
# Set the include directories
include_directories(${THERMOHUBCLIENT_SOURCE_DIR})
# Find all ThermoHubClient dependencies
include(ThermoHubClientFindDeps)
# Build ThermoHubClient library
add_subdirectory(ThermoHubClient)
# Build python wraper
if(THERMOHUBCLIENT_BUILD_PYTHON)
add_subdirectory(python)
else()
# add_subdirectory(python EXCLUDE_FROM_ALL)
endif()
# Install the cmake config files that permit users to use find_package(ThermoHubClient)
include(ThermoHubClientInstallCMakeConfigFiles)