-
Notifications
You must be signed in to change notification settings - Fork 197
/
CMakeLists.txt
76 lines (57 loc) · 2.05 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
cmake_minimum_required(VERSION 3.13.0)
project(ads)
find_package(Threads)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(COMPILE_OPTIONS
-pedantic
-Wall
-Wextra
)
add_definitions(-D_GNU_SOURCE)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Compiler flags and definitions for Visual Studio come here
endif()
add_definitions(-DCONFIG_DEFAULT_LOGLEVEL=1)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
add_subdirectory(AdsLib)
add_subdirectory(AdsTool)
add_subdirectory(AdsLibTest)
add_subdirectory(example)
# Install library
include(GenerateExportHeader)
set(ADSLIB_VERSION 0.0.20)
set_property(TARGET ads PROPERTY VERSION ${ADSLIB_VERSION})
set_property(TARGET ads PROPERTY SOVERSION 3)
# export library (either static or shared depending on BUILD_SHARED_LIBS)
install(TARGETS ads AdsTool
EXPORT adsTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AdsLib/ DESTINATION include/ads/
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h")
set(cmake_configfile_install lib/cmake/ads)
set(target_install_dest_name "${cmake_configfile_install}/adsTargets.cmake")
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/adsConfigVersion.cmake"
VERSION ${ADSLIB_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/adsConfig.cmake"
INSTALL_DESTINATION "${cmake_configfile_install}"
PATH_VARS target_install_dest_name)
install(EXPORT adsTargets
FILE adsTargets.cmake
NAMESPACE ads::
DESTINATION "${cmake_configfile_install}"
EXPORT_LINK_INTERFACE_LIBRARIES)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/adsConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/adsConfigVersion.cmake"
DESTINATION "${cmake_configfile_install}")