Skip to content

Commit 82ee622

Browse files
authored
Merge pull request #127 from mablanchard/mblanchard/cmake
Add top-level CMake script with install rules
2 parents f5ca2f6 + 8bc161e commit 82ee622

3 files changed

Lines changed: 86 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
project(fastor VERSION 0.6.4)
3+
4+
option(BUILD_TESTING "Build the testing tree." ON)
5+
6+
set(FASTOR_SOURCE_DIR "${fastor_SOURCE_DIR}")
7+
set(FASTOR_BINARY_DIR "${fastor_BINARY_DIR}")
8+
set(FASTOR_INCLUDE_DIR "${fastor_SOURCE_DIR}")
9+
10+
include(GNUInstallDirs)
11+
12+
set(FASTOR_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
13+
set(FASTOR_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
14+
set(FASTOR_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_DATADIR}/cmake/Fastor")
15+
set(FASTOR_INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_DATADIR}/pkgconfig")
16+
17+
add_library(Fastor INTERFACE)
18+
19+
target_include_directories(
20+
Fastor INTERFACE
21+
$<BUILD_INTERFACE:${FASTOR_INCLUDE_DIR}>
22+
$<INSTALL_INTERFACE:${FASTOR_INSTALL_INCLUDE_DIR}>)
23+
24+
if(BUILD_TESTING)
25+
enable_testing()
26+
27+
add_subdirectory(tests)
28+
endif()
29+
30+
install(
31+
DIRECTORY "${FASTOR_INCLUDE_DIR}/Fastor"
32+
DESTINATION "${FASTOR_INSTALL_INCLUDE_DIR}")
33+
install(
34+
TARGETS Fastor
35+
EXPORT FastorTargets)
36+
37+
export(
38+
TARGETS Fastor
39+
NAMESPACE Fastor::
40+
FILE "${FASTOR_BINARY_DIR}/FastorTargets.cmake")
41+
export(PACKAGE Fastor)
42+
install(
43+
EXPORT FastorTargets
44+
NAMESPACE Fastor::
45+
DESTINATION "${FASTOR_INSTALL_CMAKE_DIR}")
46+
47+
include(CMakePackageConfigHelpers)
48+
configure_package_config_file(
49+
"${FASTOR_SOURCE_DIR}/data/FastorConfig.cmake.in"
50+
"${FASTOR_BINARY_DIR}/FastorConfig.cmake"
51+
INSTALL_DESTINATION "${FASTOR_INSTALL_CMAKE_DIR}"
52+
PATH_VARS FASTOR_INSTALL_INCLUDE_DIR)
53+
write_basic_package_version_file(
54+
"${FASTOR_BINARY_DIR}/FastorConfigVersion.cmake"
55+
VERSION ${fastor_VERSION}
56+
COMPATIBILITY SameMajorVersion
57+
ARCH_INDEPENDENT)
58+
install(
59+
FILES
60+
"${FASTOR_BINARY_DIR}/FastorConfigVersion.cmake"
61+
"${FASTOR_BINARY_DIR}/FastorConfig.cmake"
62+
DESTINATION "${FASTOR_INSTALL_CMAKE_DIR}")
63+
64+
configure_file(
65+
"${FASTOR_SOURCE_DIR}/data/fastor.pc.in"
66+
"${FASTOR_BINARY_DIR}/fastor.pc" @ONLY)
67+
install(
68+
FILES "${FASTOR_BINARY_DIR}/fastor.pc"
69+
DESTINATION "${FASTOR_INSTALL_PKGCONFIG_DIR}")

data/FastorConfig.cmake.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@PACKAGE_INIT@
2+
3+
include("${CMAKE_CURRENT_LIST_DIR}/FastorTargets.cmake")
4+
5+
set_and_check(Fastor_INCLUDE_DIR "@PACKAGE_FASTOR_INSTALL_INCLUDE_DIR@")
6+
7+
check_required_components(Fastor)

data/fastor.pc.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
prefix=@FASTOR_INSTALL_PREFIX@
2+
exec_prefix=${prefix}
3+
includedir=${prefix}/@FASTOR_INSTALL_INCLUDE_DIR@
4+
5+
Name: Fastor
6+
Description: A light-weight high performance tensor algebra framework for modern C++
7+
URL: https://github.com/romeric/Fastor
8+
Version: @PROJECT_VERSION@
9+
Cflags: -I${includedir}
10+

0 commit comments

Comments
 (0)