-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
52 lines (40 loc) · 1.24 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
cmake_minimum_required(VERSION 3.28)
project(MyLibrary LANGUAGES CXX VERSION 0.0.1)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_library(mylibrary STATIC)
add_library(mylib::mylibrary ALIAS mylibrary)
target_compile_features(mylibrary PUBLIC cxx_std_20)
target_compile_options(mylibrary PUBLIC
$<$<COMPILE_LANG_AND_ID:CXX,Clang,GNU,ARMClang,AppleClang,LLC>:
$<BUILD_INTERFACE:-Werror;-Wall;-Wextra;-Wshadow;-Wunused;-pedantic>>
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:$<BUILD_INTERFACE:/W3>>
)
add_subdirectory(source/)
include(FetchContent)
option(MYLIB_BUILD_TESTS "Enable building tests" ON)
if(MYLIB_BUILD_TESTS)
add_subdirectory(tests/)
endif()
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
install(
TARGETS mylibrary
EXPORT mylibrary-targets
FILE_SET CXX_MODULES
DESTINATION ${CMAKE_INSTALL_LIBDIR}/mylibrary
)
install(
EXPORT mylibrary-targets
FILE mylibrary-config.cmake
NAMESPACE mylib::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mylibrary
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/mylibrary-config-version.cmake
COMPATIBILITY SameMajorVersion
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/mylibrary-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mylibrary
)
include(CPack)