-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
96 lines (74 loc) · 3.3 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
cmake_minimum_required (VERSION 2.8.12.2 FATAL_ERROR)
# Set options for this project.
set (PROJECT_NAME "SCIM" CXX)
project (${PROJECT_NAME})
set (PROJECT_SOURCE_DECLARATION_DIRECTORY ${PROJECT_SOURCE_DIR}/include)
set (PROJECT_SOURCE_DEFINITION_DIRECTORY ${PROJECT_SOURCE_DIR}/src)
set (MAIN_FILE ${PROJECT_SOURCE_DEFINITION_DIRECTORY}/main.cpp)
# Set options used by "CMake".
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
#execute_process(
# COMMAND ${CMAKE_COMMAND} -E environment
#)
SET( EIGEN3_INCLUDE_DIR "$ENV{EIGEN3_INCLUDE_DIR}" )
IF( NOT EIGEN3_INCLUDE_DIR )
SET( EIGEN3_INCLUDE_DIR "ENV{EIGEN3_INCLUDE_DIR}" )
IF( NOT EIGEN3_INCLUDE_DIR )
MESSAGE( FATAL_ERROR "Please point the environment variable EIGEN3_INCLUDE_DIR to the include directory of your Eigen3 installation.")
ENDIF()
ENDIF()
INCLUDE_DIRECTORIES ( "${EIGEN3_INCLUDE_DIR}" )
# Set options used by "FindBoost.cmake".
# Either specify BOOST_ROOT or BOOST_INCLUDEDIR and BOOST_LIBRARYDIR.
# I am using "MinGW Distro" in this example, but also a relative path, e. g.
# "vendor/boost" can be specified.
set (BOOST_ROOT "$ENV{BOOST_ROOT}")
#set (Boost_NO_SYSTEM_PATHS ON)
#set (Boost_USE_MULTITHREADED ON)
#set (Boost_USE_STATIC_LIBS ON)
#set (Boost_USE_STATIC_RUNTIME OFF)
#set (BOOST_ALL_DYN_LINK OFF)
# Load settings for the external project "Boost".
# The components "system" and "filesystem" from "Boost" version 1.55.0 or
# greater are required.
if (NOT BOOST_ROOT)
# From the offical documentation:
# Add include directories to the build. [...] If the SYSTEM option is given,
# the compiler will be told the directories are meant as system include
# directories on some platforms (signalling this setting might achieve effects
# such as the compiler skipping warnings [...])."
set (BOOST_ROOT "ENV{BOOST_ROOT}")
if (NOT BOOST_ROOT)
MESSAGE( FATAL_ERROR "Please point the environment variable BOOST_ROOT to the include directory of your Boost installation.")
endif()
# From the offical documentation:
# "Specify directories in which the linker will look for libraries. [...] Note
# that this command is rarely necessary. Library locations returned by
# find_package() and find_library() are absolute paths. Pass these absolute
# library file paths directly to the target_link_libraries() command. CMake
# will ensure the linker finds them."
#link_directories (${Boost_LIBRARY_DIRS})
endif ()
include_directories ("${BOOST_ROOT}")
include_directories (include)
ADD_DEFINITIONS(-D_USE_MATH_DEFINES)
#However, the file(GLOB...) allows for wildcard additions:
#file(GLOB SOURCES "src/*.cpp")
file(GLOB SOURCES
"src/*.cpp"
"include/*.h"
)
# "Add an executable to the project using the specified source files."
add_executable (${PROJECT_NAME} ${SOURCES})
# "Link a target to given libraries."
target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES})