diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ee0b287..9e5f5c7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/core/ddsc/include/dds/dds.h b/src/core/ddsc/include/dds/dds.h index b50f1d0..aa2f139 100644 --- a/src/core/ddsc/include/dds/dds.h +++ b/src/core/ddsc/include/dds/dds.h @@ -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 diff --git a/src/features.h.in b/src/features.h.in new file mode 100644 index 0000000..636f19f --- /dev/null +++ b/src/features.h.in @@ -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