-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
65 lines (49 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
cmake_minimum_required(VERSION 3.17)
project(XPathReader VERSION 1.4.0
DESCRIPTION "XPath Reader for use by QDP++"
LANGUAGES CXX)
# Basic Includes
include( GNUInstallDirs)
include( CMakePackageConfigHelpers)
# Enable Address address and undefined behaviour sanitizers
option(XPathReader_ENABLE_SANITIZERS "Enable Address and Undefined Behaviour Sanitizers" OFF)
# Find LibXML2
find_package(LibXml2 REQUIRED)
# Create xpath_reader_config_internal.h
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/xpath_reader_config_internal.h.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/include/xpath_reader_config_internal.h)
# Mark file for installation
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/include/xpath_reader_config_internal.h DESTINATION include)
# Deal with Sanitizer
if( XPathReader_ENABLE_SANITIZERS )
include(cmake/CheckSanitizeOpts.cmake)
check_sanitizer_options( "${XPathReader_ENABLE_SANITIZERS}" XPathReader_SANITIZER_OPTS )
message(STATUS "XPathReader: Setting Sanitizer options: ${XPathReader_SANITIZER_OPTS}")
endif()
# Configure Lib and Example
add_subdirectory(lib)
add_subdirectory(examples)
# install the headers
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
DESTINATION .
FILES_MATCHING PATTERN "*.h")
# generate the version file for the config file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/XPathReaderConfigVersion.cmake"
VERSION "${XPathReader_VERSION_MAJOR}.${XPathReader_VERSION_MINOR}"
COMPATIBILITY AnyNewerVersion
)
# Create a Package Config file.
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/XPathReaderConfig.cmake"
INSTALL_DESTINATION lib/cmake/XPathReader
)
# install it
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/XPathReaderConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/XPathReaderConfigVersion.cmake
DESTINATION lib/cmake/XPathReader
)
# export package. Does nothing by default, but
# can have uses in specially set up configurations
export(PACKAGE XPathReader)