From bad1ed79f34152c1a3e354e671845e8f5befd409 Mon Sep 17 00:00:00 2001
From: Peter Soetens <peter.soetens@fmtc.be>
Date: Fri, 30 Jan 2009 10:04:21 +0100
Subject: [PATCH 2/2] Improved CORBA compilation by not requiring -DCORBA_IS_X flags.

rtt/corba/corba.h is now included by every corba related file
which includes in turn rtt/corba/rtt-corba-config.h such that
the build knows which CORBA type is used TAO/OMNIORB.
---
 config/FindOmniORB.cmake        |    3 ++-
 config/FindTAO.cmake            |    3 ++-
 src/corba/ActionProxy.cpp       |    1 +
 src/corba/AnyDataSource.hpp     |    1 +
 src/corba/ApplicationServer.hpp |    1 +
 src/corba/AttributesI.h         |    1 +
 src/corba/CommandProxy.cpp      |    1 +
 src/corba/ControlTaskI.h        |    1 +
 src/corba/ControlTaskProxy.cpp  |    1 +
 src/corba/ControlTaskProxy.hpp  |    1 +
 src/corba/ControlTaskServer.cpp |    1 +
 src/corba/ControlTaskServer.hpp |    1 +
 src/corba/CorbaBufferProxy.hpp  |    1 +
 src/corba/CorbaConnection.hpp   |    1 +
 src/corba/CorbaConversion.hpp   |    1 +
 src/corba/CorbaPort.hpp         |    1 +
 src/corba/DataFlowI.cpp         |    1 +
 src/corba/DataFlowI.h           |    1 +
 src/corba/ExpressionProxy.cpp   |    1 +
 src/corba/ExpressionServer.hpp  |    1 +
 src/corba/OperationInterfaceI.h |    1 +
 src/corba/OperationsI.h         |    1 +
 src/corba/POAUtility.h          |    1 +
 src/corba/ScriptingAccessI.h    |    1 +
 src/corba/Services.hpp          |    1 +
 src/corba/ServicesI.h           |    1 +
 src/corba/corba.h               |    1 +
 src/corba/rtt-corba-config.h.in |    7 ++-----
 28 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/config/FindOmniORB.cmake b/config/FindOmniORB.cmake
index 24f2522..caa9e86 100644
--- a/config/FindOmniORB.cmake
+++ b/config/FindOmniORB.cmake
@@ -89,6 +89,7 @@ IF( OMNIORB4_LIBRARY_omnithread )
 IF( OMNIORB4_IDL_COMPILER )

   SET( OMNIORB4_FOUND "YES" )
+  SET(CORBA_IS_OMNIORB 1)

   IF(NOT WIN32)
     SET(OMNIORB4_IDL_FLAGS "-bcxx -Wba -Wbh=.hh -Wbs=SK.cc -Wbd=DynSK.cc" CACHE STRING "Option for the omniorb4 idl compiler")
@@ -131,7 +132,7 @@ IF( OMNIORB4_FOUND )
   SET(CORBA_LIBRARIES ${OMNIORB4_LIBRARIES})
   SET(CORBA_CFLAGS ${OMNIORB4_CPP_FLAGS})
   SET(CORBA_INCLUDE_DIRS ${OMNIORB4_INCLUDE_DIR})
-  SET(CORBA_DEFINES -DCORBA_IS_OMNIORB)
+  SET(CORBA_DEFINES "") #-DCORBA_IS_OMNIORB)

 ELSE( OMNIORB4_FOUND )
   MESSAGE("omniORB installation was not found. Please provide OMNIORB4_DIR:")
diff --git a/config/FindTAO.cmake b/config/FindTAO.cmake
index e647730..7eacf55 100644
--- a/config/FindTAO.cmake
+++ b/config/FindTAO.cmake
@@ -70,13 +70,14 @@ IF (ACE_CONFIG AND TAO_ORB AND TAO_ORBSVCS )
     ELSE( NOT ORO_TAOIDL_EXECUTABLE )
         MESSAGE( "tao_idl: ${ORO_TAOIDL_EXECUTABLE}")
         SET(FOUND_TAO TRUE)
