From 322994fc5013715fe0953f97557c9fd39c20e4a1 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Mon, 19 Feb 2024 17:29:52 -0600 Subject: [PATCH 01/16] Move and rename cmake/config.h.in so it can be used more generally --- cmake/config.h.in | 8 -------- configure | 27 ++++++++++++++++++++++++++- dds/CMakeLists.txt | 7 +++++-- dds/DCPS/Definitions.h | 4 ++-- dds/DdsDcps.mpc | 1 + dds/config/.gitignore | 1 + dds/config/OpenDDSConfig.h.in | 14 ++++++++++++++ tools/scripts/show_build_config.pl | 19 +++++++++++++------ 8 files changed, 62 insertions(+), 19 deletions(-) delete mode 100644 cmake/config.h.in create mode 100644 dds/config/.gitignore create mode 100644 dds/config/OpenDDSConfig.h.in diff --git a/cmake/config.h.in b/cmake/config.h.in deleted file mode 100644 index ce9d6af60b8..00000000000 --- a/cmake/config.h.in +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef OPENDDS_DCPS_CONFIG_EXPORT_H -#define OPENDDS_DCPS_CONFIG_EXPORT_H - -#include - -#define OPENDDS_USES_AUTO_STATIC_INCLUDES 1 - -#endif diff --git a/configure b/configure index bcc0e826ce2..300deebec03 100755 --- a/configure +++ b/configure @@ -928,7 +928,7 @@ if (!$ace_src || !$tao_src) { } if (!-r $file) { - my $dl_msg = "Downloading $file from using"; + my $dl_msg = "Downloading $file from $url using"; $would_download = 1; eval { require LWP::UserAgent; @@ -1338,6 +1338,30 @@ EOT } } +sub write_opendds_configh { + my %buildEnv = %{shift()}; + my $CFGH = backup_and_open("$buildEnv{'DDS_ROOT'}/dds/config/OpenDDSConfig.h"); + my $CFGIN = new FileHandle; + open($CFGIN, 'dds/config/OpenDDSConfig.h.in') or die("Can't open OpenDDSConfig.h.in for reading: $!\nStopped"); + + sub replace_value { + my $var = shift; + return '0' if $var eq 'OPENDDS_USES_AUTO_STATIC_INCLUDES'; + return 'UNDEFINED'; + } + + while (<$CFGIN>) { + s/@(\w+)@/replace_value($1)/e; + print $CFGH $_; + } + + $CFGIN->close; + $CFGH->close; + print "Wrote $buildEnv{'DDS_ROOT'}/dds/config/OpenDDSConfig.h\n" + if $opts{'verbose'}; + dump_and_unlink($CFGH) if $opts{'dry-run'}; +} + ## Optional OpenDDS dependencies my %optdep = ( 'java' => {env => 'JAVA_HOME', sanity => 'include/jni.h', mpc => 'java'}, @@ -2495,6 +2519,7 @@ sub configure_build { write_config_h($buildEnvRef); write_default_features($buildEnvRef); write_platform_macros($buildEnvRef); + write_opendds_configh($buildEnvRef); } generate_workspace($buildEnvRef); write_environment($buildEnvRef, $buildEnvRef->{'DDS_ROOT'}); diff --git a/dds/CMakeLists.txt b/dds/CMakeLists.txt index cb3306f4103..b3a1d22571f 100644 --- a/dds/CMakeLists.txt +++ b/dds/CMakeLists.txt @@ -632,9 +632,12 @@ opendds_target_sources(OpenDDS_Dcps ${opendds_target_sources_args} ) +# Used in OpenDDSConfig.h.in, always true for CMake builds +set(OPENDDS_USES_AUTO_STATIC_INCLUDES 1) + get_target_property(gendir OpenDDS_Dcps OPENDDS_GENERATED_DIRECTORY) -set(config_file "${gendir}/dds/DCPS/config.h") -configure_file("${_OPENDDS_CMAKE_DIR}/config.h.in" "${config_file}") +set(config_file "${gendir}/dds/config/OpenDDSConfig.h") +configure_file("${OPENDDS_SOURCE_DIR}/dds/config/OpenDDSConfig.h.in" "${config_file}") opendds_install_interface_files(OpenDDS_Dcps INCLUDE_BASE "${OPENDDS_SOURCE_DIR}" EXTRA_GENERATED_FILES "${config_file}" ) diff --git a/dds/DCPS/Definitions.h b/dds/DCPS/Definitions.h index c5aecfd61ef..e5984576461 100644 --- a/dds/DCPS/Definitions.h +++ b/dds/DCPS/Definitions.h @@ -9,8 +9,8 @@ #include #ifdef __has_include -# if __has_include() -# include +# if __has_include() +# include # endif #endif diff --git a/dds/DdsDcps.mpc b/dds/DdsDcps.mpc index a55d25c1037..930069739f3 100644 --- a/dds/DdsDcps.mpc +++ b/dds/DdsDcps.mpc @@ -50,6 +50,7 @@ project(OpenDDS_Dcps): core, coverage_optional, \ Header_Files { Version.h Versioned_Namespace.h + config DCPS DCPS/transport/framework DCPS/security/framework diff --git a/dds/config/.gitignore b/dds/config/.gitignore new file mode 100644 index 00000000000..a20a21c2f14 --- /dev/null +++ b/dds/config/.gitignore @@ -0,0 +1 @@ +/OpenDDSConfig.h diff --git a/dds/config/OpenDDSConfig.h.in b/dds/config/OpenDDSConfig.h.in new file mode 100644 index 00000000000..702b69254fc --- /dev/null +++ b/dds/config/OpenDDSConfig.h.in @@ -0,0 +1,14 @@ +#ifndef OPENDDS_USER_CONFIG_H +#define OPENDDS_USER_CONFIG_H + +// OpenDDSConfig.h.in is an input file that will be transformed to +// OpenDDSConfig.h by the configure script or the CMake configure_file command. +// Only variables of the form (at-sign)IDENTIFIER(at-sign) are supported. + +// This file should not #include any other files. + +// To add variables to this file, update both dds/CMakeLists.txt and configure. + +#define OPENDDS_USES_AUTO_STATIC_INCLUDES @OPENDDS_USES_AUTO_STATIC_INCLUDES@ + +#endif diff --git a/tools/scripts/show_build_config.pl b/tools/scripts/show_build_config.pl index eaa0ed6e3c8..3837399ef1d 100755 --- a/tools/scripts/show_build_config.pl +++ b/tools/scripts/show_build_config.pl @@ -1,5 +1,12 @@ #!/usr/bin/env perl +# Outputs the contents of files in ACE and OpenDDS that are written by configure + +# After running configure (or manually configuring a build) run this script +# with the root of the OpenDDS source tree as the current directory. +# No environment variables need to be set to run this script. +# Cross-compile builds are supported when using $SOURCE_DIR/build/{host,target} + use strict; use warnings; @@ -65,14 +72,14 @@ sub show_config { die "ACE_ROOT not found in setenv" unless $ace_root; die "ACE_ROOT in setenv doesn't exist: \"$ace_root\"" unless -d $ace_root; - my $user_macros = ($dds_root eq '.' ? '' : "$dds_root/") . 'user_macros.GNU'; - show_file($user_macros, {optional => 1}); - - my $opendds_version = ($dds_root eq '.' ? '' : "$dds_root/") . 'VERSION.txt'; - show_file($opendds_version); + my $dds_dir = $dds_root eq '.' ? '' : "$dds_root/"; + show_file("${dds_dir}VERSION.txt"); + show_file("${dds_dir}user_macros.GNU", {optional => 1}); + show_file("${dds_dir}dds/config/OpenDDSConfig.h"); + show_file("${dds_dir}bin/opendds_mwc.pl"); + show_file("${dds_dir}cmake/config.cmake"); show_file("$ace_root/ace/Version.h"); - show_file("$ace_root/bin/MakeProjectCreator/config/default.features", {optional => 1}); show_file("$ace_root/include/makeinclude/platform_macros.GNU", {optional => 1}); show_file("$ace_root/ace/config.h"); From 0097901d204011e722ccdf1a110e061d71298ffe Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Wed, 21 Feb 2024 09:34:47 -0600 Subject: [PATCH 02/16] moved write_opendds_configh in configure --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 300deebec03..6f455e27446 100755 --- a/configure +++ b/configure @@ -2519,8 +2519,8 @@ sub configure_build { write_config_h($buildEnvRef); write_default_features($buildEnvRef); write_platform_macros($buildEnvRef); - write_opendds_configh($buildEnvRef); } + write_opendds_configh($buildEnvRef); generate_workspace($buildEnvRef); write_environment($buildEnvRef, $buildEnvRef->{'DDS_ROOT'}); From 1c2fc9614025846058ef71b837cf549aef2f7e95 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Wed, 21 Feb 2024 14:00:04 -0600 Subject: [PATCH 03/16] Updated to work with cross-compiles --- tools/scripts/show_build_config.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/scripts/show_build_config.pl b/tools/scripts/show_build_config.pl index 3837399ef1d..71ebf09b79f 100755 --- a/tools/scripts/show_build_config.pl +++ b/tools/scripts/show_build_config.pl @@ -77,7 +77,7 @@ sub show_config { show_file("${dds_dir}user_macros.GNU", {optional => 1}); show_file("${dds_dir}dds/config/OpenDDSConfig.h"); show_file("${dds_dir}bin/opendds_mwc.pl"); - show_file("${dds_dir}cmake/config.cmake"); + show_file("${dds_dir}cmake/config.cmake", {optional => 1}); # not used for cross-compile show_file("$ace_root/ace/Version.h"); show_file("$ace_root/bin/MakeProjectCreator/config/default.features", {optional => 1}); From d139ade415ce0278b1f44d2a7e575d591e9b7772 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Wed, 21 Feb 2024 17:14:04 -0600 Subject: [PATCH 04/16] try to simplify some of the safety profile CI builds --- .github/workflows/build_and_test.yml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index fd224528112..a29d925a0ea 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -552,7 +552,7 @@ jobs: uses: actions/cache@v4 with: path: ${{ github.job }}.tar.xz - key: c10_${{ github.job }}_ace6tao2_${{ env.ACE_COMMIT }}_${{ env.COMPILER_VERSION }} + key: c11_${{ github.job }}_ace6tao2_${{ env.ACE_COMMIT }}_${{ env.COMPILER_VERSION }} - name: checkout MPC if: steps.cache-artifact.outputs.cache-hit != 'true' uses: actions/checkout@v4 @@ -607,7 +607,8 @@ jobs: perl -ni.bak -e "print unless /opendds/" ACE/bin/MakeProjectCreator/config/default.features # remove opendds features from here, let individual build configure scripts handle those cd $GITHUB_WORKSPACE/OpenDDS find . -iname "*\.o" | xargs rm - tar cvf ../${{ github.job }}.tar build/host/ACE_TAO build/target/ACE_TAO build/host/setenv.sh build/host/VERSION.txt + rm -rf build/{host,target}/ACE_TAO/{ACE,TAO}/{examples,performance-tests,tests} + tar cvf ../${{ github.job }}.tar build/host/ACE_TAO build/target/ACE_TAO xz -3 ../${{ github.job }}.tar - name: upload ACE_TAO artifact uses: actions/upload-artifact@v4 @@ -699,10 +700,7 @@ jobs: shell: bash run: | cd OpenDDS/build - tar cvf ../../${{ github.job }}.tar host/dds/idl/opendds_idl - tar uvf ../../${{ github.job }}.tar host/bin/opendds_idl - tar uvf ../../${{ github.job }}.tar host/dds/DCPS/libOpenDDS_Util* - tar uvf ../../${{ github.job }}.tar host/lib/libOpenDDS_Util* + tar cvf ../../${{ github.job }}.tar host/dds/idl/opendds_idl host/bin/opendds_idl host/setenv.sh host/VERSION.txt cd target find . -iname "*\.o" | xargs rm cd .. @@ -877,7 +875,7 @@ jobs: uses: actions/cache@v4 with: path: ${{ github.job }}.tar.xz - key: c10_${{ github.job }}_ace6tao2_${{ env.ACE_COMMIT }}_${{ env.COMPILER_VERSION }} + key: c11_${{ github.job }}_ace6tao2_${{ env.ACE_COMMIT }}_${{ env.COMPILER_VERSION }} - name: checkout MPC if: steps.cache-artifact.outputs.cache-hit != 'true' uses: actions/checkout@v4 @@ -933,7 +931,8 @@ jobs: perl -ni.bak -e "print unless /opendds/" ACE/bin/MakeProjectCreator/config/default.features # remove opendds features from here, let individual build configure scripts handle those cd $GITHUB_WORKSPACE/OpenDDS find . -iname "*\.o" | xargs rm - tar cvf ../${{ github.job }}.tar build/host/ACE_TAO build/target/ACE_TAO build/host/setenv.sh build/host/VERSION.txt + rm -rf build/{host,target}/ACE_TAO/{ACE,TAO}/{examples,performance-tests,tests} + tar cvf ../${{ github.job }}.tar build/host/ACE_TAO build/target/ACE_TAO xz -3 ../${{ github.job }}.tar - name: upload ACE_TAO artifact uses: actions/upload-artifact@v4 @@ -1026,10 +1025,7 @@ jobs: shell: bash run: | cd OpenDDS/build - tar cvf ../../${{ github.job }}.tar host/dds/idl/opendds_idl - tar uvf ../../${{ github.job }}.tar host/bin/opendds_idl - tar uvf ../../${{ github.job }}.tar host/dds/DCPS/libOpenDDS_Util* - tar uvf ../../${{ github.job }}.tar host/lib/libOpenDDS_Util* + tar cvf ../../${{ github.job }}.tar host/dds/idl/opendds_idl host/bin/opendds_idl host/setenv.sh host/VERSION.txt cd target find . -iname "*\.o" | xargs rm cd .. From c48f55bceb4523040c3e68bd2522f7ecd72fa424 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Wed, 21 Feb 2024 17:14:50 -0600 Subject: [PATCH 05/16] cross-compile / safety profile --- tools/scripts/show_build_config.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/scripts/show_build_config.pl b/tools/scripts/show_build_config.pl index 71ebf09b79f..a1edaaeeb9e 100755 --- a/tools/scripts/show_build_config.pl +++ b/tools/scripts/show_build_config.pl @@ -74,10 +74,11 @@ sub show_config { my $dds_dir = $dds_root eq '.' ? '' : "$dds_root/"; show_file("${dds_dir}VERSION.txt"); + # use 'optional' for the following files, they may not be in the host side of cross-compile show_file("${dds_dir}user_macros.GNU", {optional => 1}); - show_file("${dds_dir}dds/config/OpenDDSConfig.h"); - show_file("${dds_dir}bin/opendds_mwc.pl"); - show_file("${dds_dir}cmake/config.cmake", {optional => 1}); # not used for cross-compile + show_file("${dds_dir}dds/config/OpenDDSConfig.h", {optional => 1}); + show_file("${dds_dir}bin/opendds_mwc.pl", {optional => 1}); + show_file("${dds_dir}cmake/config.cmake", {optional => 1}); show_file("$ace_root/ace/Version.h"); show_file("$ace_root/bin/MakeProjectCreator/config/default.features", {optional => 1}); From a53e0ddcd67601380ed8caa568c039c82d8004ab Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 23 Feb 2024 12:46:37 -0600 Subject: [PATCH 06/16] Updated header include guard name --- dds/config/OpenDDSConfig.h.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dds/config/OpenDDSConfig.h.in b/dds/config/OpenDDSConfig.h.in index 702b69254fc..cd4bdb13f3c 100644 --- a/dds/config/OpenDDSConfig.h.in +++ b/dds/config/OpenDDSConfig.h.in @@ -1,5 +1,5 @@ -#ifndef OPENDDS_USER_CONFIG_H -#define OPENDDS_USER_CONFIG_H +#ifndef OPENDDS_DDS_CONFIG_OPENDDSCONFIG_H +#define OPENDDS_DDS_CONFIG_OPENDDSCONFIG_H // OpenDDSConfig.h.in is an input file that will be transformed to // OpenDDSConfig.h by the configure script or the CMake configure_file command. From 6bc4b2bead1444edc6fb69a3bce0537951836d15 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 23 Feb 2024 13:58:15 -0600 Subject: [PATCH 07/16] Moved OpenDDSConfig.h and made it required --- configure | 6 +++--- dds/CMakeLists.txt | 4 ++-- dds/DCPS/Definitions.h | 11 ++++++----- dds/{config => }/OpenDDSConfig.h.in | 4 ++-- tools/scripts/show_build_config.pl | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) rename dds/{config => }/OpenDDSConfig.h.in (83%) diff --git a/configure b/configure index 6f455e27446..aeb73ed6288 100755 --- a/configure +++ b/configure @@ -1340,9 +1340,9 @@ EOT sub write_opendds_configh { my %buildEnv = %{shift()}; - my $CFGH = backup_and_open("$buildEnv{'DDS_ROOT'}/dds/config/OpenDDSConfig.h"); + my $CFGH = backup_and_open("$buildEnv{'DDS_ROOT'}/dds/OpenDDSConfig.h"); my $CFGIN = new FileHandle; - open($CFGIN, 'dds/config/OpenDDSConfig.h.in') or die("Can't open OpenDDSConfig.h.in for reading: $!\nStopped"); + open($CFGIN, 'dds/OpenDDSConfig.h.in') or die("Can't open OpenDDSConfig.h.in for reading: $!\nStopped"); sub replace_value { my $var = shift; @@ -1357,7 +1357,7 @@ sub write_opendds_configh { $CFGIN->close; $CFGH->close; - print "Wrote $buildEnv{'DDS_ROOT'}/dds/config/OpenDDSConfig.h\n" + print "Wrote $buildEnv{'DDS_ROOT'}/dds/OpenDDSConfig.h\n" if $opts{'verbose'}; dump_and_unlink($CFGH) if $opts{'dry-run'}; } diff --git a/dds/CMakeLists.txt b/dds/CMakeLists.txt index b3a1d22571f..7da187fd7b6 100644 --- a/dds/CMakeLists.txt +++ b/dds/CMakeLists.txt @@ -636,8 +636,8 @@ opendds_target_sources(OpenDDS_Dcps set(OPENDDS_USES_AUTO_STATIC_INCLUDES 1) get_target_property(gendir OpenDDS_Dcps OPENDDS_GENERATED_DIRECTORY) -set(config_file "${gendir}/dds/config/OpenDDSConfig.h") -configure_file("${OPENDDS_SOURCE_DIR}/dds/config/OpenDDSConfig.h.in" "${config_file}") +set(config_file "${gendir}/dds/OpenDDSConfig.h") +configure_file("${OPENDDS_SOURCE_DIR}/dds/OpenDDSConfig.h.in" "${config_file}") opendds_install_interface_files(OpenDDS_Dcps INCLUDE_BASE "${OPENDDS_SOURCE_DIR}" EXTRA_GENERATED_FILES "${config_file}" ) diff --git a/dds/DCPS/Definitions.h b/dds/DCPS/Definitions.h index e5984576461..fd7b2032722 100644 --- a/dds/DCPS/Definitions.h +++ b/dds/DCPS/Definitions.h @@ -8,11 +8,12 @@ #include -#ifdef __has_include -# if __has_include() -# include -# endif -#endif +// OpenDDSConfig.h is generated by the configure script or by CMake +// If you're manually configuring OpenDDS, start by creating an empty file +// named OpenDDSConfig.h in a dds/ directory on the include path. +// See the OpenDDS Developer's Guide and dds/OpenDDSConfig.h.in for details +// regarding what can be customized. +#include #include diff --git a/dds/config/OpenDDSConfig.h.in b/dds/OpenDDSConfig.h.in similarity index 83% rename from dds/config/OpenDDSConfig.h.in rename to dds/OpenDDSConfig.h.in index cd4bdb13f3c..d2ab20e7403 100644 --- a/dds/config/OpenDDSConfig.h.in +++ b/dds/OpenDDSConfig.h.in @@ -1,5 +1,5 @@ -#ifndef OPENDDS_DDS_CONFIG_OPENDDSCONFIG_H -#define OPENDDS_DDS_CONFIG_OPENDDSCONFIG_H +#ifndef OPENDDS_DDS_OPENDDSCONFIG_H +#define OPENDDS_DDS_OPENDDSCONFIG_H // OpenDDSConfig.h.in is an input file that will be transformed to // OpenDDSConfig.h by the configure script or the CMake configure_file command. diff --git a/tools/scripts/show_build_config.pl b/tools/scripts/show_build_config.pl index a1edaaeeb9e..6e1d2025435 100755 --- a/tools/scripts/show_build_config.pl +++ b/tools/scripts/show_build_config.pl @@ -76,7 +76,7 @@ sub show_config { show_file("${dds_dir}VERSION.txt"); # use 'optional' for the following files, they may not be in the host side of cross-compile show_file("${dds_dir}user_macros.GNU", {optional => 1}); - show_file("${dds_dir}dds/config/OpenDDSConfig.h", {optional => 1}); + show_file("${dds_dir}dds/OpenDDSConfig.h", {optional => 1}); show_file("${dds_dir}bin/opendds_mwc.pl", {optional => 1}); show_file("${dds_dir}cmake/config.cmake", {optional => 1}); From b18645616ecdce05dc09f63e3c82a094112c0d25 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 23 Feb 2024 14:58:25 -0600 Subject: [PATCH 08/16] updated .gitignore --- dds/.gitignore | 1 + dds/config/.gitignore | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 dds/config/.gitignore diff --git a/dds/.gitignore b/dds/.gitignore index fa135040ce2..852ab06c95b 100644 --- a/dds/.gitignore +++ b/dds/.gitignore @@ -268,6 +268,7 @@ /OctetSeqS.cpp /OctetSeqS.h /OctetSeqS.inl +/OpenDDSConfig.h /OpenddsDcpsExtC.cpp /OpenddsDcpsExtC.h /OpenddsDcpsExtC.inl diff --git a/dds/config/.gitignore b/dds/config/.gitignore deleted file mode 100644 index a20a21c2f14..00000000000 --- a/dds/config/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/OpenDDSConfig.h From 20b5b40c8db3f013f9b621e04374588a4c5bc49d Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 23 Feb 2024 15:02:01 -0600 Subject: [PATCH 09/16] Renamed OPENDDS_USES_AUTO_STATIC_INCLUDES --- configure | 2 +- dds/CMakeLists.txt | 2 +- dds/DCPS/Definitions.h | 6 +++--- dds/DCPS/StaticIncludes.h | 2 +- dds/OpenDDSConfig.h.in | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/configure b/configure index aeb73ed6288..604b8fbdd0f 100755 --- a/configure +++ b/configure @@ -1346,7 +1346,7 @@ sub write_opendds_configh { sub replace_value { my $var = shift; - return '0' if $var eq 'OPENDDS_USES_AUTO_STATIC_INCLUDES'; + return '0' if $var eq 'OPENDDS_CONFIG_AUTO_STATIC_INCLUDES'; return 'UNDEFINED'; } diff --git a/dds/CMakeLists.txt b/dds/CMakeLists.txt index 7da187fd7b6..f84fb4582a7 100644 --- a/dds/CMakeLists.txt +++ b/dds/CMakeLists.txt @@ -633,7 +633,7 @@ opendds_target_sources(OpenDDS_Dcps ) # Used in OpenDDSConfig.h.in, always true for CMake builds -set(OPENDDS_USES_AUTO_STATIC_INCLUDES 1) +set(OPENDDS_CONFIG_AUTO_STATIC_INCLUDES 1) get_target_property(gendir OpenDDS_Dcps OPENDDS_GENERATED_DIRECTORY) set(config_file "${gendir}/dds/OpenDDSConfig.h") diff --git a/dds/DCPS/Definitions.h b/dds/DCPS/Definitions.h index fd7b2032722..07f24418878 100644 --- a/dds/DCPS/Definitions.h +++ b/dds/DCPS/Definitions.h @@ -98,11 +98,11 @@ # define OPENDDS_GCC_HAS_DIAG_PUSHPOP 0 #endif -#ifndef OPENDDS_USES_AUTO_STATIC_INCLUDES -# define OPENDDS_USES_AUTO_STATIC_INCLUDES 0 +#ifndef OPENDDS_CONFIG_AUTO_STATIC_INCLUDES +# define OPENDDS_CONFIG_AUTO_STATIC_INCLUDES 0 #endif -#if !OPENDDS_USES_AUTO_STATIC_INCLUDES && defined(ACE_AS_STATIC_LIBS) +#if !OPENDDS_CONFIG_AUTO_STATIC_INCLUDES && defined(ACE_AS_STATIC_LIBS) # define OPENDDS_DO_MANUAL_STATIC_INCLUDES 1 #else # define OPENDDS_DO_MANUAL_STATIC_INCLUDES 0 diff --git a/dds/DCPS/StaticIncludes.h b/dds/DCPS/StaticIncludes.h index 894911109c7..2fe71cc027a 100644 --- a/dds/DCPS/StaticIncludes.h +++ b/dds/DCPS/StaticIncludes.h @@ -3,7 +3,7 @@ #include "Definitions.h" -#if OPENDDS_USES_AUTO_STATIC_INCLUDES +#if OPENDDS_CONFIG_AUTO_STATIC_INCLUDES // Explict checks depend on *_HAS_DLL macros being set to 0 to initialize static // plugins. diff --git a/dds/OpenDDSConfig.h.in b/dds/OpenDDSConfig.h.in index d2ab20e7403..0db58de0a60 100644 --- a/dds/OpenDDSConfig.h.in +++ b/dds/OpenDDSConfig.h.in @@ -9,6 +9,6 @@ // To add variables to this file, update both dds/CMakeLists.txt and configure. -#define OPENDDS_USES_AUTO_STATIC_INCLUDES @OPENDDS_USES_AUTO_STATIC_INCLUDES@ +#define OPENDDS_CONFIG_AUTO_STATIC_INCLUDES @OPENDDS_CONFIG_AUTO_STATIC_INCLUDES@ #endif From 1bd3d483990818cdad43093827b687abb264c3be Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 23 Feb 2024 15:07:06 -0600 Subject: [PATCH 10/16] config dir no longer used --- dds/DdsDcps.mpc | 1 - 1 file changed, 1 deletion(-) diff --git a/dds/DdsDcps.mpc b/dds/DdsDcps.mpc index 930069739f3..a55d25c1037 100644 --- a/dds/DdsDcps.mpc +++ b/dds/DdsDcps.mpc @@ -50,7 +50,6 @@ project(OpenDDS_Dcps): core, coverage_optional, \ Header_Files { Version.h Versioned_Namespace.h - config DCPS DCPS/transport/framework DCPS/security/framework From b8b0619b41487a26a59ee0a424b5c4d3964e315f Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 23 Feb 2024 16:39:15 -0600 Subject: [PATCH 11/16] Install the new header --- dds/DdsDcps.mpc | 1 + 1 file changed, 1 insertion(+) diff --git a/dds/DdsDcps.mpc b/dds/DdsDcps.mpc index a55d25c1037..0eeea75180a 100644 --- a/dds/DdsDcps.mpc +++ b/dds/DdsDcps.mpc @@ -48,6 +48,7 @@ project(OpenDDS_Dcps): core, coverage_optional, \ } Header_Files { + OpenDDSConfig.h Version.h Versioned_Namespace.h DCPS From 1d2486d53dca5b49e896457278ec88ab0dbc0646 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Fri, 23 Feb 2024 16:42:41 -0600 Subject: [PATCH 12/16] Fix Including OpenDDSConfig.h for CMake --- CMakeLists.txt | 21 +++++++++++++++++++++ cmake/opendds_build_helpers.cmake | 2 ++ dds/CMakeLists.txt | 10 +--------- dds/DCPS/CMakeLists.txt | 2 +- dds/InfoRepo/CMakeLists.txt | 2 +- dds/OpenDDSConfig.h.in | 2 +- dds/idl/CMakeLists.txt | 2 +- tools/inspect/CMakeLists.txt | 2 +- 8 files changed, 29 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6856dec55e8..bb045db5ce2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,27 @@ if(NOT DEFINED OPENDDS_RAPIDJSON) endif() endif() +# Generate OpenDDSConfig.h, make it available for all targets (see +# opendds_build_helpers.cmake), and install it. +set(OPENDDS_CONFIG_AUTO_STATIC_INCLUDES 1) # Always true for CMake builds +set(config_file "dds/OpenDDSConfig.h") +set(config_out_dir "${CMAKE_CURRENT_BINARY_DIR}/opendds_config_include") +set(config_out_file "${config_out_dir}/${config_file}") +configure_file("${config_file}.in" "${config_file_out}") +add_library(OpenDDS_Config INTERFACE) +target_include_directories(OpenDDS_Config + INTERFACE + "$" + "$" +) +target_sources(OpenDDS_Config + INTERFACE FILE_SET HEADERS BASE_DIRS "${config_out_dir}" FILES "${config_out_file}") +install(TARGETS OpenDDS_Config + EXPORT opendds_targets + FILE_SET HEADERS + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + if(NOT CMAKE_CROSSCOMPILING) add_subdirectory(dds/DCPS) # OpenDDS_Util add_subdirectory(dds/idl) # opendds_idl diff --git a/cmake/opendds_build_helpers.cmake b/cmake/opendds_build_helpers.cmake index 258aeda4c37..c7e874bbe0f 100644 --- a/cmake/opendds_build_helpers.cmake +++ b/cmake/opendds_build_helpers.cmake @@ -28,6 +28,7 @@ function(_opendds_library target) "${no_value_options}" "${single_value_options}" "${multi_value_options}" ${ARGN}) _opendds_alias(${target}) + target_link_libraries(${target} PUBLIC OpenDDS_Config) # Put library in BINARY_DIR/lib set_target_properties(${target} PROPERTIES @@ -82,6 +83,7 @@ function(_opendds_executable target) "${no_value_options}" "${single_value_options}" "${multi_value_options}" ${ARGN}) _opendds_alias(${target}) + target_link_libraries(${target} PRIVATE OpenDDS_Config) set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${OPENDDS_BIN_DIR}") if(NOT arg_NO_INSTALL) diff --git a/dds/CMakeLists.txt b/dds/CMakeLists.txt index f84fb4582a7..018291e41e0 100644 --- a/dds/CMakeLists.txt +++ b/dds/CMakeLists.txt @@ -632,12 +632,4 @@ opendds_target_sources(OpenDDS_Dcps ${opendds_target_sources_args} ) -# Used in OpenDDSConfig.h.in, always true for CMake builds -set(OPENDDS_CONFIG_AUTO_STATIC_INCLUDES 1) - -get_target_property(gendir OpenDDS_Dcps OPENDDS_GENERATED_DIRECTORY) -set(config_file "${gendir}/dds/OpenDDSConfig.h") -configure_file("${OPENDDS_SOURCE_DIR}/dds/OpenDDSConfig.h.in" "${config_file}") -opendds_install_interface_files(OpenDDS_Dcps INCLUDE_BASE "${OPENDDS_SOURCE_DIR}" - EXTRA_GENERATED_FILES "${config_file}" -) +opendds_install_interface_files(OpenDDS_Dcps INCLUDE_BASE "${OPENDDS_SOURCE_DIR}") diff --git a/dds/DCPS/CMakeLists.txt b/dds/DCPS/CMakeLists.txt index f94f39a984c..3d771ee7165 100644 --- a/dds/DCPS/CMakeLists.txt +++ b/dds/DCPS/CMakeLists.txt @@ -29,4 +29,4 @@ target_include_directories(OpenDDS_Util .. # For pch ${TAO_INCLUDE_DIRS} # Only for orbconf.h and idl_features.h in Definitions.h ) -target_link_libraries(OpenDDS_Util ${deps}) +target_link_libraries(OpenDDS_Util PUBLIC ${deps}) diff --git a/dds/InfoRepo/CMakeLists.txt b/dds/InfoRepo/CMakeLists.txt index 1e9da7a9305..19d7c4b29ac 100644 --- a/dds/InfoRepo/CMakeLists.txt +++ b/dds/InfoRepo/CMakeLists.txt @@ -68,4 +68,4 @@ target_link_libraries(OpenDDS_InfoRepoServ PUBLIC OpenDDS::Federator) add_executable(DCPSInfoRepo DCPSInfoRepo.cpp) _opendds_executable(DCPSInfoRepo) -target_link_libraries(DCPSInfoRepo OpenDDS::InfoRepoServ ${exe_dep_libs}) +target_link_libraries(DCPSInfoRepo PRIVATE OpenDDS::InfoRepoServ ${exe_dep_libs}) diff --git a/dds/OpenDDSConfig.h.in b/dds/OpenDDSConfig.h.in index 0db58de0a60..8dc1c128c10 100644 --- a/dds/OpenDDSConfig.h.in +++ b/dds/OpenDDSConfig.h.in @@ -7,7 +7,7 @@ // This file should not #include any other files. -// To add variables to this file, update both dds/CMakeLists.txt and configure. +// To add variables to this file, update both CMakeLists.txt and configure. #define OPENDDS_CONFIG_AUTO_STATIC_INCLUDES @OPENDDS_CONFIG_AUTO_STATIC_INCLUDES@ diff --git a/dds/idl/CMakeLists.txt b/dds/idl/CMakeLists.txt index 137340ce021..57fa8ef3d6b 100644 --- a/dds/idl/CMakeLists.txt +++ b/dds/idl/CMakeLists.txt @@ -32,7 +32,7 @@ add_executable(opendds_idl value_writer_generator.cpp ) _opendds_executable(opendds_idl) -target_link_libraries(opendds_idl ${deps} OpenDDS_Util) +target_link_libraries(opendds_idl PRIVATE ${deps} OpenDDS_Util) set_target_properties(opendds_idl PROPERTIES # opendds_idl doesn't play nice with bundling the cpp files together UNITY_BUILD FALSE diff --git a/tools/inspect/CMakeLists.txt b/tools/inspect/CMakeLists.txt index 43c1b151eae..64db75bee6a 100644 --- a/tools/inspect/CMakeLists.txt +++ b/tools/inspect/CMakeLists.txt @@ -9,4 +9,4 @@ include(opendds_build_helpers) add_executable(inspect Inspect.cpp) _opendds_executable(inspect) -target_link_libraries(inspect ${dep_libs}) +target_link_libraries(inspect PRIVATE ${dep_libs}) From df2b8d5c0cad46d215a5859ea776260c9375c6d0 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Fri, 23 Feb 2024 16:57:00 -0600 Subject: [PATCH 13/16] Fix Typo in CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb045db5ce2..7f182c7be21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ set(OPENDDS_CONFIG_AUTO_STATIC_INCLUDES 1) # Always true for CMake builds set(config_file "dds/OpenDDSConfig.h") set(config_out_dir "${CMAKE_CURRENT_BINARY_DIR}/opendds_config_include") set(config_out_file "${config_out_dir}/${config_file}") -configure_file("${config_file}.in" "${config_file_out}") +configure_file("${config_file}.in" "${config_out_file}") add_library(OpenDDS_Config INTERFACE) target_include_directories(OpenDDS_Config INTERFACE From a9faa11e47799b5678407642a37c1982bcd62c36 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Fri, 23 Feb 2024 17:10:15 -0600 Subject: [PATCH 14/16] Add missing PRIVATE to RtpsRelay --- tools/rtpsrelay/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/rtpsrelay/CMakeLists.txt b/tools/rtpsrelay/CMakeLists.txt index df86f1745dd..3f9c02a507f 100644 --- a/tools/rtpsrelay/CMakeLists.txt +++ b/tools/rtpsrelay/CMakeLists.txt @@ -27,4 +27,4 @@ add_executable(RtpsRelay SubscriptionListener.cpp ) _opendds_executable(RtpsRelay) -target_link_libraries(RtpsRelay ${dep_libs}) +target_link_libraries(RtpsRelay PRIVATE ${dep_libs}) From ac19c6bea16c2364f5fab207ced0567950bdd78b Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Mon, 26 Feb 2024 10:53:37 -0600 Subject: [PATCH 15/16] NEWS for this change --- docs/news.d/openddsconfig.rst | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 docs/news.d/openddsconfig.rst diff --git a/docs/news.d/openddsconfig.rst b/docs/news.d/openddsconfig.rst new file mode 100644 index 00000000000..7dc4d2207ca --- /dev/null +++ b/docs/news.d/openddsconfig.rst @@ -0,0 +1,7 @@ +.. news-prs: 4482 + +.. news-start-section: Additions +- A new header, dds/OpenDDSConfig.h is generated by configure or CMake. + - Users manually configuring a build will need to create this file, which may be empty. + - See dds/OpenDDSConfig.h.in for details. +.. news-end-section From 61f549aaa9cec254ba65c9e9130fbb522af2f78b Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Mon, 26 Feb 2024 13:06:22 -0600 Subject: [PATCH 16/16] Update docs/news.d/openddsconfig.rst Co-authored-by: Fred Hornsey --- docs/news.d/openddsconfig.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/news.d/openddsconfig.rst b/docs/news.d/openddsconfig.rst index 7dc4d2207ca..ac71f9ea703 100644 --- a/docs/news.d/openddsconfig.rst +++ b/docs/news.d/openddsconfig.rst @@ -1,7 +1,8 @@ .. news-prs: 4482 .. news-start-section: Additions -- A new header, dds/OpenDDSConfig.h is generated by configure or CMake. +- A new header, ``dds/OpenDDSConfig.h`` is generated by configure or CMake. + - Users manually configuring a build will need to create this file, which may be empty. - - See dds/OpenDDSConfig.h.in for details. + - See ``dds/OpenDDSConfig.h.in`` for details. .. news-end-section