-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
107 lines (90 loc) · 4.21 KB
/
Copy pathCMakeLists.txt
File metadata and controls
107 lines (90 loc) · 4.21 KB
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
# RPBA - Robust Parallel Bundle Adjustment
#
# File CMakeLists.txt
#
#
#
# Copyright 2019 Helmut Mayer, Bundeswehr University Munich, Germany, Helmut.Mayer@unibw.de
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
cmake_minimum_required(VERSION 3.5)
project(rpba)
# RPBA files
file(GLOB rpba_sources rpba.cpp rpbacore.cpp rbacore.cpp)
set(CMAKE_CONFIGURATION_TYPES "Release;Debug" CACHE STRING "limited configs" FORCE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build mode (Values: Release, Debug)")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release Debug)
# ------------------------------------
# Boost
# ------------------------------------
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
# ------------------------------------
# Eigen
# ------------------------------------
find_path(EIGEN_INCLUDE_DIR Eigen/Core Eigen/Geometry $ENV{EIGEN_ROOT}/include /usr/include /usr/local/include)
include_directories(${EIGEN_INCLUDE_DIR})
# ------------------------------------
# METIS
# ------------------------------------
if(CMAKE_COMPILER_IS_GNUCXX)
set(METIS_LIBS libmetis.so metis.so)
else()
set(METIS_LIBS metis.lib)
endif()
find_path(METIS_INCLUDE_DIR metis.h $ENV{METIS_ROOT}/include /usr/include)
find_path(METIS_LIB_DIR ${METIS_LIBS} $ENV{METIS_ROOT}/lib /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu /usr/lib64)
include_directories(${METIS_INCLUDE_DIR})
link_directories(${METIS_LIB_DIR})
set(RPBA_TARGET_LIBS ${RPBA_TARGET_LIBS} ${METIS_LIBS})
# ------------------------------------
# TCMalloc
# ------------------------------------
if(UNIX)
option(BUILD_WITH_TCMALLOC "Use TCMalloc" OFF)
option(BUILD_WITH_PROFILER "Use TCMalloc with profiler" OFF)
# TCMalloc
if(BUILD_WITH_TCMALLOC)
if(BUILD_WITH_PROFILER)
set(rpba_TARGET_LIBS ${rpba_TARGET_LIBS} tcmalloc_and_profiler)
else()
set(rpba_TARGET_LIBS ${rpba_TARGET_LIBS} tcmalloc)
endif()
endif()
# TCMalloc with profiler
if(BUILD_WITH_PROFILER)
if(BUILD_WITH_TCMALLOC)
else()
set(rpba_TARGET_LIBS ${rpba_TARGET_LIBS} tcmalloc_and_profiler)
endif()
endif()
endif()
# set OpenMP flags
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
# Check for the 64-bit compiler
if( CMAKE_SIZEOF_VOID_P LESS 8 )
message(SEND_ERROR "Only 64 bit build mode is supported.")
endif()
include_directories(.)
if(CMAKE_COMPILER_IS_GNUCXX)
#-Wconversion
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-reorder -Wno-unknown-pragmas -Wextra -Wunreachable-code -std=c++14 -m64")
set(CMAKE_CXX_FLAGS_RELEASE "-Wno-unused-result -Wno-unused-parameter -Wno-unused-local-typedefs -pipe -march=native -pedantic -O3 -DNDEBUG -DEIGEN_NO_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-Wconversion -pipe -march=native -pedantic -g -DHPE_RUNTIME_CHECKS")
else()
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251 /wd4512")
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} "/MP /Ox /DNDEBUG /DEIGEN_NO_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} "/MP /Ob1")
endif()
set(CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
set(CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
add_executable(rpba ${rpba_sources})
target_link_libraries(rpba ${RPBA_TARGET_LIBS})