-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
67 lines (49 loc) · 1.92 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
cmake_minimum_required(VERSION 3.12)
project(SugarPP
VERSION 0.0.1
HOMEPAGE_URL "https://github.com/HO-COOH/SugarPP"
LANGUAGES CXX)
# ---- Warning guard ----
# Protect dependents from this project's warnings if the guard isn't disabled
set(sugarpp_warning_guard "SYSTEM")
if(SugarPP_INCLUDE_WITHOUT_SYSTEM)
set(sugarpp_warning_guard "")
endif()
# ---- Declare library ----
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library(SugarPP INTERFACE)
add_library(SugarPP::SugarPP ALIAS SugarPP)
target_include_directories(SugarPP
${sugarpp_warning_guard}
INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>")
# target_compile_features(SugarPP INTERFACE cxx_std_17) # makes it hard to develop because the IDE does not know to use C++17 standard
option(SugarPPUseNamespace "Make SugarPP inside namespace SugarPP" ON)
if(SugarPPUseNamespace)
target_compile_definitions(SugarPP INTERFACE SugarPPNamespace)
endif()
# ---- Install ----
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
set(sugarpp_directory "SugarPP-${PROJECT_VERSION}")
set(sugarpp_include_directory "${CMAKE_INSTALL_INCLUDEDIR}/${sugarpp_directory}")
install(TARGETS SugarPP
EXPORT SugarPPTargets
INCLUDES DESTINATION "${sugarpp_include_directory}")
set(sugarpp_install_cmakedir
"${CMAKE_INSTALL_LIBDIR}/cmake/${sugarpp_directory}")
write_basic_package_version_file(
SugarPPConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT)
install(EXPORT SugarPPTargets
FILE SugarPPConfig.cmake
NAMESPACE SugarPP::
DESTINATION "${sugarpp_install_cmakedir}")
install(FILES
"${PROJECT_BINARY_DIR}/SugarPPConfigVersion.cmake"
DESTINATION "${sugarpp_install_cmakedir}")
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/"
DESTINATION "${sugarpp_include_directory}")