-
Notifications
You must be signed in to change notification settings - Fork 204
/
CMakeLists.txt
85 lines (67 loc) · 2.94 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
84
85
#===============================================================================
cmake_minimum_required (VERSION 3.12)
project ("AudioFile" VERSION 1.1.2
DESCRIPTION "A simple C++ library for reading and writing audio files."
HOMEPAGE_URL "https://github.com/adamstark/AudioFile")
#===============================================================================
include (GNUInstallDirs)
#===============================================================================
option (BUILD_TESTS "Build tests" ON)
option (BUILD_EXAMPLES "Build examples" ON)
#===============================================================================
set (AUDIOFILE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/AudioFile.h)
source_group (TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${AUDIOFILE_SOURCES})
add_library (${PROJECT_NAME} INTERFACE ${AUDIOFILE_SOURCES})
#===============================================================================
target_include_directories (${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
#===============================================================================
target_compile_features (${PROJECT_NAME} INTERFACE cxx_std_17)
#===============================================================================
if (BUILD_EXAMPLES)
add_subdirectory (examples)
endif ()
if (BUILD_TESTS)
enable_testing()
add_subdirectory (tests)
endif ()
#===============================================================================
set (CMAKE_SUPPRESS_REGENERATION true)
#===============================================================================
include (CMakePackageConfigHelpers)
install (TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install (FILES ${PROJECT_SOURCE_DIR}/AudioFile.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)
install (EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
file (WRITE ${PROJECT_BINARY_DIR}/Config.cmake.in
"@PACKAGE_INIT@\n\ninclude(\"\${CMAKE_CURRENT_LIST_DIR}/@[email protected]\")\n\ncheck_required_components(@PROJECT_NAME@)\n"
)
configure_package_config_file (
${PROJECT_BINARY_DIR}/Config.cmake.in
${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
write_basic_package_version_file (
${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT
)
install (FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)