diff --git a/CMakeLists.txt b/CMakeLists.txt index 7383bfa..30b2889 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,46 @@ add_library(smath INTERFACE) target_include_directories(smath INTERFACE ${CMAKE_SOURCE_DIR}/include) add_library(smath::smath ALIAS smath) +include(CMakePackageConfigHelpers) +install(TARGETS smath + EXPORT smathTargets +) +install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include) + +install(EXPORT smathTargets + NAMESPACE smath:: + FILE smathTargets.cmake + DESTINATION lib/cmake/smath +) + +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/smathConfigVersion.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) + +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/smathConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/smathConfig.cmake" + INSTALL_DESTINATION "lib/cmake/smath" +) + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/smath.pc.in" + "${CMAKE_CURRENT_BINARY_DIR}/smath.pc" + @ONLY +) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/smath.pc" + DESTINATION lib/pkgconfig +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/smathConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/smathConfigVersion.cmake" + DESTINATION lib/cmake/smath +) + if(BUILD_EXAMPLES) file(GLOB EXAMPLE_SOURCES "${CMAKE_SOURCE_DIR}/examples/*.cpp") foreach(EXAMPLE_FILE ${EXAMPLE_SOURCES}) diff --git a/cmake/smath.pc.in b/cmake/smath.pc.in new file mode 100644 index 0000000..f6fac4d --- /dev/null +++ b/cmake/smath.pc.in @@ -0,0 +1,8 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +includedir=${prefix}/include + +Name: smath +Description: Simple header-only math library +Version: @PROJECT_VERSION@ +Cflags: -I${includedir} +Libs: diff --git a/cmake/smathConfig.cmake.in b/cmake/smathConfig.cmake.in new file mode 100644 index 0000000..7364358 --- /dev/null +++ b/cmake/smathConfig.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/smathTargets.cmake") +check_required_components(smath)