diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..88fea615 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,72 @@ +cmake_minimum_required(VERSION 3.0) + +# I took this from CATCH2's (V2.0) CMakeList.txt because +# this seems to be close to our use case here. +# https://github.com/catchorg/Catch2/blob/v2.x/CMakeLists.txt +if(NOT DEFINED PROJECT_NAME) + set(NOT_SUBPROJECT ON) +else() + set(NOT_SUBPROJECT OFF) +endif() + + +project(Libalgebra VERSION 1.0.0) + + +include(GNUInstallDirs) + + +set(CMAKE_CXX_STANDARD 98) + +find_package(Boost REQUIRED COMPONENTS thread) + +add_library(Libalgebra INTERFACE) + +target_include_directories(Libalgebra + INTERFACE + $ + $ + ) + +add_library(Libalgebra::Libalgebra ALIAS Libalgebra) + +target_link_libraries(Libalgebra INTERFACE Boost::boost Boost::thread) + +if(NOT_SUBPROJECT) + install(TARGETS Libalgebra + EXPORT LibalgebraTargets + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) + + include(CMakePackageConfigHelpers) + set(LIBALGEBRA_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Libalgebra") + + message(STATUS "Writing cmake config file") + configure_package_config_file( + LibalgebraConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/LibalgebraConfig.cmake + INSTALL_DESTINATION ${LIBALGEBRA_CMAKE_CONFIG_DESTINATION} + PATH_VARS CMAKE_INSTALL_INCLUDEDIR + ) + + message(STATUS "Writing cmake config version file") + write_basic_package_version_file( + LibalgebraConfigVersion.cmake + VERSION ${PACKAGE_VERSION} + COMPATIBILITY SameMajorVersion + ARCH_INDEPENDENT + ) + + message(STATUS "Installing config files to ${LIBALGEBRA_CMAKE_CONFIG_DESTINATION}") + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/LibalgebraConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/LibalgebraConfigVersion.cmake + DESTINATION ${LIBALGEBRA_CMAKE_CONFIG_DESTINATION} + ) + + + install(EXPORT LibalgebraTargets + FILE LibalgebraTargets.cmake + NAMESPACE Libalgebra:: + DESTINATION lib/cmake/Libalgebra + ) +endif() \ No newline at end of file diff --git a/LibalgebraConfig.cmake.in b/LibalgebraConfig.cmake.in new file mode 100644 index 00000000..07a60f00 --- /dev/null +++ b/LibalgebraConfig.cmake.in @@ -0,0 +1,14 @@ +include(CMakeFindDependencyMacro) + +set(LIBALGEBRA_VERSION 1.0.0) + +@PACKAGE_INIT@ + +find_dependency(Boost COMPONENTS thread REQUIRED) + +set_and_check(LIBALGEBRA_INCLUDE_DIR "@CMAKE_INSTALL_INCLUDEDIR@") + + +include(${CMAKE_CURRENT_LIST_DIR}/LibalgebraTargets.cmake) + +check_required_components(Libalgebra) \ No newline at end of file