-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
84 lines (73 loc) · 3.47 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
#*************************************************************************
# CMakeLists.txt -- This file is part of DEN2OBJ. *
# *
# Author: Ivo Filot <[email protected]> *
# *
# DEN2OBJ is free software: you can redistribute it and/or modify *
# it under the terms of the GNU General Public License as published *
# by the Free Software Foundation, either version 3 of the License, *
# or (at your option) any later version. *
# *
# DEN2OBJ is distributed in the hope that it will be useful, *
# but WITHOUT ANY WARRANTY; without even the implied warranty *
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
# See the GNU General Public License for more details. *
# *
# You should have received a copy of the GNU General Public License *
# along with this program. If not, see http://www.gnu.org/licenses/. *
# *
#*************************************************************************/
# set minimum cmake requirements
cmake_minimum_required(VERSION 3.5)
project (den2obj-shared-example)
# add custom directory to look for .cmake files
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules )
# Enable release build
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# add OS specific
SET(BOOST_INCLUDEDIR "/usr/include")
SET(BOOST_LIBRARYDIR "/usr/lib/x86_64-linux-gnu")
# set Boost
set (Boost_NO_SYSTEM_PATHS ON)
set (Boost_USE_MULTITHREADED ON)
set (Boost_USE_STATIC_LIBS OFF)
set (Boost_USE_STATIC_RUNTIME OFF)
set (BOOST_ALL_DYN_LINK OFF)
# use OpenMP
find_package(OpenMP)
if (OPENMP_FOUND)
option(HAS_OPENMP "OpenMP enabled" ON)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
# include libraries
find_package(PkgConfig REQUIRED)
find_package(Boost COMPONENTS regex iostreams filesystem REQUIRED)
find_package(LibLZMA REQUIRED)
find_package(ZLIB REQUIRED)
find_package(BZip2 REQUIRED)
pkg_check_modules(DEN2OBJ den2obj REQUIRED)
pkg_check_modules(EIGEN eigen3 REQUIRED)
# Set include folders
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${EIGEN_INCLUDE_DIRS}
${DEN2OBJ_INCLUDE_DIR}
${Boost_INCLUDE_DIRS})
# Add sources
file(GLOB SOURCES "*.cpp")
add_executable(den2obj-shared-example ${SOURCES})
# Set C++17
add_definitions(-std=c++17 -march=native)
# Link libraries
target_link_libraries(den2obj-shared-example
${DEN2OBJ_LIBRARIES}
${Boost_LIBRARIES}
${LIBLZMA_LIBRARIES}
${ZLIB_LIBRARIES}
${BZIP2_LIBRARIES})