|
| 1 | +cmake_minimum_required(VERSION 3.10) |
| 2 | +project(pcg-cpp VERSION 0.9.1 LANGUAGES CXX) |
| 3 | + |
| 4 | +include(GNUInstallDirs) |
| 5 | +include(CMakePackageConfigHelpers) |
| 6 | + |
| 7 | +# Header-only library |
| 8 | +add_library(pcg-cpp INTERFACE) |
| 9 | +add_library(pcg_cpp::pcg_cpp ALIAS pcg-cpp) |
| 10 | + |
| 11 | +target_include_directories(pcg-cpp INTERFACE |
| 12 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 13 | + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> |
| 14 | +) |
| 15 | + |
| 16 | +target_compile_features(pcg-cpp INTERFACE cxx_std_11) |
| 17 | + |
| 18 | +# Options |
| 19 | +option(PCG_CPP_BUILD_SAMPLES "Build samples" ON) |
| 20 | +option(PCG_CPP_BUILD_TESTS "Build tests" ON) |
| 21 | + |
| 22 | +if(PCG_CPP_BUILD_TESTS) |
| 23 | + enable_testing() |
| 24 | +endif() |
| 25 | + |
| 26 | +if(PCG_CPP_BUILD_SAMPLES) |
| 27 | + add_subdirectory(sample) |
| 28 | +endif() |
| 29 | + |
| 30 | +if(PCG_CPP_BUILD_TESTS) |
| 31 | + add_subdirectory(test-high) |
| 32 | +endif() |
| 33 | + |
| 34 | +# Installation |
| 35 | +install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
| 36 | + |
| 37 | +install(TARGETS pcg-cpp EXPORT pcg-cppTargets) |
| 38 | +install(EXPORT pcg-cppTargets |
| 39 | + FILE pcg-cppTargets.cmake |
| 40 | + NAMESPACE pcg_cpp:: |
| 41 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcg-cpp |
| 42 | +) |
| 43 | + |
| 44 | +write_basic_package_version_file( |
| 45 | + "${CMAKE_CURRENT_BINARY_DIR}/pcg-cppConfigVersion.cmake" |
| 46 | + VERSION ${PROJECT_VERSION} |
| 47 | + COMPATIBILITY SameMajorVersion |
| 48 | +) |
| 49 | + |
| 50 | +configure_package_config_file( |
| 51 | + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/pcg-cppConfig.cmake.in" |
| 52 | + "${CMAKE_CURRENT_BINARY_DIR}/pcg-cppConfig.cmake" |
| 53 | + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcg-cpp |
| 54 | +) |
| 55 | + |
| 56 | +install(FILES |
| 57 | + "${CMAKE_CURRENT_BINARY_DIR}/pcg-cppConfig.cmake" |
| 58 | + "${CMAKE_CURRENT_BINARY_DIR}/pcg-cppConfigVersion.cmake" |
| 59 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcg-cpp |
| 60 | +) |
0 commit comments