-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
99 lines (82 loc) · 3.11 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
97
98
99
cmake_minimum_required(VERSION 3.3)
project(DopeVector)
option(WITH_RTTI "Build DopeVector using RTTI or not" OFF)
option(WITH_EIGEN "Build DopeVector with Index<Dimension> as Eigen Matrix (if present) or not." OFF)
option(ATTACH_SOURCES "When generating an IDE project, add DopeVector header files to project sources." OFF)
set(hdr_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(hdr_internal_files
${hdr_dir}/DopeVector/internal/Common.hpp
${hdr_dir}/DopeVector/internal/Expression.hpp
${hdr_dir}/DopeVector/internal/eigen_support/EigenExpression.hpp
${hdr_dir}/DopeVector/internal/Iterator.hpp
)
source_group("DopeVector\\internal" FILES ${hdr_internal_files})
set(hdr_internal_inline_files
${hdr_dir}/DopeVector/internal/inlines/Index.inl
${hdr_dir}/DopeVector/internal/inlines/Expression.inl
${hdr_dir}/DopeVector/internal/inlines/eigen_support/EigenExpression.inl
${hdr_dir}/DopeVector/internal/inlines/Iterator.inl
${hdr_dir}/DopeVector/internal/inlines/DopeVector.inl
${hdr_dir}/DopeVector/internal/inlines/Grid.inl
)
set_source_files_properties(${hdr_internal_inline_files} PROPERTIES XCODE_EXPLICIT_FILE_TYPE "sourcecode.cpp.h")
source_group("DopeVector\\internal\\inlines" FILES ${hdr_internal_inline_files})
set(hdr_main_files
${hdr_dir}/DopeVector/DopeVector.hpp
${hdr_dir}/DopeVector/Grid.hpp
${hdr_dir}/DopeVector/Index.hpp
)
source_group("DopeVector" FILES ${hdr_main_files})
set(all_hdr ${hdr_internal_files} ${hdr_internal_inline_files} ${hdr_main_files})
add_library(${PROJECT_NAME} INTERFACE)
set(required_cxx_features
cxx_alias_templates
cxx_auto_type
cxx_constexpr
cxx_decltype
cxx_default_function_template_args
cxx_defaulted_functions
cxx_defaulted_move_initializers
cxx_deleted_functions
cxx_explicit_conversions
cxx_generalized_initializers
cxx_lambdas
cxx_noexcept
cxx_nonstatic_member_init
cxx_nullptr
cxx_override
cxx_range_for
cxx_right_angle_brackets
cxx_rvalue_references
cxx_static_assert
cxx_variadic_templates
)
target_compile_features(${PROJECT_NAME} INTERFACE ${required_cxx_features})
target_include_directories(${PROJECT_NAME} INTERFACE ${hdr_dir})
if(ATTACH_SOURCES)
target_sources(${PROJECT_NAME} INTERFACE ${all_hdr})
endif()
if(WITH_EIGEN)
find_package(Eigen3 3.3.1 QUIET NO_MODULE) # Eigen 3.3 uses modern cmake
if(EIGEN3_FOUND)
message(STATUS "Found Eigen ${Eigen3_VERSION} for use in DopeVector")
target_link_libraries(${PROJECT_NAME} INTERFACE Eigen3::Eigen)
target_compile_definitions(${PROJECT_NAME} INTERFACE DOPE_USE_EIGEN)
else()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH})
find_package(Eigen3 QUIET)
if(EIGEN3_FOUND)
message(STATUS "Found Eigen ${Eigen3_VERSION} for use in DopeVector")
target_include_directories(${PROJECT_NAME} INTERFACE ${EIGEN3_INCLUDE_DIR})
target_compile_definitions(${PROJECT_NAME} INTERFACE DOPE_USE_EIGEN)
else()
message(STATUS "Eigen was not found")
endif()
endif()
endif(WITH_EIGEN)
if(WITH_RTTI)
message(STATUS "RTTI is on")
target_compile_definitions(${PROJECT_NAME} INTERFACE DOPE_USE_RTTI)
else()
message(STATUS "RTTI is off")
endif()