forked from jlblancoc/nanoflann
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
121 lines (97 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
# ----------------------------------------------------------------------------
# Root CMake file for nanoflann
#
# 2011 - Jose Luis Blanco
# ----------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.6)
PROJECT(nanoflann)
# --------------------------------------------------------------
# Indicate CMake 2.7 and above that we don't want to mix relative
# and absolute paths in lib lists. Run "cmake --help-policy CMP0003" for info
# --------------------------------------------------------------
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
SET( EXECUTABLE_OUTPUT_PATH ${nanoflann_BINARY_DIR}/bin CACHE PATH "Output directory for programs" )
# Extract library version into "NANOFLANN_VERSION"
# -----------------------------------------------------
# Look for: "#define NANOFLANN_VERSION 0xABC"
file(READ "${nanoflann_SOURCE_DIR}/include/nanoflann.hpp" STR_HPP)
STRING(REGEX MATCHALL "NANOFLANN_VERSION.*0x[0-9,A-F]+" CMAKE_VERSION_LINE "${STR_HPP}")
STRING(REGEX MATCHALL "0x[0-9,A-F]+" NANOFLANN_VERSION_HEX "${CMAKE_VERSION_LINE}")
STRING(REGEX REPLACE "0x(.).*" "\\1" NANOFLANN_VERSION_MAJOR "${NANOFLANN_VERSION_HEX}" )
STRING(REGEX REPLACE "0x.(.).*" "\\1" NANOFLANN_VERSION_MINOR "${NANOFLANN_VERSION_HEX}" )
STRING(REGEX REPLACE "0x..(.).*" "\\1" NANOFLANN_VERSION_PATCH "${NANOFLANN_VERSION_HEX}" )
MESSAGE(STATUS "nanoflann version: ${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}.${NANOFLANN_VERSION_PATCH}")
file(WRITE "${nanoflann_BINARY_DIR}/version" "${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}.${NANOFLANN_VERSION_PATCH}")
file(WRITE "${nanoflann_SOURCE_DIR}/version" "${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}.${NANOFLANN_VERSION_PATCH}")
# Compiler options:
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -mtune=native -Wall -pedantic")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
# Try to find Eigen3 for use in the examples
FIND_PACKAGE(PkgConfig QUIET)
MESSAGE(STATUS "Check for Eigen3")
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(PKG_EIGEN3 QUIET eigen3) # Try to find eigen3 with pkg-config
ENDIF()
SET(EIGEN3_FOUND FALSE)
FIND_PATH(EIGEN3_INCLUDE NAMES signature_of_eigen3_matrix_library
PATHS ${CMAKE_INSTALL_PREFIX}/include ${PKG_EIGEN3_INCLUDE_DIRS}
PATH_SUFFIXES eigen3
)
IF (NOT EXISTS ${EIGEN3_INCLUDE})
MESSAGE(STATUS "Eigen3 not found in standard location. Try passing -DEIGEN3_INCLUDE=/path/to/eigen3")
ELSE()
MESSAGE(STATUS "Using Eigen3 in: ${EIGEN3_INCLUDE}")
INCLUDE_DIRECTORIES("${EIGEN3_INCLUDE}")
SET(EIGEN3_FOUND TRUE)
ENDIF()
# Include dir:
INCLUDE_DIRECTORIES(${nanoflann_SOURCE_DIR}/include)
# Examples
add_subdirectory(examples)
# Tests
SET( BUILD_TESTING ON CACHE BOOL "Build unit tests")
IF( BUILD_TESTING)
add_subdirectory(tests)
ENDIF( BUILD_TESTING)
# --------------------------------------------------------------------
# Install/uninstall targets
# --------------------------------------------------------------------
#--------------------------------------------------------------
# If we are building the final step of the Debian package,
# save each library files in the corresponding directories:
#--------------------------------------------------------------
IF(CMAKE_USE_DEB_POSTFIXS)
# Values when building a Debian package ---------------
MESSAGE(STATUS "** Using Debian post-fix for install directories **")
SET(libnanoflann_dev_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/libnanoflann-dev/usr/")
SET(nanoflann_pkgconfig_INSTALL_PREFIX "/usr") # Values when building a Debian package
ELSE(CMAKE_USE_DEB_POSTFIXS)
# Values under normal conditions -----------------------
SET(libnanoflann_dev_INSTALL_PREFIX "")
SET(nanoflann_pkgconfig_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") # Values under normal conditions
ENDIF(CMAKE_USE_DEB_POSTFIXS)
# Generate the pkg-config file:
CONFIGURE_FILE(
"${nanoflann_SOURCE_DIR}/scripts/nanoflann.pc.in"
"${nanoflann_BINARY_DIR}/nanoflann.pc" @ONLY IMMEDIATE )
# Uninstall target, for "make uninstall"
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
@ONLY IMMEDIATE)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
INSTALL(
FILES "${nanoflann_BINARY_DIR}/nanoflann.pc"
DESTINATION ${libnanoflann_dev_INSTALL_PREFIX}lib${LIB_SUFFIX}/pkgconfig )
INSTALL(
FILES "${nanoflann_SOURCE_DIR}/include/nanoflann.hpp"
DESTINATION ${libnanoflann_dev_INSTALL_PREFIX}include/ )
IF(CMAKE_USE_DEB_POSTFIXS)
INSTALL(
FILES "${nanoflann_SOURCE_DIR}/copyright"
DESTINATION ${libnanoflann_dev_INSTALL_PREFIX}share/doc/libnanoflann-dev/ )
ENDIF(CMAKE_USE_DEB_POSTFIXS)