|
1 | | -cmake_minimum_required (VERSION 3.2.0 FATAL_ERROR) |
| 1 | +cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) |
2 | 2 |
|
3 | | -project (taocpp-operators VERSION 1.1.1 LANGUAGES CXX) |
| 3 | +project(taocpp-operators VERSION 1.2.0 LANGUAGES CXX) |
| 4 | + |
| 5 | +if(${PROJECT_NAME}_FOUND) |
| 6 | + # multiple versions can't co-exist |
| 7 | + if(NOT ${PROJECT_NAME}_VERSION STREQUAL ${PROJECT_VERSION}) |
| 8 | + message(FATAL_ERROR "Multiple mismatched versions") |
| 9 | + endif() |
| 10 | + |
| 11 | + # only include if this is the first include |
| 12 | + if(NOT ${PROJECT_NAME}_DIR STREQUAL "${PROJECT_BINARY_DIR}") |
| 13 | + return() |
| 14 | + endif() |
| 15 | +endif() |
| 16 | + |
| 17 | +# keep track of version |
| 18 | +set(${PROJECT_NAME}_FOUND TRUE CACHE BOOL "" FORCE) |
| 19 | +set(${PROJECT_NAME}_VERSION "${PROJECT_VERSION}" CACHE STRING "" FORCE) |
| 20 | +set(${PROJECT_NAME}_DIR "${PROJECT_BINARY_DIR}" CACHE PATH "" FORCE) |
| 21 | + |
| 22 | +mark_as_advanced(${PROJECT_NAME}_FOUND) |
| 23 | +mark_as_advanced(${PROJECT_NAME}_VERSION) |
| 24 | +mark_as_advanced(${PROJECT_NAME}_DIR) |
4 | 25 |
|
5 | 26 | # installation directories |
6 | | -set (TAOCPP_OPERATORS_INSTALL_INCLUDE_DIR "include" CACHE STRING "The installation include directory") |
7 | | -set (TAOCPP_OPERATORS_INSTALL_DOC_DIR "share/doc/tao/operators" CACHE STRING "The installation doc directory") |
8 | | -set (TAOCPP_OPERATORS_INSTALL_CMAKE_DIR "share/taocpp-operators/cmake" CACHE STRING "The installation cmake directory") |
| 27 | +set(TAOCPP_OPERATORS_INSTALL_INCLUDE_DIR "include" CACHE STRING "The installation include directory") |
| 28 | +set(TAOCPP_OPERATORS_INSTALL_DOC_DIR "share/doc/tao/operators" CACHE STRING "The installation doc directory") |
| 29 | +set(TAOCPP_OPERATORS_INSTALL_CMAKE_DIR "share/taocpp-operators/cmake" CACHE STRING "The installation cmake directory") |
9 | 30 |
|
10 | 31 | # define a header-only library |
11 | | -add_library (operators INTERFACE) |
12 | | -add_library (taocpp::operators ALIAS operators) |
13 | | -target_include_directories (operators INTERFACE |
| 32 | +add_library(taocpp-operators INTERFACE) |
| 33 | +add_library(taocpp::operators ALIAS taocpp-operators) |
| 34 | +target_include_directories(taocpp-operators INTERFACE |
14 | 35 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
15 | 36 | $<INSTALL_INTERFACE:${TAOCPP_OPERATORS_INSTALL_INCLUDE_DIR}> |
16 | 37 | ) |
17 | 38 |
|
18 | 39 | # features used by taocpp/operators |
19 | | -target_compile_features (operators INTERFACE |
| 40 | +target_compile_features(taocpp-operators INTERFACE |
20 | 41 | cxx_constexpr |
21 | 42 | cxx_noexcept |
22 | 43 | cxx_rvalue_references |
23 | 44 | ) |
24 | 45 |
|
25 | 46 | # testing |
26 | | -enable_testing () |
27 | | -option (TAOCPP_OPERATORS_BUILD_TESTS "Build test programs" ON) |
28 | | -if (TAOCPP_OPERATORS_BUILD_TESTS) |
29 | | - add_subdirectory (src/test/operators) |
30 | | -endif () |
| 47 | +enable_testing() |
| 48 | +option(TAOCPP_OPERATORS_BUILD_TESTS "Build test programs" ON) |
| 49 | +if(TAOCPP_OPERATORS_BUILD_TESTS) |
| 50 | + add_subdirectory(src/test/operators) |
| 51 | +endif() |
| 52 | + |
| 53 | +# make package findable |
| 54 | +configure_file(cmake/dummy-config.cmake.in taocpp-operators-config.cmake @ONLY) |
31 | 55 |
|
32 | 56 | # install and export target |
33 | | -install (TARGETS operators EXPORT operators-targets) |
| 57 | +install(TARGETS taocpp-operators EXPORT taocpp-operators-targets) |
34 | 58 |
|
35 | | -install (EXPORT operators-targets |
| 59 | +install(EXPORT taocpp-operators-targets |
36 | 60 | FILE taocpp-operators-config.cmake |
37 | 61 | NAMESPACE taocpp:: |
38 | 62 | DESTINATION ${TAOCPP_OPERATORS_INSTALL_CMAKE_DIR} |
39 | 63 | ) |
40 | 64 |
|
41 | | -install (DIRECTORY include/ DESTINATION ${TAOCPP_OPERATORS_INSTALL_INCLUDE_DIR}) |
42 | | -install (FILES LICENSE DESTINATION ${TAOCPP_OPERATORS_INSTALL_DOC_DIR}) |
| 65 | +install(DIRECTORY include/ DESTINATION ${TAOCPP_OPERATORS_INSTALL_INCLUDE_DIR}) |
| 66 | +install(FILES LICENSE DESTINATION ${TAOCPP_OPERATORS_INSTALL_DOC_DIR}) |
0 commit comments