Skip to content

Commit

Permalink
Merge pull request #16 from terrylyons/cmake-files
Browse files Browse the repository at this point in the history
Added basic cmake file
  • Loading branch information
inakleinbottle authored Jun 24, 2021
2 parents f65bc30 + cfd01fb commit 55b994c
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
72 changes: 72 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

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()
14 changes: 14 additions & 0 deletions LibalgebraConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 55b994c

Please sign in to comment.