Skip to content

Commit

Permalink
Merge pull request OpenDDS#4482 from mitza-oci/configh
Browse files Browse the repository at this point in the history
Move and rename cmake/config.h.in so it can be used more generally
  • Loading branch information
jrw972 authored Feb 26, 2024
2 parents 8a80ceb + 61f549a commit d139fe7
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 47 deletions.
20 changes: 8 additions & 12 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ..
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ..
Expand Down
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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_out_file}")
add_library(OpenDDS_Config INTERFACE)
target_include_directories(OpenDDS_Config
INTERFACE
"$<BUILD_INTERFACE:${config_out_dir}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
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
Expand Down
8 changes: 0 additions & 8 deletions cmake/config.h.in

This file was deleted.

2 changes: 2 additions & 0 deletions cmake/opendds_build_helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

if(OPENDDS_CXX_STD)
target_compile_features(${target} PUBLIC "cxx_std_${OPENDDS_CXX_STD}")
Expand Down Expand Up @@ -86,6 +87,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(OPENDDS_CXX_STD)
Expand Down
27 changes: 26 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1338,6 +1338,30 @@ EOT
}
}

sub write_opendds_configh {
my %buildEnv = %{shift()};
my $CFGH = backup_and_open("$buildEnv{'DDS_ROOT'}/dds/OpenDDSConfig.h");
my $CFGIN = new FileHandle;
open($CFGIN, 'dds/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_CONFIG_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/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'},
Expand Down Expand Up @@ -2496,6 +2520,7 @@ sub configure_build {
write_default_features($buildEnvRef);
write_platform_macros($buildEnvRef);
}
write_opendds_configh($buildEnvRef);
generate_workspace($buildEnvRef);
write_environment($buildEnvRef, $buildEnvRef->{'DDS_ROOT'});

Expand Down
1 change: 1 addition & 0 deletions dds/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@
/OctetSeqS.cpp
/OctetSeqS.h
/OctetSeqS.inl
/OpenDDSConfig.h
/OpenddsDcpsExtC.cpp
/OpenddsDcpsExtC.h
/OpenddsDcpsExtC.inl
Expand Down
7 changes: 1 addition & 6 deletions dds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,4 @@ opendds_target_sources(OpenDDS_Dcps
${opendds_target_sources_args}
)

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}")
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}")
2 changes: 1 addition & 1 deletion dds/DCPS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
17 changes: 9 additions & 8 deletions dds/DCPS/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

#include <ace/config-lite.h>

#ifdef __has_include
# if __has_include(<dds/DCPS/config.h>)
# include <dds/DCPS/config.h>
# 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 <dds/OpenDDSConfig.h>

#include <dds/Versioned_Namespace.h>

Expand Down Expand Up @@ -97,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
Expand Down
2 changes: 1 addition & 1 deletion dds/DCPS/StaticIncludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions dds/DdsDcps.mpc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ project(OpenDDS_Dcps): core, coverage_optional, \
}

Header_Files {
OpenDDSConfig.h
Version.h
Versioned_Namespace.h
DCPS
Expand Down
2 changes: 1 addition & 1 deletion dds/InfoRepo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
14 changes: 14 additions & 0 deletions dds/OpenDDSConfig.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#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.
// 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 CMakeLists.txt and configure.

#define OPENDDS_CONFIG_AUTO_STATIC_INCLUDES @OPENDDS_CONFIG_AUTO_STATIC_INCLUDES@

#endif
2 changes: 1 addition & 1 deletion dds/idl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions docs/news.d/openddsconfig.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. 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
2 changes: 1 addition & 1 deletion tools/inspect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
2 changes: 1 addition & 1 deletion tools/rtpsrelay/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
20 changes: 14 additions & 6 deletions tools/scripts/show_build_config.pl
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -65,14 +72,15 @@ 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");
# 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/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});
show_file("$ace_root/include/makeinclude/platform_macros.GNU", {optional => 1});
show_file("$ace_root/ace/config.h");
Expand Down

0 comments on commit d139fe7

Please sign in to comment.