2
2
# Distributed under the Boost Software License, Version 1.0.
3
3
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4
4
5
- cmake_minimum_required (VERSION 3.7 )
5
+ cmake_minimum_required (VERSION 3.8 )
6
6
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /cmake" )
7
7
8
8
@@ -28,24 +28,28 @@ include(CheckCxxCompilerSupport)
28
28
29
29
30
30
##############################################################################
31
- # Setup the 'hana' header-only library target.
31
+ # Setup the 'hana' header-only library target, along with its install target
32
+ # and exports.
32
33
##############################################################################
33
34
add_library (hana INTERFACE )
34
- target_include_directories (hana INTERFACE include )
35
-
36
- include (CheckCXXCompilerFlag)
37
- # On Clang for Windows, -std=c++14 is not known, but -std=c++1y appears to work.
38
- if (MSVC AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" )
39
- check_cxx_compiler_flag(-std=c++1y BOOST_HANA_HAS_STD_CPP1Y)
40
- if (BOOST_HANA_HAS_STD_CPP1Y)
41
- target_add_compile_options(hana INTERFACE -std=c++1y)
42
- endif ()
43
- else ()
44
- # TODO: Set these as interface properties when supported
45
- set (CMAKE_CXX_STANDARD 14)
46
- set (CMAKE_CXX_STANDARD_REQUIRED YES )
35
+ target_include_directories (hana INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include>"
36
+ $<INSTALL_INTERFACE:include >)
37
+ # With Clang on Windows, the -std=c++14 flag is incorrectly set and the compiler
38
+ # complains about the unkown option. TODO: Remove this workaround once the
39
+ # underlying bug is fixed in CMake: https://gitlab.kitware.com/cmake/cmake/issues/17015
40
+ if (NOT (MSVC AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" ))
41
+ target_compile_features (hana INTERFACE cxx_std_14)
47
42
endif ()
48
43
44
+ # Export the `hana` library into a HanaConfig.cmake file
45
+ install (TARGETS hana EXPORT HanaConfig)
46
+ install (EXPORT HanaConfig DESTINATION lib/cmake/hana)
47
+ install (DIRECTORY include /boost DESTINATION include FILES_MATCHING PATTERN "*.hpp" )
48
+
49
+ # Also install an optional pkg-config file
50
+ configure_file (cmake/hana.pc.in hana.pc @ONLY)
51
+ install (FILES "${CMAKE_CURRENT_BINARY_DIR} /hana.pc" DESTINATION lib/pkgconfig)
52
+
49
53
50
54
##############################################################################
51
55
# Setup CMake options
@@ -66,6 +70,7 @@ option(BOOST_HANA_ENABLE_EXCEPTIONS
66
70
##############################################################################
67
71
# Function to setup common compiler flags on tests and examples
68
72
##############################################################################
73
+ include (CheckCXXCompilerFlag)
69
74
function (boost_hana_set_test_properties target )
70
75
target_link_libraries (${target} PRIVATE hana)
71
76
set_target_properties (${target} PROPERTIES CXX_EXTENSIONS NO )
@@ -110,17 +115,11 @@ endfunction()
110
115
111
116
112
117
##############################################################################
113
- # Setup include paths. More include paths can be added in subdirectories .
118
+ # Look for the rest of Boost, which is an optional dependency of some tests .
114
119
##############################################################################
115
- include_directories (${Boost.Hana_SOURCE_DIR}/include )
116
-
117
120
find_package (Boost 1.59)
118
- if (Boost_FOUND)
119
- include_directories (${Boost_INCLUDE_DIRS} )
120
- else ()
121
- message (WARNING
122
- "The Boost library headers were not found; targets depending "
123
- "on Boost won't be available." )
121
+ if (NOT Boost_FOUND)
122
+ message (WARNING "The rest of Boost was not found; some tests and examples will be disabled." )
124
123
endif ()
125
124
126
125
@@ -142,9 +141,9 @@ function(boost_hana_target_name_for out file)
142
141
set (_extension "${ARGV2} " )
143
142
endif ()
144
143
145
- file (RELATIVE_PATH _relative ${Boost.Hana_SOURCE_DIR} ${file} )
146
- string (REPLACE "${_extension} " "" _name ${_relative} )
147
- string (REGEX REPLACE "/" "." _name ${_name} )
144
+ file (RELATIVE_PATH _relative " ${Boost.Hana_SOURCE_DIR}" " ${file} " )
145
+ string (REPLACE "${_extension} " "" _name " ${_relative} " )
146
+ string (REGEX REPLACE "/" "." _name " ${_name} " )
148
147
set (${out} "${_name} " PARENT_SCOPE)
149
148
endfunction ()
150
149
@@ -154,7 +153,7 @@ endfunction()
154
153
##############################################################################
155
154
add_custom_target (check
156
155
COMMAND ${CMAKE_CTEST_COMMAND} --output -on -failure
157
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
156
+ WORKING_DIRECTORY " ${CMAKE_CURRENT_BINARY_DIR} "
158
157
COMMENT "Build and then run all the tests and examples." )
159
158
160
159
@@ -175,15 +174,3 @@ add_subdirectory(benchmark)
175
174
add_subdirectory (doc )
176
175
add_subdirectory (example)
177
176
add_subdirectory (test )
178
-
179
-
180
- ##############################################################################
181
- # Setup the 'install' target.
182
- # This copies the whole content of include/ to ${CMAKE_INSTALL_PREFIX}.
183
- ##############################################################################
184
- install (DIRECTORY include /boost DESTINATION include
185
- PATTERN ".DS_Store" EXCLUDE )
186
-
187
- # We also install an optional pkg-config file.
188
- configure_file (cmake/hana.pc.in hana.pc @ONLY)
189
- install (FILES ${CMAKE_CURRENT_BINARY_DIR} /hana.pc DESTINATION lib/pkgconfig)
0 commit comments