+	SET(CORBA_IS_TAO 1)

         SET(CORBA_CFLAGS "")
         SET(CORBA_INCLUDE_DIRS "")
         SET(CORBA_LDFLAGS "")
         SET(CORBA_LIBRARIES "")
         SET(CORBA_LIBRARY_DIRS "")
-        SET(CORBA_DEFINES -DCORBA_IS_TAO)
+        SET(CORBA_DEFINES "") #-DCORBA_IS_TAO)

         # Set include/link variables
         IF( NOT ${ACE_DIR} STREQUAL /usr )
diff --git a/src/corba/ActionProxy.cpp b/src/corba/ActionProxy.cpp
index cf28a56..3556480 100644
--- a/src/corba/ActionProxy.cpp
+++ b/src/corba/ActionProxy.cpp
@@ -40,6 +40,7 @@
 #include "OperationsI.h"
 #include "ActionProxy.hpp"

+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include <ace/String_Base.h>
 #endif
diff --git a/src/corba/AnyDataSource.hpp b/src/corba/AnyDataSource.hpp
index df5b406..df948a2 100644
--- a/src/corba/AnyDataSource.hpp
+++ b/src/corba/AnyDataSource.hpp
@@ -41,6 +41,7 @@

 #include "DataSource.hpp"
 #include "corba.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include <tao/Version.h>
 #if TAO_MAJOR_VERSION == 1 && TAO_MINOR_VERSION <= 4
diff --git a/src/corba/ApplicationServer.hpp b/src/corba/ApplicationServer.hpp
index 9a77b17..cbb8665 100644
--- a/src/corba/ApplicationServer.hpp
+++ b/src/corba/ApplicationServer.hpp
@@ -40,6 +40,7 @@
 #define ORO_APPLICATION_SERVER_HPP

 #include "../rtt-config.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include <tao/corba.h>
 #include <tao/PortableServer/PortableServer.h>
diff --git a/src/corba/AttributesI.h b/src/corba/AttributesI.h
index 64fe5b4..e0b11f3 100644
--- a/src/corba/AttributesI.h
+++ b/src/corba/AttributesI.h
@@ -71,6 +71,7 @@

 #include "../rtt-config.h"
 #include "corba.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include "AttributesS.h"
 #else
diff --git a/src/corba/CommandProxy.cpp b/src/corba/CommandProxy.cpp
index 69346ac..f5ce97f 100644
--- a/src/corba/CommandProxy.cpp
+++ b/src/corba/CommandProxy.cpp
@@ -41,6 +41,7 @@
 #include "CommandProxy.hpp"
 #include "ConditionInterface.hpp"

+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include <ace/String_Base.h>
 #endif
diff --git a/src/corba/ControlTaskI.h b/src/corba/ControlTaskI.h
index 43ada37..48dfa2b 100644
--- a/src/corba/ControlTaskI.h
+++ b/src/corba/ControlTaskI.h
@@ -71,6 +71,7 @@

 #include "../rtt-config.h"
 #include "corba.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include "ControlTaskS.h"
 #else
diff --git a/src/corba/ControlTaskProxy.cpp b/src/corba/ControlTaskProxy.cpp
index 36059d9..ed6633f 100644
--- a/src/corba/ControlTaskProxy.cpp
+++ b/src/corba/ControlTaskProxy.cpp
@@ -64,6 +64,7 @@
 #include "CommandInterface.hpp"
 #include "Types.hpp"
 #include "corba.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include "orbsvcs/CosNamingC.h"
 #include <ace/String_Base.h>
diff --git a/src/corba/ControlTaskProxy.hpp b/src/corba/ControlTaskProxy.hpp
index 8c5395c..2877602 100644
--- a/src/corba/ControlTaskProxy.hpp
+++ b/src/corba/ControlTaskProxy.hpp
@@ -43,6 +43,7 @@
 #ifndef _REENTRANT
 #define _REENTRANT
 #endif
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include <tao/corba.h>
 #else
