-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
80 lines (66 loc) · 2 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# SLB
#
# Copyright Michael Park, 2017
# Copyright Agustin Berge, 2017
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 3.0)
project(SLB CXX)
include(CTest)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
option(SLB_BUILD_TESTING "Compile with unit tests." ON)
else()
option(SLB_BUILD_TESTING "Compile with unit tests." OFF)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Build
add_library(SLB INTERFACE)
target_include_directories(SLB INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
add_library(SLB::SLB ALIAS SLB)
# Test
if(BUILD_TESTING AND SLB_BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
# Config
include(CMakePackageConfigHelpers)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/slb-config.cmake.in [[
# SLB
#
# Copyright Michael Park, 2017
# Copyright Agustin Berge, 2017
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
# - Config file for SLB
#
# SLB_INCLUDE_DIRS - include directories
# SLB_LIBRARIES - libraries to link against
#
# The following `IMPORTED` target is also defined:
#
# SLB::SLB
@PACKAGE_INIT@
include(${CMAKE_CURRENT_LIST_DIR}/slb-targets.cmake)
get_target_property(SLB_INCLUDE_DIRS SLB::SLB INTERFACE_INCLUDE_DIRECTORIES)
set_and_check(SLB_INCLUDE_DIRS "${SLB_INCLUDE_DIRS}")
set(SLB_LIBRARIES SLB::SLB)
]])
configure_package_config_file(
${CMAKE_CURRENT_BINARY_DIR}/slb-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/slb-config.cmake
INSTALL_DESTINATION lib/cmake/slb
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
# Install
install(DIRECTORY include/slb DESTINATION include)
install(TARGETS SLB EXPORT _targets)
install(EXPORT _targets
DESTINATION lib/cmake/slb
NAMESPACE SLB::
FILE slb-targets.cmake)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/slb-config.cmake
DESTINATION lib/cmake/slb)