| 1 |
# |
| 2 |
# Licensed to the Apache Software Foundation (ASF) under one |
| 3 |
# or more contributor license agreements. See the NOTICE file |
| 4 |
# distributed with this work for additional information |
| 5 |
# regarding copyright ownership. The ASF licenses this file |
| 6 |
# to you under the Apache License, Version 2.0 (the |
| 7 |
# "License"); you may not use this file except in compliance |
| 8 |
# with the License. You may obtain a copy of the License at |
| 9 |
# |
| 10 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
# |
| 12 |
# Unless required by applicable law or agreed to in writing, |
| 13 |
# software distributed under the License is distributed on an |
| 14 |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 |
# KIND, either express or implied. See the License for the |
| 16 |
# specific language governing permissions and limitations |
| 17 |
# under the License. |
| 18 |
# |
| 19 |
|
| •20 |
cmake_minimum_required (VERSION 3.16) |
| 21 |
|
| 22 |
project (Proton C) |
| 23 |
|
| 24 |
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/tools/cmake/Modules") |
| 25 |
set (CMAKE_THREAD_PREFER_PTHREAD TRUE) |
| 26 |
|
| 27 |
include (CTest) |
| 28 |
include (CheckLanguage) |
| 29 |
include (CheckLibraryExists) |
| 30 |
include (CheckSymbolExists) |
| 31 |
include (CheckPythonModule) |
| 32 |
|
| 33 |
find_package (OpenSSL) |
| 34 |
find_package (Threads) |
| 35 |
find_package (SWIG) |
| 36 |
find_package (CyrusSASL) |
| 37 |
|
| 38 |
# This setting mirrors FindPythonInterp behavior on Windows/macOS, which did not consult registry/frameworks first.` |
| 39 |
if (NOT DEFINED Python_FIND_REGISTRY) |
| 40 |
set(Python_FIND_REGISTRY "LAST") |
| 41 |
endif () |
| 42 |
if (NOT DEFINED Python_FIND_FRAMEWORK) |
| 43 |
set(Python_FIND_FRAMEWORK "LAST") |
| 44 |
endif () |
| 45 |
find_package(Python 3.6 |
| 46 |
REQUIRED COMPONENTS Interpreter |
| 47 |
OPTIONAL_COMPONENTS Development) |
| 48 |
|
| 49 |
include(tests/PNAddTest.cmake) |
| 50 |
|
| 51 |
# Set up runtime checks (valgrind, sanitizers etc.) |
| 52 |
include(tests/RuntimeCheck.cmake) |
| 53 |
|
| 54 |
## Set up so that find_package(Proton) & find_package(ProtonCpp) work in the build tree |
| 55 |
set (Proton_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/config) |
| 56 |
set (ProtonCpp_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/config) |
| 57 |
|
| 58 |
## Variables used across components |
| 59 |
|
| 60 |
set (PN_ENV_SCRIPT "${Python_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/scripts/env.py") |
| 61 |
set (PN_C_INCLUDE_DIR "${CMAKE_BINARY_DIR}/c/include") |
| 62 |
set (PN_C_LIBRARY_DIR "${CMAKE_BINARY_DIR}/c") |
| 63 |
set (PN_C_SOURCE_DIR "${CMAKE_BINARY_DIR}/c/src") |
| 64 |
|
| 65 |
## C |
| 66 |
if (DEFINED CMAKE_C_COMPILE_FEATURES) |
| 67 |
set(CMAKE_C_STANDARD 99) |
| 68 |
set(CMAKE_C_EXTENSIONS OFF) |
| 69 |
set(CMAKE_C_STANDARD_REQUIRED ON) |
| 70 |
else() |
| 71 |
set (C_STANDARD_GNU -std=c99) |
| 72 |
set (C_EXTENDED_GNU -std=gnu99) |
| 73 |
set (C_STANDARD_Clang -std=c99) |
| 74 |
set (C_EXTENDED_Clang -std=gnu99) |
| 75 |
endif() |
| 76 |
|
| 77 |
set (C_STANDARD_FLAGS ${C_STANDARD_${CMAKE_C_COMPILER_ID}}) |
| 78 |
set (C_EXTENDED_FLAGS ${C_EXTENDED_${CMAKE_C_COMPILER_ID}}) |
| 79 |
|
| 80 |
## C++ |
| 81 |
check_language (CXX) |
| 82 |
if (CMAKE_CXX_COMPILER) |
| 83 |
enable_language(CXX) |
| 84 |
|
| 85 |
# This effectively checks for cmake version 3.1 or later |
| 86 |
if (DEFINED CMAKE_CXX_COMPILE_FEATURES) |
| 87 |
set(CMAKE_CXX_STANDARD 11) |
| 88 |
set(CMAKE_CXX_EXTENSIONS OFF) |
| 89 |
else () |
| 90 |
# This can only be a fairly old version of Linux in practice |
| 91 |
set(CXX_STANDARD "-std=c++11") |
| 92 |
endif () |
| 93 |
endif() |
| 94 |
|
| 95 |
# Build static C and C++ libraries in addition to shared libraries. |
| 96 |
option(BUILD_STATIC_LIBS "Build static libraries as well as shared libraries" OFF) |
| 97 |
|
| 98 |
if (CMAKE_CONFIGURATION_TYPES) |
| 99 |
# There is no single "build type"... |
| 100 |
message(STATUS "Build types are ${CMAKE_CONFIGURATION_TYPES}") |
| 101 |
else (CMAKE_CONFIGURATION_TYPES) |
| 102 |
# There is a single build configuration |
| 103 |
# If the build type is not set then set the default |
| 104 |
if (NOT CMAKE_BUILD_TYPE) |
| 105 |
set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING |
| 106 |
"Build type: Debug, Release, RelWithDebInfo, MinSizeRel or Coverage (default RelWithDebInfo)" FORCE) |
| 107 |
endif () |
| 108 |
|
| 109 |
# Set up extra coverage analysis options for gcc and clang |
| 110 |
if (CMAKE_COMPILER_IS_GNUCC) |
| 111 |
set (CMAKE_C_FLAGS_COVERAGE "-g -O0 --coverage") |
| 112 |
set (CMAKE_CXX_FLAGS_COVERAGE "-g -O0 --coverage") |
| 113 |
set (CMAKE_EXE_LINKER_FLAGS_COVERAGE "--coverage") |
| 114 |
set (CMAKE_MODULE_LINKER_FLAGS_COVERAGE "--coverage") |
| 115 |
set (CMAKE_SHARED_LINKER_FLAGS_COVERAGE "--coverage") |
| 116 |
mark_as_advanced( |
| 117 |
CMAKE_C_FLAGS_COVERAGE CMAKE_CXX_FLAGS_COVERAGE |
| 118 |
CMAKE_EXE_LINKER_FLAGS_COVERAGE CMAKE_MODULE_LINKER_FLAGS_COVERAGE |
| 119 |
CMAKE_SHARED_LINKER_FLAGS_COVERAGE) |
| 120 |
endif() |
| 121 |
|
| 122 |
if (CMAKE_BUILD_TYPE MATCHES "Deb") |
| 123 |
set (has_debug_symbols " (has debug symbols)") |
| 124 |
endif (CMAKE_BUILD_TYPE MATCHES "Deb") |
| 125 |
message(STATUS "Build type is \"${CMAKE_BUILD_TYPE}\"${has_debug_symbols}") |
| 126 |
endif (CMAKE_CONFIGURATION_TYPES) |
| 127 |
|
| 128 |
# Add coverage target if we're building for test coverage |
| 129 |
if (CMAKE_BUILD_TYPE MATCHES "Coverage") |
| 130 |
make_directory(coverage_results) |
| 131 |
add_custom_target(coverage |
| 132 |
WORKING_DIRECTORY ./coverage_results |
| 133 |
COMMAND ${CMAKE_SOURCE_DIR}/scripts/record-coverage.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) |
| 134 |
endif() |
| 135 |
|
| 136 |
# Try to keep any platform specific overrides together here: |
| 137 |
|
| 138 |
# MacOS has a bunch of differences in build tools and process and so we have to turn some things |
| 139 |
# off if building there: |
| 140 |
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") |
| 141 |
set (NOENABLE_WARNING_ERROR ON) |
| 142 |
set (LIB_SUFFIX "") |
| 143 |
endif () |
| 144 |
|
| 145 |
# Benchmarks should be disabled by default |
| 146 |
set (NOENABLE_BENCHMARKS ON) |
| 147 |
|
| 148 |
# Add options here called <whatever> they will turn into "ENABLE_<whatever" and can be |
| 149 |
# overridden on a platform specific basis above by NOENABLE_<whatever> |
| 150 |
set (OPTIONS WARNING_ERROR UNDEFINED_ERROR LINKTIME_OPTIMIZATION HIDE_UNEXPORTED_SYMBOLS FUZZ_TESTING BENCHMARKS) |
| 151 |
|
| 152 |
foreach (OPTION ${OPTIONS}) |
| 153 |
if (NOT NOENABLE_${OPTION}) |
| 154 |
set ("DEFAULT_${OPTION}" ON) |
| 155 |
endif () |
| 156 |
endforeach (OPTION) |
| 157 |
|
| 158 |
# And add the option here too with help text |
| 159 |
option(ENABLE_WARNING_ERROR "Consider compiler warnings to be errors" ${DEFAULT_WARNING_ERROR}) |
| 160 |
option(ENABLE_UNDEFINED_ERROR "Check for unresolved library symbols" ${DEFAULT_UNDEFINED_ERROR}) |
| 161 |
option(ENABLE_LINKTIME_OPTIMIZATION "Perform link time optimization" ${DEFAULT_LINKTIME_OPTIMIZATION}) |
| 162 |
option(ENABLE_HIDE_UNEXPORTED_SYMBOLS "Only export library symbols that are explicitly requested" ${DEFAULT_HIDE_UNEXPORTED_SYMBOLS}) |
| 163 |
option(ENABLE_FUZZ_TESTING "Enable building fuzzers and regression testing with libFuzzer" ${DEFAULT_FUZZ_TESTING}) |
| 164 |
option(ENABLE_BENCHMARKS "Enable building and running benchmarks with Google Benchmark" ${DEFAULT_BENCHMARKS}) |
| 165 |
|
| 166 |
option(BUILD_EXAMPLES "Enable building example programs" ON) |
| 167 |
option(BUILD_TLS "Enable building separate TLS library for Proton raw connections" OFF) |
| 168 |
|
| 169 |
# Set any additional compiler specific flags |
| 170 |
set (LTO_GNU "-flto -fno-fat-lto-objects") |
| 171 |
set (LTO_Clang "-flto=thin") |
| 172 |
set (LTO_MSVC "/GL") |
| 173 |
set (LINK_LTO_GNU "-flto -fno-fat-lto-objects") |
| 174 |
set (LINK_LTO_Clang "-flto=thin") |
| 175 |
set (LINK_LTO_MSVC "/LTCG") |
| 176 |
|
| 177 |
set (WERROR_GNU "-Werror") |
| 178 |
set (WERROR_Clang "-Werror") |
| 179 |
set (WERROR_MSVC "") |
| 180 |
|
| 181 |
set (COMMON_WARNING_GNU "-Wall -pedantic-errors") |
| 182 |
set (COMMON_WARNING_Clang "-Wall -pedantic") |
| 183 |
set (COMMON_WARNING_MSVC "") |
| 184 |
|
| 185 |
set (CC_WARNING_GNU "-Wno-unused-parameter -Wstrict-prototypes -Wvla -Wsign-compare -Wwrite-strings") |
| 186 |
set (CC_WARNING_Clang "-Wno-unused-parameter -Wstrict-prototypes -Wvla -Wsign-compare -Wwrite-strings") |
| 187 |
set (CC_WARNING_MSVC "/wd4244 /wd4267 /wd4800 /wd4996") |
| 188 |
|
| 189 |
set (CXX_WARNING_GNU "") |
| 190 |
set (CXX_WARNING_Clang "") |
| 191 |
set (CXX_WARNING_MSVC "") |
| 192 |
|
| 193 |
set (CATCH_UNDEFINED_Linux "-Wl,--no-undefined") |
| 194 |
set (CATCH_UNDEFINED_FreeBSD "-Wl,--no-undefined") |
| 195 |
set (CATCH_UNDEFINED_Darwin "-Wl,-undefined,error") |
| 196 |
set (CATCH_UNDEFINED_Windows "") |
| 197 |
|
| 198 |
set (HIDE_SYMBOLS_GNU "-fvisibility=hidden") |
| 199 |
set (HIDE_SYMBOLS_Clang "-fvisibility=hidden") |
| 200 |
set (HIDE_SYMBOLS_SunPro "-xldscope=hidden") |
| 201 |
|
| 202 |
if (ENABLE_LINKTIME_OPTIMIZATION) |
| 203 |
set (LTO ${LTO_${CMAKE_C_COMPILER_ID}}) |
| 204 |
set (LINK_LTO ${LINK_LTO_${CMAKE_C_COMPILER_ID}}) |
| 205 |
endif (ENABLE_LINKTIME_OPTIMIZATION) |
| 206 |
|
| 207 |
if (ENABLE_WARNING_ERROR) |
| 208 |
set (WERROR ${WERROR_${CMAKE_C_COMPILER_ID}}) |
| 209 |
endif (ENABLE_WARNING_ERROR) |
| 210 |
|
| 211 |
if (ENABLE_UNDEFINED_ERROR) |
| 212 |
set (CATCH_UNDEFINED ${CATCH_UNDEFINED_${CMAKE_SYSTEM_NAME}}) |
| 213 |
endif (ENABLE_UNDEFINED_ERROR) |
| 214 |
|
| 215 |
if (ENABLE_HIDE_UNEXPORTED_SYMBOLS) |
| 216 |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${HIDE_SYMBOLS_${CMAKE_C_COMPILER_ID}}") |
| 217 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HIDE_SYMBOLS_${CMAKE_C_COMPILER_ID}}") |
| 218 |
endif (ENABLE_HIDE_UNEXPORTED_SYMBOLS) |
| 219 |
|
| 220 |
set (COMMON_WARNING_FLAGS ${COMMON_WARNING_${CMAKE_C_COMPILER_ID}}) |
| 221 |
set (CXX_WARNING_FLAGS "${WERROR} ${COMMON_WARNING_FLAGS} ${CXX_WARNING_${CMAKE_C_COMPILER_ID}}") |
| 222 |
set (COMPILE_WARNING_FLAGS "${WERROR} ${COMMON_WARNING_FLAGS} ${CC_WARNING_${CMAKE_C_COMPILER_ID}}") |
| 223 |
|
| 224 |
if (MSVC) |
| 225 |
set(CMAKE_DEBUG_POSTFIX "d") |
| 226 |
endif (MSVC) |
| 227 |
|
| 228 |
file(READ VERSION.txt PN_VERSION_FILE) |
| 229 |
string(STRIP ${PN_VERSION_FILE} PN_VERSION_LINE) |
| 230 |
string(REPLACE "-" ";" PN_VERSION_SPLIT "${PN_VERSION_LINE}") |
| 231 |
list(GET PN_VERSION_SPLIT 0 PN_VERSION_CLEAN) |
| 232 |
list(REMOVE_AT PN_VERSION_SPLIT 0) |
| 233 |
string(REPLACE ";" "-" PN_VERSION_QUALIFIER "${PN_VERSION_SPLIT}") |
| 234 |
string(REGEX MATCHALL "[0-9]+" PN_VERSION_LIST "${PN_VERSION_CLEAN}") |
| 235 |
|
| 236 |
list(GET PN_VERSION_LIST 0 PN_VERSION_MAJOR) |
| 237 |
list(GET PN_VERSION_LIST 1 PN_VERSION_MINOR) |
| 238 |
|
| 239 |
list(LENGTH PN_VERSION_LIST PN_VERSION_LENGTH) |
| 240 |
if (${PN_VERSION_LENGTH} GREATER 2) |
| 241 |
list(GET PN_VERSION_LIST 2 PN_VERSION_POINT) |
| 242 |
set (PN_VERSION "${PN_VERSION_MAJOR}.${PN_VERSION_MINOR}.${PN_VERSION_POINT}") |
| 243 |
else() |
| 244 |
set (PN_VERSION_POINT 0) |
| 245 |
set (PN_VERSION "${PN_VERSION_MAJOR}.${PN_VERSION_MINOR}") |
| 246 |
endif() |
| 247 |
|
| 248 |
message(STATUS "PN_VERSION: ${PN_VERSION} (${PN_VERSION_QUALIFIER})") |
| 249 |
|
| 250 |
# In rpm builds the build sets some variables: |
| 251 |
# CMAKE_INSTALL_PREFIX - this is a standard cmake variable |
| 252 |
# INCLUDE_INSTALL_DIR |
| 253 |
# LIB_INSTALL_DIR |
| 254 |
# SYSCONF_INSTALL_DIR |
| 255 |
# SHARE_INSTALL_DIR |
| 256 |
# So make these cached variables and the specific variables non cached |
| 257 |
# and derived from them. |
| 258 |
|
| 259 |
if (NOT DEFINED LIB_SUFFIX) |
| 260 |
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) |
| 261 |
if ("${LIB64}" STREQUAL "TRUE" AND ${CMAKE_SIZEOF_VOID_P} STREQUAL "8") |
| 262 |
set(LIB_SUFFIX 64) |
| 263 |
else() |
| 264 |
set(LIB_SUFFIX "") |
| 265 |
endif() |
| 266 |
endif() |
| 267 |
|
| 268 |
# Start of variables used during install |
| 269 |
set (INCLUDE_INSTALL_DIR include CACHE PATH "Include file directory") |
| 270 |
set (LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Library object file directory") |
| 271 |
set (SYSCONF_INSTALL_DIR etc CACHE PATH "System read only configuration directory") |
| 272 |
set (SHARE_INSTALL_DIR share CACHE PATH "Shared read only data directory") |
| 273 |
set (MAN_INSTALL_DIR share/man CACHE PATH "Manpage directory") |
| 274 |
|
| 275 |
mark_as_advanced (INCLUDE_INSTALL_DIR LIB_INSTALL_DIR SYSCONF_INSTALL_DIR SHARE_INSTALL_DIR MAN_INSTALL_DIR) |
| 276 |
|
| 277 |
# Sets variable NAME to contain relative path from ROOT to VALUE |
| 278 |
# if VALUE is already relative, it does nothing |
| 279 |
macro (pn_relative_install_dir NAME ROOT VALUE) |
| 280 |
if (IS_ABSOLUTE ${VALUE}) |
| 281 |
file(RELATIVE_PATH "${NAME}" "${ROOT}" "${VALUE}") |
| 282 |
else () |
| 283 |
set (${NAME} "${VALUE}") |
| 284 |
endif () |
| 285 |
endmacro () |
| 286 |
|
| 287 |
pn_relative_install_dir (INCLUDEDIR "${CMAKE_INSTALL_PREFIX}" "${INCLUDE_INSTALL_DIR}") |
| 288 |
pn_relative_install_dir (LIBDIR "${CMAKE_INSTALL_PREFIX}" "${LIB_INSTALL_DIR}") |
| 289 |
|
| 290 |
## LANGUAGE BINDINGS |
| 291 |
|
| 292 |
# Default directory for language bindings not being installed into |
| 293 |
# system specified locations. |
| 294 |
set (BINDINGS_DIR ${LIB_INSTALL_DIR}/proton/bindings) |
| 295 |
|
| 296 |
set (SYSINSTALL_BINDINGS OFF CACHE BOOL "If SYSINSTALL_BINDINGS is OFF then proton bindings will be installed underneath ${BINDINGS_DIR} and each user will need to modify their interpreter configuration to load the appropriate binding. If SYSINSTALL_BINDINGS is ON, then each language interpreter will be queried for the appropriate directory and proton bindings will be installed and available system wide with no additional per user configuration.") |
| 297 |
|
| 298 |
set (BINDING_LANGS PYTHON RUBY) |
| 299 |
|
| 300 |
foreach (LANG ${BINDING_LANGS}) |
| 301 |
set (SYSINSTALL_${LANG} OFF CACHE BOOL "Install ${LANG} bindings into interpreter specified location.") |
| 302 |
if (SYSINSTALL_BINDINGS OR SYSINSTALL_${LANG}) |
| 303 |
set (CHECK_SYSINSTALL_${LANG} ON) |
| 304 |
else () |
| 305 |
set (CHECK_SYSINSTALL_${LANG} OFF) |
| 306 |
endif () |
| 307 |
endforeach() |
| 308 |
|
| 309 |
set (PROTON_SHARE ${SHARE_INSTALL_DIR}/proton) |
| 310 |
# End of variables used during install |
| 311 |
|
| 312 |
# Set result to a native search path - used by examples and binding tests. |
| 313 |
# args after result are directories or search paths. |
| 314 |
macro(set_search_path result) |
| 315 |
set(${result} ${ARGN}) |
| 316 |
if (UNIX) |
| 317 |
string(REPLACE ";" ":" ${result} "${${result}}") # native search path separators. |
| 318 |
endif() |
| 319 |
file(TO_NATIVE_PATH "${${result}}" ${result}) # native slash separators |
| 320 |
endmacro() |
| 321 |
|
| 322 |
if (CMAKE_SYSTEM_NAME STREQUAL Windows) |
| 323 |
# CMake uses semicolon as list separator. Change ';'->'\;' |
| 324 |
function(to_native_path path result) |
| 325 |
file (TO_NATIVE_PATH "${path}" path) |
| 326 |
string (REPLACE ";" "\;" path "${path}") |
| 327 |
# without this, ...;last\dir\ would later combine with list separator ; into \; |
| 328 |
set (${result} "${path}\;" PARENT_SCOPE) |
| 329 |
endfunction() |
| 330 |
else (CMAKE_SYSTEM_NAME STREQUAL Windows) |
| 331 |
# Just change ';'->':' |
| 332 |
function(to_native_path path result) |
| 333 |
file (TO_NATIVE_PATH "${path}" path) |
| 334 |
string (REPLACE ";" ":" path "${path}") |
| 335 |
set (${result} "${path}" PARENT_SCOPE) |
| 336 |
endfunction() |
| 337 |
endif (CMAKE_SYSTEM_NAME STREQUAL Windows) |
| 338 |
|
| 339 |
add_custom_target(docs) |
| 340 |
add_custom_target(doc DEPENDS docs) |
| 341 |
|
| 342 |
# Note: Process bindings after the source lists have been defined so |
| 343 |
# the bindings can reference them. |
| 344 |
add_subdirectory(c) |
| 345 |
|
| 346 |
# Add bindings that do not require swig here - the directory name must be the same as the binding name |
| 347 |
# See below for swig bindings |
| 348 |
set(BINDINGS cpp go) |
| 349 |
|
| 350 |
if (CMAKE_CXX_COMPILER) |
| 351 |
set (DEFAULT_CPP ON) |
| 352 |
endif() |
| 353 |
|
| 354 |
# Prerequisites for Go |
| 355 |
find_program(GO_EXE go) |
| 356 |
mark_as_advanced(GO_EXE) |
| 357 |
if (GO_EXE) |
| 358 |
set (DEFAULT_GO ON) |
| 359 |
if(WIN32 OR RUNTIME_CHECK) |
| 360 |
# Go on windows requires gcc tool chain |
| 361 |
# Go does not work with C-based runtime checkers. |
| 362 |
set (DEFAULT_GO OFF) |
| 363 |
endif() |
| 364 |
endif (GO_EXE) |
| 365 |
|
| 366 |
if(SWIG_FOUND) |
| 367 |
# Add any new swig bindings here - the directory name must be the same as the binding name |
| 368 |
list(APPEND BINDINGS python ruby) |
| 369 |
|
| 370 |
include(UseSWIG) |
| •371 |
|
| 372 |
# All swig modules should include ${PROTON_HEADERS} in SWIG_MODULE_<name>_EXTRA_DEPS |
| 373 |
file(GLOB PROTON_HEADERS "${CMAKE_SOURCE_DIR}/c/include/proton/*.h") |
| •374 |
# All swig modules should include ${BINDING_DEPS} or ${BINDING_DEPS_FULL} in swig_link_libraries |
| 375 |
set (BINDING_DEPS qpid-proton-core) |
| 376 |
set (BINDING_DEPS_FULL qpid-proton) |
| 377 |
|
| 378 |
# Add a block here to detect the prerequisites to build each language binding: |
| 379 |
# |
| 380 |
# If the prerequisites for the binding are present set a variable called |
| 381 |
# DEFAULT_{uppercase name of binding} to ON |
| 382 |
|
| 383 |
# Prerequisites for Python wrapper: |
| 384 |
if (Python_Development_FOUND) |
| 385 |
set (DEFAULT_PYTHON ON) |
| 386 |
endif () |
| 387 |
|
| 388 |
# Prerequisites for Ruby: |
| 389 |
find_package(Ruby) |
| 390 |
if (RUBY_FOUND) |
| 391 |
set (DEFAULT_RUBY ON) |
| 392 |
endif () |
| 393 |
endif() |
| 394 |
|
| 395 |
# To kick-start a build with just a few bindings enabled by default, e.g. ruby and go: |
| 396 |
# |
| 397 |
# cmake -DBUILD_BINDINGS="ruby;go" |
| 398 |
# |
| 399 |
# This is only used when CMakeCache.txt is first created, after that set the normal |
| 400 |
# BUILD_XXX variables to enable/disable bindings. |
| 401 |
# |
| 402 |
if (NOT DEFINED BUILD_BINDINGS) |
| 403 |
set(BUILD_BINDINGS "${BINDINGS}") |
| 404 |
endif() |
| 405 |
|
| 406 |
foreach(BINDING ${BINDINGS}) |
| 407 |
string(TOUPPER ${BINDING} UBINDING) |
| 408 |
list(FIND BUILD_BINDINGS ${BINDING} N) |
| 409 |
if(NOBUILD_${UBINDING} OR ( N EQUAL -1 ) ) # Over-ridden or not on the BUILD_BINDINGS list |
| 410 |
set(DEFAULT_${UBINDING} OFF) |
| 411 |
endif() |
| 412 |
option(BUILD_${UBINDING} "Build ${BINDING} language binding" ${DEFAULT_${UBINDING}}) |
| 413 |
if (BUILD_${UBINDING}) |
| 414 |
add_subdirectory(${BINDING}) |
| 415 |
endif () |
| 416 |
endforeach(BINDING) |
| 417 |
|
| 418 |
unset(BUILD_BINDINGS CACHE) # Remove from cache, only relevant when creating the initial cache. |
| 419 |
|
| 420 |
install (FILES LICENSE.txt README.md tests/share/CMakeLists.txt DESTINATION ${PROTON_SHARE}) |
| 421 |
install (FILES tests/share/examples-README.md RENAME README.md DESTINATION ${PROTON_SHARE}/examples) |
| 422 |
install (DIRECTORY tests DESTINATION ${PROTON_SHARE} PATTERN share EXCLUDE) |
| 423 |
|
| 424 |
# Generate test environment settings |
| 425 |
configure_file(${CMAKE_SOURCE_DIR}/misc/config.sh.in |
| 426 |
${CMAKE_BINARY_DIR}/config.sh @ONLY) |
| 427 |
configure_file(${CMAKE_SOURCE_DIR}/misc/config.bat.in |
| 428 |
${CMAKE_BINARY_DIR}/config.bat @ONLY) |
| 429 |
|
| 430 |
if (BUILD_EXAMPLES) |
| 431 |
add_subdirectory(tests/examples) |
| 432 |
endif (BUILD_EXAMPLES) |