-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
83 lines (58 loc) · 1.84 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
cmake_minimum_required( VERSION 3.19 )
set( CFGFILE_VERSION "0.2.11" )
option( BUILD_EXAMPLES "Build examples? Default ON." ON )
option( BUILD_TESTS "Build tests? Default ON." ON )
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE "Release"
CACHE STRING "Choose the type of build."
FORCE)
endif( NOT CMAKE_BUILD_TYPE )
SET( CMAKE_CXX_STANDARD 14 )
SET( CMAKE_CXX_STANDARD_REQUIRED ON )
project( cfgfile )
add_subdirectory( generator )
if( ${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME} )
if( BUILD_EXAMPLES )
add_subdirectory( example )
endif()
if( BUILD_TESTS )
enable_testing()
add_subdirectory( tests )
endif()
file( GLOB_RECURSE SRC cfgfile/* )
add_library( cfgfile INTERFACE ${SRC} )
add_library( cfgfile::cfgfile ALIAS cfgfile )
target_include_directories( cfgfile INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
install( DIRECTORY cfgfile
DESTINATION include
)
install( TARGETS cfgfile
EXPORT cfgfile-targets
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
INCLUDES DESTINATION include
)
install( EXPORT cfgfile-targets
DESTINATION lib/cmake/cfgfile
NAMESPACE cfgfile::
)
include( CMakePackageConfigHelpers )
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/cfgfile-config-version.cmake"
VERSION ${CFGFILE_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file( cfgfile-config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/cfgfile-config.cmake"
INSTALL_DESTINATION lib/cmake/cfgfile )
install( FILES ${PROJECT_BINARY_DIR}/cfgfile-config.cmake
${PROJECT_BINARY_DIR}/cfgfile-config-version.cmake
DESTINATION lib/cmake/cfgfile
)
else()
set( cfgfile_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE )
endif( ${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME} )