-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
57 lines (47 loc) · 1.95 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
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(pcl-mean-and-covariance)
if(NOT CMAKE_BUILD_TYPE)
message("-- No build type specified; defaulting to CMAKE_BUILD_TYPE=Release.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
string(REPLACE "." "-" COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(COMPILER "clang-${COMPILER_VERSION}")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(COMPILER "gcc-${COMPILER_VERSION}")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(COMPILER "intel-${COMPILER_VERSION}")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(COMPILER "msvc-${COMPILER_VERSION}")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(COMPILER "appleclang-${COMPILER_VERSION}")
endif()
# Benchmarks and tests will be compiled with different compiler flags pertaining to CPU instruction set.
# Clang and Celero do not play well with "-mno-sse2" flag, so add it only for non-Clang compilers.
set(FLAGS none native sse2)
if(NOT (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")))
list(APPEND FLAGS no-sse2)
endif()
# Helper macro to add a compiler option corresponding to a flag to a given target.
macro(add_flag target flag)
set(_opt "")
if(${flag} STREQUAL "native")
set(_opt "-march=native")
elseif(NOT ${flag} STREQUAL "none")
set(_opt "-m${flag}")
endif()
target_compile_options(${target} PRIVATE "${_opt}")
endmacro()
add_subdirectory(third-party)
add_library(mean_and_covariance INTERFACE)
set_property(
TARGET mean_and_covariance
PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${PCL_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src
)
add_subdirectory(bench)
add_subdirectory(test)
message("-- Compiler: ${COMPILER}")
message("-- Flags: ${FLAGS}")