diff --git a/src/corba/ControlTaskServer.cpp b/src/corba/ControlTaskServer.cpp
index f07dd8b..409ef00 100644
--- a/src/corba/ControlTaskServer.cpp
+++ b/src/corba/ControlTaskServer.cpp
@@ -39,6 +39,7 @@

 #include "ControlTaskServer.hpp"
 #include "ControlTaskProxy.hpp"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include "ControlTaskS.h"
 #include <orbsvcs/CosNamingC.h>
diff --git a/src/corba/ControlTaskServer.hpp b/src/corba/ControlTaskServer.hpp
index fc9c3a2..bf07356 100644
--- a/src/corba/ControlTaskServer.hpp
+++ b/src/corba/ControlTaskServer.hpp
@@ -43,6 +43,7 @@
 #ifndef _REENTRANT
 #define _REENTRANT
 #endif
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include <tao/corba.h>
 #include "ControlTaskS.h"
diff --git a/src/corba/CorbaBufferProxy.hpp b/src/corba/CorbaBufferProxy.hpp
index 0182a10..834bfa7 100644
--- a/src/corba/CorbaBufferProxy.hpp
+++ b/src/corba/CorbaBufferProxy.hpp
@@ -43,6 +43,7 @@
 #include "../BufferInterface.hpp"
 #include "corba.h"
 #include "DataFlowC.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include "DataFlowS.h"
 #endif
diff --git a/src/corba/CorbaConnection.hpp b/src/corba/CorbaConnection.hpp
index 1d0f3a7..931b512 100644
--- a/src/corba/CorbaConnection.hpp
+++ b/src/corba/CorbaConnection.hpp
@@ -3,6 +3,7 @@

 #include "../ConnectionInterface.hpp"
 #include "DataFlowC.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include <tao/corba.h>
 #include <tao/PortableServer/PortableServer.h>
diff --git a/src/corba/CorbaConversion.hpp b/src/corba/CorbaConversion.hpp
index 74d1916..9addf2d 100644
--- a/src/corba/CorbaConversion.hpp
+++ b/src/corba/CorbaConversion.hpp
@@ -42,6 +42,7 @@
 #include <string>
 #include <vector>

+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include <tao/Version.h>
 #if TAO_MAJOR_VERSION == 1 && TAO_MINOR_VERSION <= 4
diff --git a/src/corba/CorbaPort.hpp b/src/corba/CorbaPort.hpp
index a21b76f..45e40eb 100644
--- a/src/corba/CorbaPort.hpp
+++ b/src/corba/CorbaPort.hpp
@@ -44,6 +44,7 @@
 #include "../PortInterface.hpp"
 #include "DataFlowC.h"
 #include "corba.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include <tao/PortableServer/PortableServer.h>
 #endif
diff --git a/src/corba/DataFlowI.cpp b/src/corba/DataFlowI.cpp
index c2ccdc5..d0abe48 100644
--- a/src/corba/DataFlowI.cpp
+++ b/src/corba/DataFlowI.cpp
@@ -68,6 +68,7 @@

 #include "DataFlowI.h"
 #include "corba.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include "DataFlowS.h"
 #else
diff --git a/src/corba/DataFlowI.h b/src/corba/DataFlowI.h
index 9bfdb72..9b52f18 100644
--- a/src/corba/DataFlowI.h
+++ b/src/corba/DataFlowI.h
@@ -70,6 +70,7 @@
 #define DATAFLOWI_H_

 #include "../rtt-config.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include "DataFlowS.h"
 #else
diff --git a/src/corba/ExpressionProxy.cpp b/src/corba/ExpressionProxy.cpp
index ceb904e..d80b386 100644
--- a/src/corba/ExpressionProxy.cpp
+++ b/src/corba/ExpressionProxy.cpp
@@ -42,6 +42,7 @@
 #include "ExpressionProxy.hpp"
 #include <iostream>

+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include <ace/String_Base.h>
 #endif
