-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
84 lines (67 loc) · 2.57 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
81
82
83
# Requires at least CMake 3.5
cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
# Header-only library
##############################
# Project name
##############################
set(ELK_WARNING_SUPPRESSOR_VERSION_MAJOR 0)
set(ELK_WARNING_SUPPRESSOR_VERSION_MINOR 1)
set(ELK_WARNING_SUPPRESSOR_VERSION_REVISION 0)
project(elk-warning-suppressor
DESCRIPTION "Cross-platform, header-only library to help suppress warnings in included 3rd party's code"
HOMEPAGE_URL "https://github.com/elk-audio/elk-warning-suppressor"
LANGUAGES CXX
VERSION ${ELK_WARNING_SUPPRESSOR_VERSION_MAJOR}.${ELK_WARNING_SUPPRESSOR_VERSION_MINOR}.${ELK_WARNING_SUPPRESSOR_VERSION_REVISION}
)
##############################
# Setting build options
##############################
option(BUILD_DEMO "Build demo" OFF)
##############################
# Set additional compiler option
##############################
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Create a header-only library (INTERFACE)
# Create alias elk::warningSuppressor so other projects can link to it
add_library(${PROJECT_NAME} INTERFACE)
add_library(elk::warningSuppressor ALIAS ${PROJECT_NAME})
# Specify where the header-only library is
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/elk-warning-suppressor>
$<INSTALL_INTERFACE:include/elk-warning-suppressor>
)
set_target_properties(${PROJECT_NAME}
PROPERTIES EXPORT_NAME warningSuppressor
)
# Demo
if (BUILD_DEMO)
add_subdirectory(Examples)
endif ()
#############
# Install #
#############
# Create install target for library
install(TARGETS ${PROJECT_NAME}
EXPORT elkWarningSuppressorConfig
PUBLIC_HEADER DESTINATION include/elk-warning-suppressor
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/elk-warning-suppressor DESTINATION include)
# Generate config version file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/elk-warning-suppressorConfigVersion.cmake
VERSION ${ELK_WARNING_SUPPRESSOR_VERSION_MAJOR}.${ELK_WARNING_SUPPRESSOR_VERSION_MINOR}.${ELK_WARNING_SUPPRESSOR_VERSION_REVISION}
COMPATIBILITY SameMinorVersion
)
# Generate install config file
install(EXPORT elkWarningSuppressorConfig
FILE elk-warning-suppressorConfig.cmake
DESTINATION lib/cmake/elk-warning-suppressor
NAMESPACE elk::
)
# Install config version file
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/elk-warning-suppressorConfigVersion.cmake
DESTINATION lib/cmake/elk-warning-suppressor
)