-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
103 lines (87 loc) · 3.11 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
# Copyright 2024 Spectacular AI Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.3)
option(IsoOctree_PYTHON "Build python bindings" OFF)
option(IsoOctree_STATIC "Build static lib" OFF)
if (IsoOctree_PYTHON)
set(LIBNAME "IsoOctreeNative")
else()
set(LIBNAME "IsoOctree")
endif()
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt" VERSION_CONTENTS)
project(${LIBNAME} VERSION ${VERSION_CONTENTS})
if (IsoOctree_STATIC OR IsoOctree_PYTHON)
set(IsoOctree_LIBTYPE "STATIC")
else()
set(IsoOctree_LIBTYPE "SHARED")
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(ISO_OCTREE_SRC SRC/api.cpp)
add_library(${LIBNAME} ${IsoOctree_LIBTYPE} ${ISO_OCTREE_SRC})
target_include_directories(${LIBNAME} PRIVATE SRC)
set_target_properties(${LIBNAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)
if(NOT MSVC)
target_compile_options(${LIBNAME} PRIVATE "-Wno-dangling-else")
endif()
if (NOT IsoOctree_PYTHON)
include(GNUInstallDirs)
install(FILES
include/IsoOctree/IsoOctree.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${LIBNAME}
COMPONENT Devel)
# CMake installation boilerplate
install(TARGETS ${LIBNAME}
EXPORT ${LIBNAME}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
set_property(TARGET ${LIBNAME} PROPERTY VERSION ${PROJECT_VERSION})
set_property(TARGET ${LIBNAME} PROPERTY SOVERSION ${MAJOR_VERSION})
set_property(TARGET ${LIBNAME} PROPERTY INTERFACE_${LIBNAME}_MAJOR_VERSION ${MAJOR_VERSION})
set_property(TARGET ${LIBNAME} APPEND PROPERTY COMPATIBLE_INTERFACE_STRING ${LIBNAME}_MAJOR_VERSION)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${LIBNAME}/${LIBNAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT ${LIBNAME}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${LIBNAME}/${LIBNAME}Targets.cmake"
NAMESPACE ${LIBNAME}::
)
configure_file(cmake/${LIBNAME}Config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/${LIBNAME}/${LIBNAME}Config.cmake"
COPYONLY
)
set(ConfigPackageLocation lib/cmake/${LIBNAME})
install(EXPORT ${LIBNAME}Targets
FILE
${LIBNAME}Targets.cmake
NAMESPACE
${LIBNAME}::
DESTINATION
${ConfigPackageLocation}
)
install(
FILES
cmake/${LIBNAME}Config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/${LIBNAME}/${LIBNAME}ConfigVersion.cmake"
DESTINATION
${ConfigPackageLocation}
COMPONENT
Devel
)
endif()