forked from tudelft3d/masbcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
84 lines (65 loc) · 2.76 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
cmake_minimum_required(VERSION 2.8)
project(masbcpp)
# C++11
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
# Figure out if we can enable OpenMP
set(LINK_LIBS)
set(COMPILE_OPTIONS "-funroll-loops -ffast-math")
# disable openmp with xcode, doesn't work
if(NOT CMAKE_GENERATOR MATCHES "Xcode")
if(APPLE)
if(EXISTS "/usr/local/bin/clang-omp++")
message(STATUS "Building with OMP support")
set(CMAKE_CXX_COMPILER "/usr/local/bin/clang-omp++" )
add_definitions(-DWITH_OPENMP)
#add_definitions(-DCLANG_OMP)
set(LINK_LIBS ${LINK_LIBS} -liomp5)
set(COMPILE_OPTIONS "${COMPILE_OPTIONS} -fopenmp")
include_directories(/usr/local/include/libiomp)
link_directories(/usr/local/lib)
endif()
else()
find_package(OpenMP)
if(OPENMP_FOUND)
add_definitions(-DWITH_OPENMP)
set(COMPILE_OPTIONS "${COMPILE_OPTIONS} ${OpenMP_CXX_FLAGS}")
endif()
endif()
endif()
# Find eigen, should set EIGEN3_INCLUDE_DIR
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(Eigen3 REQUIRED)
find_package(PCL 1.8 REQUIRED COMPONENTS common search features)
# enable verbose printing by default
# PCL_NO_PRECOMPILE is needed to make the pcl::NormalEstimationOMP work properly
add_definitions(${PCL_DEFINITIONS} -DVERBOSEPRINT -DPCL_NO_PRECOMPILE)
# global
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_OPTIONS}")
set(CMAKE_BUILD_TYPE Release)
set_property(GLOBAL PROPERTY LINKER_LANGUAGE CXX)
# include directories
include_directories(${CMAKE_SOURCE_DIR}/thirdparty ${PCL_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR})
link_directories(${PCL_LIBRARY_DIRS})
# bundle all thirdparty stuff as a static library
FILE(GLOB_RECURSE THIRDPARTY thirdparty/*.cpp)
add_library(thirdparty STATIC ${THIRDPARTY})
set(LINK_LIBS ${LINK_LIBS} thirdparty ${PCL_COMMON_LIBRARIES} ${PCL_SEARCH_LIBRARIES} ${PCL_FEATURES_LIBRARIES})
# build a library from the masbpcpp processing functions
# add_library(masbcpp STATIC src/compute_ma_processing.cpp src/compute_normals_processing.cpp src/simplify_processing.cpp)
add_library(masbcpp STATIC src/io.cpp src/compute_normals_processing.cpp src/compute_ma_processing.cpp src/simplify_processing.cpp)
# set excutables
add_executable(compute_ma src/compute_ma.cpp)
add_executable(compute_normals src/compute_normals.cpp)
add_executable(simplify src/simplify.cpp)
# link targets
target_link_libraries(masbcpp ${LINK_LIBS})
target_link_libraries(compute_ma masbcpp)
target_link_libraries(compute_normals masbcpp)
target_link_libraries(simplify masbcpp)
# install(TARGETS compute_ma compute_normals simplify DESTINATION bin)