This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
146 lines (119 loc) · 5.25 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
cmake_minimum_required(VERSION 3.8.2) # cxx_std_11
project(ddl_library VERSION 4.4.1)
# Disable extensions here and require the chosen CMAKE_CXX_STANDARD
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
# if Conan is used, we have to include the generated file and doing some basic setup
if(CONAN_COMPILER)
if ( EXISTS ${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
elseif ( EXISTS ${CMAKE_CURRENT_BINARY_DIR}/../conanbuildinfo.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/../conanbuildinfo.cmake)
elseif ( EXISTS ${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo_multi.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo_multi.cmake)
elseif ( EXISTS ${CMAKE_CURRENT_BINARY_DIR}/../conanbuildinfo_multi.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/../conanbuildinfo_multi.cmake)
else()
message(FATAL_ERROR "Conan build info can't be found.")
endif()
if(CORTEX_WORKSPACE)
conan_basic_setup(TARGETS)
else()
conan_basic_setup(TARGETS NO_OUTPUT_DIRS)
endif()
endif()
# Options #################################################
option(ddl_cmake_enable_tests
"Enable tests - requires googletest (default: OFF)"
OFF)
option(ddl_cmake_enable_installation
"Enable installation of the ddl library to CMAKE_INSTALL_PREFIX (default: OFF)"
OFF)
option(ddl_cmake_enable_ddl_generator_tools
"Enable building of the two tools ddl2header and header2ddl (default: OFF)"
OFF)
# End Options #############################################
# Disable extensions here and require the chosen CMAKE_CXX_STANDARD (coming from e.g. Conan)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Check for default install prefix and cmake build type (UNIX)
include(./cmake/check_cmake_install_prefix.cmake)
include(./cmake/check_cmake_build_type.cmake)
# Enable multicore compilation on Windows
include(./cmake/enable_multicore_compilation.cmake)
# Use integrated debug symbols on Windows (avoiding PDBs)
include(./cmake/use_integrated_debug_symbols.cmake)
# Set library name conventions
include(./cmake/set_library_naming_conventions.cmake)
# Enable folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Add a_util dependency
find_package(a_util 5.6.1 REQUIRED)
# Include sources
include(./ddlrepresentation/pkg_ddlrepresentation.sources)
include(./codec/codec.sources)
include(./serialization/serialization.sources)
include(./mapping/mapping.sources)
add_library(ddl STATIC
${DDLREPRESENTATION_CPP}
${CODEC_CPP}
${SERIALIZATION_CPP}
${MAPPING_CPP}
${DDLREPRESENTATION_H}
${CODEC_H}
${SERIALIZATION_H}
${MAPPING_CONFIGURATION_H}
${MAPPING_ENGINE_H}
${MAPPING_H}
ddl.h
legacy_error_macros.h
)
set_target_properties(ddl PROPERTIES FOLDER ddl)
target_include_directories(ddl PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
# a_util is public since its part of the ddl api
target_link_libraries(ddl PUBLIC a_util)
target_compile_features(ddl INTERFACE cxx_std_11) # C++11 for self and dependants
target_compile_options(ddl PRIVATE $<$<CXX_COMPILER_ID:GNU>:-fPIC>)
# Create version config
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/cmake/ddl-config-version.cmake
COMPATIBILITY AnyNewerVersion)
configure_file(cmake/ddl-config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/ddl/ddlConfig.cmake"
)
if(ddl_cmake_enable_tests)
set(ddl_cmake_integrated_tests ON)
enable_testing()
add_subdirectory(test)
endif()
if(ddl_cmake_enable_ddl_generator_tools)
add_subdirectory(ddlgenerators)
endif()
if(ddl_cmake_enable_installation)
install(TARGETS ddl ARCHIVE DESTINATION lib)
install(FILES ${DDLREPRESENTATION_INSTALL} DESTINATION include/${DDLREPRESENTATION_DIR})
install(FILES ${CODEC_INSTALL} DESTINATION include/${CODEC_DIR})
install(FILES ${SERIALIZATION_INSTALL} DESTINATION include/${SERIALIZATION_DIR})
install(FILES ${MAPPING_CONFIGURATION_INSTALL} DESTINATION include/${MAPPING_DIR}/configuration)
install(FILES ${MAPPING_ENGINE_INSTALL} DESTINATION include/${MAPPING_DIR}/engine)
install(FILES ${MAPPING_INSTALL} DESTINATION include/${MAPPING_DIR})
install(FILES ddl.h legacy_error_macros.h DESTINATION include)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/ddl-config-version.cmake DESTINATION cmake)
configure_file(cmake/ddl-config.cmake.in ${CMAKE_INSTALL_PREFIX}/cmake/ddl-config.cmake @ONLY)
install(FILES cmake/migrate_to_ddl_4_1.cmake cmake/ddl4.1_replacements.txt cmake/migrate_to_ddl_4_1.sh.in DESTINATION cmake)
install(FILES README.md DESTINATION .)
else()
# This allows a host product to use find_package from within the build-tree
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cmake/ddl-config.cmake "")
endif()
##this enables a post-install command, so this must be "Last Dir Standing"!!!
add_subdirectory(doc)
# License Information must be delivered anyway!
install(FILES doc/license/MPL2.0.txt DESTINATION ./)
install(FILES doc/license/MPL2.0.txt DESTINATION doc/license)
install(FILES doc/input/used_licenses.md DESTINATION doc/license)
install(FILES doc/input/mpl.md DESTINATION doc/license)