-
-
Notifications
You must be signed in to change notification settings - Fork 174
/
CMakeLists.txt
132 lines (110 loc) · 4.67 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
cmake_minimum_required(VERSION 3.24 FATAL_ERROR)
project(AvogadroLibs)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Use C++17 when possible
option(PYTHON_WHEEL_BUILD "Is this a Python wheel build?" OFF)
mark_as_advanced(PYTHON_WHEEL_BUILD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS False)
# Set symbol visibility defaults for all targets.
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
set(CMAKE_VISIBILITY_INLINES_HIDDEN True)
include(BuildType)
include(BuildLocation)
include(CompilerFlags)
include(InstallLocation)
include(DetermineVersion)
# Set up our version.
set(AvogadroLibs_VERSION_MAJOR "1")
set(AvogadroLibs_VERSION_MINOR "99")
set(AvogadroLibs_VERSION_PATCH "0")
set(AvogadroLibs_VERSION
"${AvogadroLibs_VERSION_MAJOR}.${AvogadroLibs_VERSION_MINOR}.${AvogadroLibs_VERSION_PATCH}")
find_package(Git)
determine_version(${AvogadroLibs_SOURCE_DIR} ${GIT_EXECUTABLE} "AvogadroLibs")
option(BUILD_SHARED_LIBS "Build with shared libraries" ON)
# Before any plugins are defined, and before any add_subdirectory calls:
set_property(GLOBAL PROPERTY AvogadroLibs_PLUGINS)
set_property(GLOBAL PROPERTY AvogadroLibs_STATIC_PLUGINS)
if(MSVC)
add_definitions("-D_CRT_SECURE_NO_WARNINGS" "-DNOMINMAX -D_USE_MATH_DEFINES")
# Ensure __cplusplus is correct, otherwise it defaults to 199711L which isn't true
# https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-160
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
message(STATUS "Setting MSVC debug information format to 'Embedded'")
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
set(CMAKE_VS_GLOBALS
"UseMultiToolTask=true"
"DebugInformationFormat=OldStyle"
)
endif()
option(ENABLE_TESTING "Enable testing and building the tests." OFF)
option(TEST_QTGL "Build the Qt OpenGL test application" OFF)
option(ENABLE_TRANSLATIONS "Enable building translations with Qt5 Linguist" OFF)
option(USE_OPENGL "Enable libraries that use OpenGL" ON)
option(USE_HDF5 "Enable optional HDF5 features" OFF)
option(USE_QT "Enable libraries that use Qt 5 or 6" ON)
option(USE_VTK "Enable libraries that use VTK" OFF)
option(USE_LIBARCHIVE "Enable optional Libarchive features" ON)
option(USE_LIBMSYM "Enable optional features using libmsym" ON)
option(USE_SPGLIB "Enable optional features using spglib" ON)
option(USE_MMTF "Enable optional features using mmtf" ON)
option(USE_PYTHON "Use Python to wrap some of our API" OFF)
option(USE_EXTERNAL_NLOHMANN "Use an externally-provided version of the nlohmann JSON library" OFF)
option(USE_EXTERNAL_PUGIXML "Use an externally-provided version of pugixml" OFF)
option(USE_EXTERNAL_STRUCT "Use an externally-provided version of the struct binary data formatting library" OFF)
set(QT_VERSION "5" CACHE STRING "What major version of Qt")
set(QT_VERSIONS_SUPPORTED 5 6)
set_property(CACHE QT_VERSION PROPERTY STRINGS 5 6)
if(NOT QT_VERSION IN_LIST QT_VERSIONS_SUPPORTED)
message(FATAL_ERROR "Qt version must be one of ${QT_VERSIONS_SUPPORTED}")
endif()
add_subdirectory(thirdparty)
add_subdirectory(utilities)
add_subdirectory(avogadro)
if(ENABLE_TESTING)
include(CTest)
enable_testing()
add_subdirectory(tests)
endif()
option(BUILD_DOCUMENTATION "Build project documentation" OFF)
if(BUILD_DOCUMENTATION)
add_subdirectory(docs)
endif()
if(USE_PYTHON)
add_subdirectory(python)
endif()
if(ENABLE_TRANSLATIONS)
find_package(Qt5LinguistTools)
endif()
# SKBUILD is set for binary wheel
if (NOT SKBUILD)
install(
FILES
README.md
CONTRIBUTING.md
LICENSE
DESTINATION "${INSTALL_DOC_DIR}/avogadrolibs")
endif()
# After all add_subdirectory calls, so the list of plugins is complete:
get_property(AvogadroLibs_PLUGINS GLOBAL PROPERTY AvogadroLibs_PLUGINS)
get_property(AvogadroLibs_STATIC_PLUGINS GLOBAL
PROPERTY AvogadroLibs_STATIC_PLUGINS)
configure_file(${AvogadroLibs_SOURCE_DIR}/cmake/CTestCustom.cmake.in
${AvogadroLibs_BINARY_DIR}/CTestCustom.cmake)
configure_file("${AvogadroLibs_SOURCE_DIR}/cmake/AvogadroLibsConfig.cmake.in"
"${AvogadroLibs_BINARY_DIR}/AvogadroLibsConfig.cmake" @ONLY)
configure_file("${AvogadroLibs_SOURCE_DIR}/cmake/AvogadroLibsConfigVersion.cmake.in"
"${AvogadroLibs_BINARY_DIR}/AvogadroLibsConfigVersion.cmake" @ONLY)
# SKBUILD is set for binary wheel
if (NOT SKBUILD)
install(FILES
"${AvogadroLibs_BINARY_DIR}/AvogadroLibsConfig.cmake"
"${AvogadroLibs_BINARY_DIR}/AvogadroLibsConfigVersion.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Findlibmsym.cmake"
DESTINATION "${INSTALL_LIBRARY_DIR}/cmake/avogadrolibs")
install(EXPORT "AvogadroLibsTargets"
NAMESPACE Avogadro::
DESTINATION "${INSTALL_LIBRARY_DIR}/cmake/avogadrolibs")
endif()