diff --git a/src/corba/ExpressionServer.hpp b/src/corba/ExpressionServer.hpp
index a0d9bb0..1e6f184 100644
--- a/src/corba/ExpressionServer.hpp
+++ b/src/corba/ExpressionServer.hpp
@@ -41,6 +41,7 @@

 #include "../DataSourceBase.hpp"
 #include "OperationsC.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include <tao/PortableServer/PortableServer.h>
 #else
diff --git a/src/corba/OperationInterfaceI.h b/src/corba/OperationInterfaceI.h
index 75ffdb5..cabacd3 100644
--- a/src/corba/OperationInterfaceI.h
+++ b/src/corba/OperationInterfaceI.h
@@ -71,6 +71,7 @@

 #include "../rtt-config.h"
 #include "corba.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include "OperationInterfaceS.h"
 #else
diff --git a/src/corba/OperationsI.h b/src/corba/OperationsI.h
index 0eb7b29..2635899 100644
--- a/src/corba/OperationsI.h
+++ b/src/corba/OperationsI.h
@@ -73,6 +73,7 @@
 #define INCLUDE_EXECUTIONI_H_

 #include "OperationsC.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include "OperationsS.h"
 #endif
diff --git a/src/corba/POAUtility.h b/src/corba/POAUtility.h
index 8f86351..8dc3ee2 100644
--- a/src/corba/POAUtility.h
+++ b/src/corba/POAUtility.h
@@ -41,6 +41,7 @@

 #include "../rtt-config.h"
 #include "corba.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include <tao/PortableServer/PortableServer.h>
 #else
diff --git a/src/corba/ScriptingAccessI.h b/src/corba/ScriptingAccessI.h
index 2af7808..4151921 100644
--- a/src/corba/ScriptingAccessI.h
+++ b/src/corba/ScriptingAccessI.h
@@ -71,6 +71,7 @@

 #include "../rtt-config.h"
 #include "corba.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include "ScriptingAccessS.h"
 #else
diff --git a/src/corba/Services.hpp b/src/corba/Services.hpp
index 46863f2..28ca099 100644
--- a/src/corba/Services.hpp
+++ b/src/corba/Services.hpp
@@ -40,6 +40,7 @@
 #define ORO_CORBA_SERVICES_HPP

 #include "../rtt-config.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include "orbsvcs/CosNamingC.h"
 #else
diff --git a/src/corba/ServicesI.h b/src/corba/ServicesI.h
index a1c4755..86040e3 100644
--- a/src/corba/ServicesI.h
+++ b/src/corba/ServicesI.h
@@ -41,6 +41,7 @@

 #include "Services.hpp"
 #include "ServicesC.h"
+#include "corba.h"
 #ifdef CORBA_IS_TAO
 #include "ServicesS.h"
 #endif
diff --git a/src/corba/corba.h b/src/corba/corba.h
index 4074b74..5478008 100644
--- a/src/corba/corba.h
+++ b/src/corba/corba.h
@@ -1,6 +1,7 @@
 #ifndef ORO_CORBA_SUPPORT_HH
 #define ORO_CORBA_SUPPORT_HH

+#include "rtt-corba-config.h"
 #if CORBA_IS_TAO
 #include <tao/corba.h>
 #define CORBA_SERVANT(f) f ## "S.h"
diff --git a/src/corba/rtt-corba-config.h.in b/src/corba/rtt-corba-config.h.in
index 17f7053..180f6b1 100644
--- a/src/corba/rtt-corba-config.h.in
+++ b/src/corba/rtt-corba-config.h.in
@@ -3,11 +3,8 @@

 #define RTT_CORBA_IMPLEMENTATION @CORBA_IMPLEMENTATION@

-#ifeq (RTT_CORBA_IMPLEMENTATION, TAO)
-#define CORBA_IS_TAO
-#else
-#define CORBA_IS_OMNIORB
-#endif
+#cmakedefine CORBA_IS_TAO 1
+#cmakedefine CORBA_IS_OMNIORB 1

 #endif

--
1.6.1.2

