|
| 1 | +cmake_minimum_required(VERSION 3.22) |
| 2 | + |
| 3 | +project( |
| 4 | + simde |
| 5 | + DESCRIPTION |
| 6 | + "Implementations of SIMD instruction sets for systems which don't natively support them." |
| 7 | + HOMEPAGE_URL "https://github.com/simd-everywhere/simde" |
| 8 | + LANGUAGES C CXX |
| 9 | + VERSION 0.8.4 |
| 10 | +) |
| 11 | + |
| 12 | +# Options |
| 13 | +option(SIMDE_TEST_CMAKE_PACKAGING "Test cmake packaging" ${PROJECT_IS_TOP_LEVEL}) |
| 14 | + |
| 15 | +# The main simde library |
| 16 | +add_library(simde INTERFACE) |
| 17 | +add_library(simde::simde ALIAS simde) |
| 18 | + |
| 19 | +target_compile_features(simde INTERFACE c_std_99) |
| 20 | + |
| 21 | +target_include_directories( |
| 22 | + simde |
| 23 | + INTERFACE |
| 24 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> |
| 25 | + $<INSTALL_INTERFACE:include> |
| 26 | +) |
| 27 | + |
| 28 | +if(SIMDE_TEST_CMAKE_PACKAGING) |
| 29 | + include(CTest) |
| 30 | + enable_testing() |
| 31 | + add_subdirectory(test/cmake-packaging) |
| 32 | +endif() |
| 33 | + |
| 34 | +include(GNUInstallDirs) |
| 35 | + |
| 36 | +# Install headers |
| 37 | +install(DIRECTORY simde DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
| 38 | + |
| 39 | +# Export targets |
| 40 | +install(TARGETS simde EXPORT simde-targets) |
| 41 | + |
| 42 | +# Package Configuration |
| 43 | +include(CMakePackageConfigHelpers) |
| 44 | + |
| 45 | +write_basic_package_version_file( |
| 46 | + ${CMAKE_CURRENT_BINARY_DIR}/simde-config-version.cmake |
| 47 | + VERSION ${PROJECT_VERSION} |
| 48 | + COMPATIBILITY SameMajorVersion |
| 49 | +) |
| 50 | + |
| 51 | +file( |
| 52 | + WRITE |
| 53 | + ${CMAKE_CURRENT_BINARY_DIR}/simde-config.cmake.in |
| 54 | + "@PACKAGE_INIT@\n" |
| 55 | + "include(\"\${CMAKE_CURRENT_LIST_DIR}/simde-config-targets.cmake\")\n" |
| 56 | +) |
| 57 | + |
| 58 | +configure_package_config_file( |
| 59 | + ${CMAKE_CURRENT_BINARY_DIR}/simde-config.cmake.in |
| 60 | + ${CMAKE_CURRENT_BINARY_DIR}/simde-config.cmake |
| 61 | + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/simde |
| 62 | + NO_SET_AND_CHECK_MACRO |
| 63 | + NO_CHECK_REQUIRED_COMPONENTS_MACRO |
| 64 | +) |
| 65 | + |
| 66 | +install( |
| 67 | + FILES |
| 68 | + ${CMAKE_CURRENT_BINARY_DIR}/simde-config.cmake |
| 69 | + ${CMAKE_CURRENT_BINARY_DIR}/simde-config-version.cmake |
| 70 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/simde |
| 71 | +) |
| 72 | + |
| 73 | +install( |
| 74 | + EXPORT simde-targets |
| 75 | + FILE simde-config-targets.cmake |
| 76 | + NAMESPACE simde:: |
| 77 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/simde |
| 78 | +) |
0 commit comments