Generate header with compile-time features

Currently:

* DDS_HAS_SECURITY for DDS Security support
* DDS_HAS_LIFESPAN for lifespan QoS support
* DDS_HAS_DEADLINE_MISSED for "deadline missed" event support

These are defined to 1 if support for the feature is included in the
build and left undefined if it isn't.

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2020-03-25 10:39:44 +01:00 committed by eboasson
parent d4e9300dad
commit ecbd585f12
3 changed files with 45 additions and 0 deletions

View file

@ -16,6 +16,26 @@ if(NOT ${PROJECT_NAME} STREQUAL "CycloneDDS")
message(FATAL_ERROR "Top-level CMakeLists.txt was moved to the top-level directory. Please run cmake on ${dir} instead of ${CMAKE_CURRENT_LIST_DIR}")
endif()
# Generate a header file listing compile-time options relevant to the API. Define to
# "1" if enabled so that the generated features.h ends up having either
#
# - #define DDS_HAS_SECURITY 1
# or
# - /* #undef DDS_HAS_SECURITY */
#
# which caters both for those who prefer #ifdef DDS_HAS_SECURITY and for those who prefer
# #if DDS_HAS_SECURITY.
if(ENABLE_SECURITY)
set(DDS_HAS_SECURITY "1")
endif()
if(ENABLE_LIFESPAN)
set(DDS_HAS_LIFESPAN "1")
endif()
if(ENABLE_DEADLINE_MISSED)
set(DDS_HAS_DEADLINE_MISSED "1")
endif()
configure_file(features.h.in "${CMAKE_CURRENT_BINARY_DIR}/core/include/dds/features.h")
add_definitions(-DDDSI_INCLUDE_NETWORK_PARTITIONS -DDDSI_INCLUDE_SSM)
# OpenSSL is huge, raising the RSS by 1MB or so, and moreover find_package(OpenSSL) causes

View file

@ -25,6 +25,7 @@
#endif
#include "dds/export.h"
#include "dds/features.h"
/**
* Handle to an entity. A valid entity handle will always have a positive

24
src/features.h.in Normal file
View file

@ -0,0 +1,24 @@
/*
* Copyright(c) 2020 ADLINK Technology Limited and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef _DDS_PUBLIC_FEATURES_H_
#define _DDS_PUBLIC_FEATURES_H_
/* Whether or not support for DDS Security is included */
#cmakedefine DDS_HAS_SECURITY @DDS_HAS_SECURITY@
/* Whether or not support for the lifespan QoS is included */
#cmakedefine DDS_HAS_LIFESPAN @DDS_HAS_LIFESPAN@
/* Whether or not support for generating "deadline missed" events is included */
#cmakedefine DDS_HAS_DEADLINE_MISSED @DDS_HAS_DEADLINE_MISSED@
#endif