-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
136 lines (121 loc) · 4.41 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
#
# This file is part of the Geometry library.
# Copyright (C) 2009-2015 Benjamin Eikel <[email protected]>
# Copyright (C) 2015-2019 Sascha Brandt <[email protected]>
#
# This library is subject to the terms of the Mozilla Public License, v. 2.0.
# You should have received a copy of the MPL along with this library; see the
# file LICENSE. If not, you can obtain one at http://mozilla.org/MPL/2.0/.
#
cmake_minimum_required(VERSION 3.1.0)
project(Geometry VERSION 0.3.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Set up install directories
include(GNUInstallDirs)
set(CMAKE_INSTALL_CMAKECONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/Geometry)
# Add the library
add_library(Geometry SHARED
BoundingSphere.cpp
BoxHelper.cpp
BoxIntersection.cpp
Frustum.cpp
RayBoxIntersection.cpp
Tools.cpp
)
set_property(TARGET Geometry PROPERTY PUBLIC_HEADER
Angle.h
BoundingSphere.h
Box.h
BoxHelper.h
BoxIntersection.h
Cone.h
Convert.h
Definitions.h
DualQuaternion.h
Frustum.h
Interpolation.h
Line.h
LineTriangleIntersection.h
Matrix3x3.h
Matrix4x4.h
Plane.h
Point.h
PointOctree.h
Quaternion.h
RayBoxIntersection.h
Rect.h
Sphere.h
SQT.h
SRT.h
Tetrahedron.h
Tools.h
Triangle.h
TriangleTriangleIntersection.h
Vec2.h
Vec3.h
Vec4.h
VecHelper.h
VecN.h
)
if(MSVC)
target_compile_definitions(Geometry PRIVATE "GEOMETRYAPI=__declspec(dllexport)")
target_compile_definitions(Geometry INTERFACE "GEOMETRYAPI=__declspec(dllimport)")
else()
target_compile_definitions(Geometry PRIVATE "GEOMETRYAPI=")
target_compile_definitions(Geometry INTERFACE "GEOMETRYAPI=")
endif()
# Set version of library
set_target_properties(Geometry PROPERTIES VERSION ${Geometry_VERSION}
SOVERSION ${Geometry_VERSION_MAJOR}
POSITION_INDEPENDENT_CODE ON
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
option(GEOMETRY_BUILD_TESTS "Defines if CppUnit tests for the Geometry library are built.")
if(GEOMETRY_BUILD_TESTS)
if(UNIX AND NOT APPLE)
find_program(MEMORYCHECK_COMMAND NAMES valgrind)
set(MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck --leak-check=summary --num-callers=1 --vgdb=no")
endif()
include(CTest)
add_subdirectory(tests)
endif()
# Install the library
install(TARGETS Geometry EXPORT LibraryExport
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtimelibraries
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtimelibraries
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT developmentlibraries
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Geometry COMPONENT headers
)
# Set include directories for users of this library
target_include_directories(Geometry
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/.."
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
# Library export
install(EXPORT LibraryExport DESTINATION ${CMAKE_INSTALL_CMAKECONFIGDIR} FILE GeometryTargets.cmake COMPONENT developmentlibraries)
# Create the configuration files
include(CMakePackageConfigHelpers)
configure_package_config_file(GeometryConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/GeometryConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_CMAKECONFIGDIR}
PATH_VARS CMAKE_INSTALL_CMAKECONFIGDIR
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/GeometryConfigVersion.cmake
COMPATIBILITY SameMajorVersion)
# Install the configuration files
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/GeometryConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/GeometryConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_CMAKECONFIGDIR} COMPONENT developmentlibraries)
# Packaging
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_NAME "libgeometry${Geometry_VERSION_MAJOR}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Geometry library")
set(CPACK_PACKAGE_VENDOR "Benjamin Eikel; Claudius Jaehn; Ralf Petring; Sascha Brandt")
set(CPACK_PACKAGE_CONTACT "Benjamin Eikel <[email protected]>")
set(CPACK_PACKAGE_VERSION_MAJOR ${Geometry_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${Geometry_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${Geometry_VERSION_PATCH})
set(CPACK_PACKAGE_FILE_NAME "libGeometry")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_STRIP_FILES ON)
include(CPack)