Moved add_definitions in cmake files to /src/ so that all components and tests use the same definitions when compiling sources

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
This commit is contained in:
Dennis Potman 2020-02-26 10:17:01 +01:00 committed by eboasson
parent b3c5a8d4fc
commit 323de40cba
6 changed files with 44 additions and 46 deletions

View file

@ -16,11 +16,47 @@ 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()
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
# trouble on some older CMake versions that otherwise work fine, so provide an option to avoid
# all OpenSSL related things.
#
# Historically the option was DDSC_ENABLE_OPENSSL so make some allowance for those who are
# currently relying on it.
option(ENABLE_SSL "Enable openssl support" ON)
option(DDSC_ENABLE_OPENSSL "Deprecated: please use ENABLE_SSL instead" ON)
if(NOT DDSC_ENABLE_OPENSSL)
message(ERROR "DDSC_ENABLE_OPENSSL is deprecated, please use ENABLE_SSL instead")
set(ENABLE_SSL OFF)
endif()
if(ENABLE_SSL)
find_package(OpenSSL)
if(OPENSSL_FOUND)
add_definitions(-DDDSI_INCLUDE_SSL)
message(STATUS "Building with OpenSSL support")
else()
message(STATUS "Building without OpenSSL support")
endif()
endif()
# Support the OMG DDS Security within ddsc adds quite a bit of code.
option(ENABLE_SECURITY "Enable OMG DDS Security support" ON)
if(NOT ENABLE_SECURITY)
message(STATUS "Building without OMG DDS Security support")
else()
add_definitions(-DDDSI_INCLUDE_SECURITY)
endif()
option(ENABLE_LIFESPAN "Enable Lifespan QoS support" ON)
if(ENABLE_LIFESPAN)
add_definitions(-DDDSI_INCLUDE_LIFESPAN)
endif()
option(ENABLE_DEADLINE_MISSED "Enable Deadline Missed QoS support" ON)
if(ENABLE_DEADLINE_MISSED)
add_definitions(-DDDSI_INCLUDE_DEADLINE_MISSED)
endif()
add_subdirectory(ddsrt)

View file

@ -25,47 +25,15 @@ else()
add_library(ddsc)
endif()
add_definitions(-DDDSI_INCLUDE_NETWORK_PARTITIONS -DDDSI_INCLUDE_SSM)
option(ENABLE_LIFESPAN "Enable Lifespan QoS support" ON)
if(ENABLE_LIFESPAN)
add_definitions(-DDDSI_INCLUDE_LIFESPAN)
endif()
option(ENABLE_DEADLINE_MISSED "Enable Deadline Missed QoS support" ON)
if(ENABLE_DEADLINE_MISSED)
add_definitions(-DDDSI_INCLUDE_DEADLINE_MISSED)
endif()
# OpenSSL is huge, raising the RSS by 1MB or so, and moreover find_package(OpenSSL) causes
# trouble on some older CMake versions that otherwise work fine, so provide an option to avoid
# all OpenSSL related things.
#
# Historically the option was DDSC_ENABLE_OPENSSL so make some allowance for those who are
# currently relying on it.
option(ENABLE_SSL "Enable openssl support" ON)
option(DDSC_ENABLE_OPENSSL "Deprecated: please use ENABLE_SSL instead" ON)
if(NOT DDSC_ENABLE_OPENSSL)
message(ERROR "DDSC_ENABLE_OPENSSL is deprecated, please use ENABLE_SSL instead")
set(ENABLE_SSL OFF)
endif()
if(ENABLE_SSL)
find_package(OpenSSL)
if(OPENSSL_FOUND)
add_definitions(-DDDSI_INCLUDE_SSL)
if(ENABLE_SSL AND OPENSSL_FOUND)
target_link_libraries(ddsc PRIVATE OpenSSL::SSL)
if(CMAKE_GENERATOR MATCHES "Visual Studio")
set_target_properties(ddsc PROPERTIES LINK_FLAGS "/ignore:4099")
endif()
message(STATUS "Building with OpenSSL support")
else()
message(STATUS "Building without OpenSSL support")
endif()
endif()
# Support the OMG DDS Security within ddsc adds quite a bit of code.
if(ENABLE_SECURITY)
add_definitions(-DDDSI_INCLUDE_SECURITY)
target_link_libraries(ddsc PRIVATE security_core)
target_include_directories(
ddsc PUBLIC

View file

@ -11,12 +11,11 @@
#
cmake_minimum_required(VERSION 3.7)
if( ENABLE_SECURITY )
add_definitions(-DDDSI_INCLUDE_SECURITY)
if(ENABLE_SECURITY)
add_subdirectory(api)
add_subdirectory(core)
if ( ENABLE_SSL)
if(ENABLE_SSL)
add_subdirectory(builtin_plugins)
endif()
endif()

View file

@ -11,8 +11,6 @@
#
include (GenerateExportHeader)
find_package(OpenSSL)
PREPEND(srcs_accesscontrol "${CMAKE_CURRENT_LIST_DIR}/src"
access_control_objects.c
access_control_parser.c

View file

@ -11,8 +11,6 @@
#
include (GenerateExportHeader)
find_package(OpenSSL)
PREPEND(srcs_cryptographic "${CMAKE_CURRENT_LIST_DIR}/src"
crypto_cipher.c
crypto_key_exchange

View file

@ -10,7 +10,6 @@
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
include(CUnit)
find_package(OpenSSL)
set(security_auth_test_sources
"common/src/loader.c"