forked from OpenAssetIO/OpenAssetIO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
167 lines (144 loc) · 5.5 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# SPDX-License-Identifier: Apache-2.0
# Copyright 2013-2024 The Foundry Visionmongers Ltd
#----------------------------------------------------------------------
# Versioning
# Library ABI version
# This should be set to the major component of the last release version
# where the ABI changed.
set(_core_abi_version 1)
#----------------------------------------------------------------------
# Public headers
set(_public_header_source_root ${CMAKE_CURRENT_LIST_DIR}/include)
# Installation location for install phase.
# TODO(DF): When CMake 3.23 is released, use FILE_SET, which allows
# explicitly associating public headers with a target. Note that the
# PUBLIC_HEADER target property is not useful since it flattens the
# directory structure when installed.
install(
DIRECTORY
${_public_header_source_root}/openassetio
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}
)
#-----------------------------------------------------------------------
# Create core target
# Note: static vs. shared is auto-determined by CMake's built-in
# BUILD_SHARED_LIBS option.
# TODO(DF): Allow customising library name (e.g. suffix)? See OCIO.
add_library(openassetio-core)
add_library(${PROJECT_NAME}::openassetio-core ALIAS openassetio-core)
# Set good default target options.
openassetio_set_default_target_properties(openassetio-core)
# Set output artifact base filename.
set_target_properties(openassetio-core PROPERTIES OUTPUT_NAME openassetio)
# Add to the set of installable targets.
install(TARGETS openassetio-core EXPORT ${PROJECT_NAME}_EXPORTED_TARGETS)
if (WIN32)
# "TARGET_PDB_FILE is allowed only for targets with linker created
# artifacts"
if (BUILD_SHARED_LIBS)
install(
FILES $<TARGET_PDB_FILE:openassetio-core>
TYPE BIN
CONFIGURATIONS "Debug" "RelWithDebInfo"
)
endif ()
endif ()
#-----------------------------------------------------------------------
# Target dependencies
# Source file dependencies.
target_sources(
openassetio-core
PRIVATE
src/Context.cpp
src/errors/exceptionMessages.cpp
src/hostApi/HostInterface.cpp
src/hostApi/Manager.cpp
src/hostApi/ManagerConveniences.cpp
src/hostApi/ManagerFactory.cpp
src/hostApi/ManagerImplementationFactoryInterface.cpp
src/hostApi/EntityReferencePager.cpp
src/log/ConsoleLogger.cpp
src/log/LoggerInterface.cpp
src/log/SeverityFilter.cpp
src/managerApi/Host.cpp
src/managerApi/HostSession.cpp
src/managerApi/ManagerInterface.cpp
src/managerApi/EntityReferencePagerInterface.cpp
src/pluginSystem/CppPluginSystem.cpp
src/pluginSystem/CppPluginSystemManagerImplementationFactory.cpp
src/pluginSystem/CppPluginSystemManagerPlugin.cpp
src/pluginSystem/CppPluginSystemPlugin.cpp
src/pluginSystem/HybridPluginSystemManagerImplementationFactory.cpp
src/trait/TraitsData.cpp
src/utils/formatter.cpp
src/utils/ostream.cpp
src/utils/Regex.cpp
src/utils/path.cpp
src/utils/path/common.cpp
src/utils/path/windows.cpp
src/utils/path/windows/detail.cpp
src/utils/path/windows/pathTypes.cpp
src/utils/path/posix.cpp
src/utils/path/posix/detail.cpp
src/utils/substitute.cpp
)
# Public header dependency.
target_include_directories(openassetio-core
PUBLIC
# For generated export.h and version.hpp header.
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>"
# Use includes from source tree for building.
"$<BUILD_INTERFACE:${_public_header_source_root}>"
# Use includes from install tree for installed lib.
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_link_libraries(
openassetio-core
PRIVATE
# Header-only private dependencies:
$<BUILD_INTERFACE:tomlplusplus::tomlplusplus>
$<BUILD_INTERFACE:fmt::fmt-header-only>
# (Static) private library dependencies
ada::ada
PCRE2::8BIT
# For dlopen et al.
${CMAKE_DL_LIBS}
)
#-----------------------------------------------------------------------
# API export header
# Definition for export header, to use for versioned namespacing.
# TODO(DF): It may turn out this should go in a separate header. Also
# other projects have much more elaborate version headers. See OCIO
# (bundles version in export header) and OTIO (uses separate header),
# both of which include a long list of additional #defines.
set(_define_version
"#define OPENASSETIO_CORE_ABI_VERSION v${_core_abi_version}")
# TODO(DF): Allow customising namespace? See OCIO.
# Use CMake utility to generate the export header.
include(GenerateExportHeader)
generate_export_header(
openassetio-core
EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/openassetio/export.h
CUSTOM_CONTENT_FROM_VARIABLE _define_version
)
install(
FILES ${PROJECT_BINARY_DIR}/include/openassetio/export.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openassetio/
)
#----------------------------------------------------------------------
# Version header
# Create a version.hpp with the configured version nums from template
configure_file(${PROJECT_SOURCE_DIR}/cmake/templates/include/openassetio/version.hpp.in
${PROJECT_BINARY_DIR}/include/openassetio/version.hpp @ONLY)
install(
FILES ${PROJECT_BINARY_DIR}/include/openassetio/version.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openassetio/
)
#-----------------------------------------------------------------------
# Tests
if (OPENASSETIO_ENABLE_TESTS)
add_subdirectory(tests)
if (OPENASSETIO_ENABLE_TEST_ABI)
openassetio_add_abi_test_target(openassetio-core)
endif ()
endif ()