forked from SINTEF-Geometry/MBA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
119 lines (92 loc) · 3.12 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
cmake_minimum_required(VERSION 3.7.2 FATAL_ERROR)
project(mba)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
option(BUILD_SHARED_LIBS "Build shared library" OFF)
option(BUILD_EXAMPLES "Build examples" OFF)
add_library(${PROJECT_NAME} "")
FILE(GLOB_RECURSE mba_SRCS src/*.cpp include/*.h)
target_sources(${PROJECT_NAME}
PRIVATE
${mba_SRCS}
)
# Set various compiler flags
target_compile_options(${PROJECT_NAME} PUBLIC
$<$<CXX_COMPILER_ID:GNU>:$<BUILD_INTERFACE:-Wall>>
$<$<CXX_COMPILER_ID:MSVC>:/MP8>
)
target_compile_options(${PROJECT_NAME} PUBLIC $<$<CONFIG:Release>:-DNVERBOSE>)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> #<prefix>/${CMAKE_INSTALL_INCLUDEDIR}/mba
)
set_target_properties(${PROJECT_NAME} PROPERTIES
DEBUG_POSTFIX "_d")
if(BUILD_EXAMPLES)
add_subdirectory(app)
endif()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
#build tree
export(TARGETS ${PROJECT_NAME}
NAMESPACE mba::
FILE "${CMAKE_BINARY_DIR}/lib/cmake/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake"
)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in"
"${CMAKE_BINARY_DIR}/lib/cmake/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CMAKE_BINARY_DIR}/lib/cmake/${PROJECT_NAME}"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/lib/cmake/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION 1.3.0
COMPATIBILITY ExactVersion
)
#install tree
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT ${PROJECT_NAME}_runtime
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT ${PRJECT_NAME}_libraries
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT ${PROJECT_NAME}_libraries
)
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE mba::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT ${PROJECT_NAME}_config
)
## <package_name>ConfigVersion.cmake
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION 1.3.0
COMPATIBILITY ExactVersion
)
## <package_name>Config.cmake
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in"
"${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(FILES "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT ${PROJECT_NAME}_config
)
install(FILES "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT ${PROJECT_NAME}_config
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT ${PROJECT_NAME}_headers
FILES_MATCHING PATTERN "*.h"
REGEX "doxy*" EXCLUDE
)