-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
165 lines (137 loc) · 5.15 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
# Copyright 2003,2006,2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
# Under the terms of Contract DE-NA0003525 with NTESS,
# the U.S. Government retains certain rights in this software.
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED 1)
project(verdict VERSION 1.4.2)
# Includes
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
if (POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif ()
set(verdict_VERSION_FLAT "${verdict_VERSION_MAJOR}${verdict_VERSION_MINOR}${verdict_VERSION_PATCH}")
option(VERDICT_BUILD_DOC "Build the 2007 Verdict User Manual" OFF)
option(VERDICT_MANGLE "Mangle verdict names for inclusion in a larger library?" OFF)
if (VERDICT_MANGLE)
set(VERDICT_MANGLE_PREFIX "verdict" CACHE STRING "The namespace enclosing verdict function names and classes.")
mark_as_advanced(VERDICT_MANGLE_PREFIX)
endif ()
mark_as_advanced(VERDICT_MANGLE)
option(VERDICT_ENABLE_TESTING "Should tests of the VERDICT library be built?" ON)
set(verdict_HEADERS
verdict.h
VerdictVector.hpp
verdict_defines.hpp)
set(verdict_SOURCES
V_EdgeMetric.cpp
V_GaussIntegration.cpp
V_GaussIntegration.hpp
V_HexMetric.cpp
V_KnifeMetric.cpp
V_PyramidMetric.cpp
V_QuadMetric.cpp
V_TetMetric.cpp
V_TriMetric.cpp
V_WedgeMetric.cpp
VerdictVector.cpp)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/verdict_config.h.in
${CMAKE_CURRENT_BINARY_DIR}/verdict_config.h
@ONLY)
add_library(verdict ${verdict_SOURCES} ${verdict_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/verdict_config.h)
target_include_directories(verdict PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
if(UNIX)
target_link_libraries(verdict PRIVATE m)
endif()
# Setting the VERSION and SOVERSION of a library will include
# version information either in the library, or in the library
# name (depending on the platform). You may choose to exclude
# this information.
if (NOT VERDICT_NO_LIBRARY_VERSION)
set_target_properties(verdict PROPERTIES
VERSION "${verdict_VERSION}"
SOVERSION "${verdict_VERSION_MAJOR}.${verdict_VERSION_MINOR}")
endif ()
if (NOT VERDICT_EXPORT_GROUP)
set(VERDICT_EXPORT_GROUP VerdictExport)
endif ()
if (VERDICT_ENABLE_TESTING)
enable_testing()
if (NOT TARGET GTest::GTest)
find_package(GTest REQUIRED)
endif ()
function(add_verdict_unittests DIR)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${DIR} ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
foreach (TEST ${ARGN})
add_test(NAME UT-${TEST}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${DIR}
COMMAND ${TEST})
endforeach (TEST ${ARGN})
endfunction()
add_verdict_unittests(unittests unittests_verdict)
endif ()
if (VERDICT_BUILD_DOC)
add_subdirectory(docs/VerdictUserManual2007)
endif ()
#########################
# Installation commands #
#########################
if (NOT verdict_INSTALL_DOC_DIR)
set(verdict_INSTALL_DOC_DIR ${CMAKE_INSTALL_DOCDIR})
endif ()
if (NOT verdict_INSTALL_INCLUDE_DIR)
set(verdict_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR})
endif ()
if (NOT verdict_INSTALL_INCLUDE_SUBDIR)
set(verdict_INSTALL_INCLUDE_SUBDIR verdict)
endif ()
if (NOT verdict_INSTALL_BIN_DIR)
set(verdict_INSTALL_BIN_DIR ${CMAKE_INSTALL_BINDIR})
endif ()
if (NOT verdict_INSTALL_LIB_DIR)
set(verdict_INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR})
endif ()
if (NOT verdict_INSTALL_CMAKE_DIR)
set(verdict_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/verdict)
endif ()
# Install documentation
install(FILES
README.md
DESTINATION ${verdict_INSTALL_DOC_DIR}/verdict/${verdict_VERSION}/ COMPONENT VerdictDevelopment)
# Install required header files
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/verdict_config.h
verdict.h
DESTINATION ${verdict_INSTALL_INCLUDE_DIR} COMPONENT VerdictDevelopment)
target_include_directories(verdict PUBLIC $<INSTALL_INTERFACE:${verdict_INSTALL_INCLUDE_DIR}>)
# Install library
install(TARGETS verdict EXPORT ${VERDICT_EXPORT_GROUP}
RUNTIME DESTINATION ${verdict_INSTALL_BIN_DIR} COMPONENT Runtime # .exe, .dll
LIBRARY DESTINATION ${verdict_INSTALL_LIB_DIR} COMPONENT Runtime # .so, .dll
ARCHIVE DESTINATION ${verdict_INSTALL_LIB_DIR} COMPONENT VerdictDevelopment #[[.a, .lib]])
# Export Targets file
export(EXPORT ${VERDICT_EXPORT_GROUP}
FILE "${CMAKE_CURRENT_BINARY_DIR}/VerdictTargets.cmake"
NAMESPACE Verdict::)
# Install Targets file
install(EXPORT ${VERDICT_EXPORT_GROUP}
FILE "VerdictTargets.cmake"
NAMESPACE Verdict::
DESTINATION ${verdict_INSTALL_CMAKE_DIR} COMPONENT VerdictDevelopment)
# Create Config file
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/VerdictConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/VerdictConfig.cmake"
INSTALL_DESTINATION ${verdict_INSTALL_CMAKE_DIR})
# Generate the version file for the Config file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/VerdictConfigVersion.cmake"
VERSION "${verdict_VERSION}"
COMPATIBILITY AnyNewerVersion)
# Install Config and ConfigVersion files
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/VerdictConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/VerdictConfigVersion.cmake"
DESTINATION ${verdict_INSTALL_CMAKE_DIR} COMPONENT VerdictDevelopment)