|
2 | 2 | # This file is subject to the license terms in the LICENSE file |
3 | 3 | # found in the top-level directory of this distribution. |
4 | 4 |
|
5 | | -cmake_minimum_required(VERSION 3.1) |
6 | | -project(array) |
| 5 | +cmake_minimum_required(VERSION 3.8) |
| 6 | +project(foonathan_array VERSION 0.0.0) |
7 | 7 |
|
| 8 | +# source files |
8 | 9 | set(detail_header_files |
9 | 10 | ${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/array/detail/all_of.hpp |
10 | 11 | ${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/array/detail/is_trivial.hpp |
@@ -39,14 +40,37 @@ set(header_files |
39 | 40 | ${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/array/small_bag.hpp |
40 | 41 | ${CMAKE_CURRENT_SOURCE_DIR}/include/foonathan/array/variant_bag.hpp |
41 | 42 | ) |
| 43 | + |
| 44 | +# main target |
42 | 45 | add_library(foonathan_array INTERFACE) |
43 | | -target_sources(foonathan_array INTERFACE ${detail_header_files} ${header_files}) |
44 | | -target_include_directories(foonathan_array INTERFACE include) |
45 | | -if(MSVC) |
46 | | - target_compile_definitions(foonathan_array INTERFACE "-D_SCL_SECURE_NO_WARNINGS") |
| 46 | +add_library(foonathan::foonathan_array ALIAS foonathan_array) |
| 47 | +target_sources(foonathan_array INTERFACE $<BUILD_INTERFACE:${detail_header_files} ${header_files}>) |
| 48 | +target_compile_features(foonathan_array INTERFACE cxx_std_11) |
| 49 | +target_include_directories(foonathan_array SYSTEM INTERFACE |
| 50 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/> |
| 51 | + $<INSTALL_INTERFACE:include/>) |
| 52 | + |
| 53 | +# installation |
| 54 | +if(NOT dependency_via_submodule) |
| 55 | + include(CMakePackageConfigHelpers) |
| 56 | + write_basic_package_version_file(foonathan_array-config-version.cmake COMPATIBILITY ExactVersion) |
| 57 | + install(TARGETS foonathan_array EXPORT foonathan_array_targets |
| 58 | + INCLUDES DESTINATION include) |
| 59 | + install(EXPORT foonathan_array_targets |
| 60 | + DESTINATION lib/cmake/foonathan_array |
| 61 | + FILE foonathan_array-targets.cmake |
| 62 | + NAMESPACE foonathan::) |
| 63 | + install(DIRECTORY include/ |
| 64 | + DESTINATION include) |
| 65 | + install(FILES foonathan_array-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/foonathan_array-config-version.cmake |
| 66 | + DESTINATION lib/cmake/foonathan_array) |
| 67 | +else() |
| 68 | + message(STATUS "Dependency installed via submodule, installation unavailable") |
47 | 69 | endif() |
48 | 70 |
|
49 | | -if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) |
| 71 | +# subdirectories |
| 72 | +option(FOONATHAN_ARRAY_BUILD_TEST "build tests of foonathan/array" OFF) |
| 73 | +if(${FOONATHAN_ARRAY_BUILD_TEST} OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)) |
50 | 74 | enable_testing() |
51 | 75 | add_subdirectory(test) |
52 | 76 | endif() |
0 commit comments