You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by ve...@apache.org on 2013/03/25 10:36:42 UTC

svn commit: r1460559 - in /etch/trunk: binding-cpp/runtime/build.xml examples/helloworld/cpp/CMakeLists.txt examples/helloworld/cpp/build.xml examples/helloworld/cpp/src/main/src/MainHelloWorldClient.cpp

Author: veithm
Date: Mon Mar 25 09:36:42 2013
New Revision: 1460559

URL: http://svn.apache.org/r1460559
Log:
ETCH-260 Enable HelloWorld Cpp Example Build for different platforms

Change-Id: Ie0d1b1471ee926e58253f951be4aec69d170a0cb

Modified:
    etch/trunk/binding-cpp/runtime/build.xml
    etch/trunk/examples/helloworld/cpp/CMakeLists.txt
    etch/trunk/examples/helloworld/cpp/build.xml
    etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldClient.cpp

Modified: etch/trunk/binding-cpp/runtime/build.xml
URL: http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/build.xml?rev=1460559&r1=1460558&r2=1460559&view=diff
==============================================================================
--- etch/trunk/binding-cpp/runtime/build.xml (original)
+++ etch/trunk/binding-cpp/runtime/build.xml Mon Mar 25 09:36:42 2013
@@ -131,7 +131,7 @@
                 <echo>Configuring CMake build</echo>
                 <echo>Using generator: ${cmake.generator}</echo>
                 <echo>Using toolchain file: ${basedir}/toolchains/${platform}.toolchain</echo>
-                <cmake srcdir="${basedir}" bindir="${target}/${platform}/${Etch.build.target}" buildtype="${Etch.build.target}" >
+                <cmake srcdir="${basedir}" bindir="${target}/${platform}/${Etch.build.target}" cmakeonly="false" buildtype="${Etch.build.target}" >
                     <generator name="${cmake.generator}" />
                     <variable name="ETCH_EXTERNAL_DEPENDS" type="PATH" value="${env.ETCH_EXTERNAL_DEPENDS}" />
                     <variable name="CMAKE_TOOLCHAIN_FILE" type="FILEPATH" value="${basedir}/toolchains/${platform}.toolchain" />
@@ -142,7 +142,7 @@
                 <echo>Configuring CMake build</echo>
                 <echo>Using default generator</echo>
                 <echo>Using toolchain file: ${basedir}/toolchains/${platform}.toolchain</echo>
-                <cmake srcdir="${basedir}" bindir="${target}/${platform}/${Etch.build.target}" buildtype="${Etch.build.target}" >
+                <cmake srcdir="${basedir}" bindir="${target}/${platform}/${Etch.build.target}" cmakeonly="false" buildtype="${Etch.build.target}" >
                     <variable name="ETCH_EXTERNAL_DEPENDS" type="PATH" value="${env.ETCH_EXTERNAL_DEPENDS}" />
                     <variable name="CMAKE_TOOLCHAIN_FILE" type="FILEPATH" value="${basedir}/toolchains/${platform}.toolchain" />
                 </cmake>

Modified: etch/trunk/examples/helloworld/cpp/CMakeLists.txt
URL: http://svn.apache.org/viewvc/etch/trunk/examples/helloworld/cpp/CMakeLists.txt?rev=1460559&r1=1460558&r2=1460559&view=diff
==============================================================================
--- etch/trunk/examples/helloworld/cpp/CMakeLists.txt (original)
+++ etch/trunk/examples/helloworld/cpp/CMakeLists.txt Mon Mar 25 09:36:42 2013
@@ -25,14 +25,6 @@ IF (EXISTS "${CMAKE_SOURCE_DIR}/CMakeLis
   INCLUDE ("${CMAKE_SOURCE_DIR}/CMakeLists_local.txt" OPTIONAL)
 ENDIF()
 
-IF(UNIX)
-  add_definitions("-DOS_LINUX")
-  add_definitions("-DARCH_X86_32")
-ELSEIF(WIN32)
-  add_definitions("-DOS_WINDOWS")
-  add_definitions("-DARCH_X86_32")
-ENDIF()
-
 #====================================================================================#
 
 #Etch Home
@@ -43,48 +35,23 @@ ENDIF (NOT ETCH_HOME)
 SET(ETCH_CPP_HOME ${ETCH_HOME}/binding-cpp)
 SET(ETCH_CPP_INCLUDE_DIR ${ETCH_CPP_HOME}/include)
 SET(ETCH_CPP_LIBRARY_DIR ${ETCH_CPP_HOME}/lib)
-
-IF(UNIX)
-	FIND_LIBRARY(ETCH_LIBRARY NAMES libetch.a PATHS ${ETCH_CPP_LIBRARY_DIR})
-	FIND_LIBRARY(CAPU_LIBRARY NAMES libcapu.a PATHS ${ETCH_CPP_LIBRARY_DIR}/Linux_X86_32)
-ELSEIF(WIN32)
-	FIND_LIBRARY(ETCH_LIBRARY NAMES etch.lib PATHS ${ETCH_CPP_LIBRARY_DIR})
-	FIND_LIBRARY(CAPU_LIBRARY NAMES capu.lib PATHS ${ETCH_CPP_LIBRARY_DIR}/Windows_X86_32/Debug)
-ENDIF()
-
-IF (ETCH_LIBRARY)
-    SET(ETCH_LIBRARY_FOUND TRUE)
-ENDIF ()
-
-IF (CAPU_LIBRARY)
-    SET(CAPU_LIBRARY_FOUND TRUE)
-ENDIF ()
-
-IF (NOT ETCH_LIBRARY_FOUND)
-    MESSAGE(FATAL_ERROR "ERROR: Could not find etch library in ${ETCH_CPP_LIBRARY_DIR}")
-ENDIF ()
-
-IF (NOT CAPU_LIBRARY_FOUND)
-    MESSAGE(FATAL_ERROR "ERROR: Could not find capu library in ${ETCH_CPP_LIBRARY_DIR}")
-ENDIF ()
-
+SET(ETCH_CPP_LIBRARY_DIR_PLATFORM_SPECIFIC ${ETCH_CPP_LIBRARY_DIR}/${TARGET_OS}_${TARGET_ARCH}/${ETCH_BUILD_TARGET})
 
 # set include dirs
 include_directories (${ETCH_CPP_INCLUDE_DIR})
 include_directories (${PROJECT_SOURCE_DIR}/src/main/include)
 include_directories (${PROJECT_SOURCE_DIR}/target/generated-sources/cpp/include)
 
+link_directories(${ETCH_CPP_LIBRARY_DIR_PLATFORM_SPECIFIC})
+
+
 #STATUS
 message(STATUS " ")
 message(STATUS "====================================================")
+message(STATUS "build target:            ${ETCH_BUILD_TARGET}")
 message(STATUS "using Etch home Dir:     ${ETCH_HOME}")
-message(STATUS "using Etch dir:         ${ETCH_LIBRARY}")
-message(STATUS "using Capu dir:         ${CAPU_LIBRARY}")
-
-message(STATUS "using include dir: ${ETCH_CPP_INCLUDE_DIR}")
-message(STATUS "====================================================")
-message(STATUS " ")
-
+message(STATUS "using include dir:       ${ETCH_CPP_INCLUDE_DIR}")
+message(STATUS "using library dir:       ${ETCH_CPP_LIBRARY_DIR_PLATFORM_SPECIFIC}")
 
 #====================================================================================#
 # SERVER
@@ -114,18 +81,21 @@ add_executable(etch-cpp-helloworld-serve
 )
 
 
-IF (UNIX)
-target_link_libraries(etch-cpp-helloworld-server ${ETCH_LIBRARY} ${CAPU_LIBRARY} pthread rt)
-set_target_properties(etch-cpp-helloworld-server PROPERTIES COMPILE_FLAGS "-m32 -g" LINK_FLAGS "-m32")
-ELSEIF(WIN32)
-target_link_libraries(etch-cpp-helloworld-server ${ETCH_LIBRARY} ${CAPU_LIBRARY})
-IF (BUILD_CHECK_MEMORY)
-  file (COPY ${VLD}/vld.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
-  file (COPY ${VLD}/bin/dbghelp.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
-  file (COPY ${VLD}/bin/vld.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
-  target_link_libraries (etch-cpp-helloworld-server ${VLD}/lib/vld.lib)
-ENDIF (BUILD_CHECK_MEMORY)
-ENDIF ()
+IF (TARGET_OS STREQUAL "Linux")
+  target_link_libraries(etch-cpp-helloworld-server etch capu pthread rt)
+  set_target_properties(etch-cpp-helloworld-server PROPERTIES COMPILE_FLAGS "-m32 -g" LINK_FLAGS "-m32")
+ELSEIF(TARGET_OS STREQUAL "Windows")
+  target_link_libraries(etch-cpp-helloworld-server etch capu)
+  IF (BUILD_CHECK_MEMORY)
+    file (COPY ${VLD}/vld.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+    file (COPY ${VLD}/bin/dbghelp.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+    file (COPY ${VLD}/bin/vld.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+    target_link_libraries (etch-cpp-helloworld-server ${VLD}/lib/vld.lib)
+  ENDIF (BUILD_CHECK_MEMORY)
+ELSEIF(TARGET_OS STREQUAL "QNX")
+  target_link_libraries (etch-cpp-helloworld-server etch capu c socket)
+ENDIF()
+
 set_target_properties(etch-cpp-helloworld-server PROPERTIES OUTPUT_NAME "helloworld-server")
 
 #====================================================================================#
@@ -150,19 +120,20 @@ add_executable(etch-cpp-helloworld-clien
  target/generated-sources/cpp/src/ValueFactoryHelloWorld.cpp
 )
 
-
-IF (UNIX)
-target_link_libraries(etch-cpp-helloworld-client ${ETCH_LIBRARY} ${CAPU_LIBRARY} pthread rt)
-set_target_properties(etch-cpp-helloworld-client PROPERTIES COMPILE_FLAGS "-m32 -g" LINK_FLAGS "-m32")
-ELSEIF(WIN32)
-target_link_libraries(etch-cpp-helloworld-client ${ETCH_LIBRARY} ${CAPU_LIBRARY})
-IF (BUILD_CHECK_MEMORY)
-  file (COPY ${VLD}/vld.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
-  file (COPY ${VLD}/bin/dbghelp.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
-  file (COPY ${VLD}/bin/vld.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
-  target_link_libraries (etch-cpp-helloworld-client ${VLD}/lib/vld.lib)
-ENDIF (BUILD_CHECK_MEMORY)
-ENDIF ()
+IF (TARGET_OS STREQUAL "Linux")
+  target_link_libraries(etch-cpp-helloworld-client etch capu pthread rt)
+  set_target_properties(etch-cpp-helloworld-client PROPERTIES COMPILE_FLAGS "-m32 -g" LINK_FLAGS "-m32")
+ELSEIF(TARGET_OS STREQUAL "Windows")
+  target_link_libraries(etch-cpp-helloworld-client etch capu )
+  IF (BUILD_CHECK_MEMORY)
+    file (COPY ${VLD}/vld.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+    file (COPY ${VLD}/bin/dbghelp.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+    file (COPY ${VLD}/bin/vld.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
+    target_link_libraries (etch-cpp-helloworld-client ${VLD}/lib/vld.lib)
+  ENDIF (BUILD_CHECK_MEMORY)
+ELSEIF(TARGET_OS STREQUAL "QNX")
+  target_link_libraries (etch-cpp-helloworld-client etch capu c socket)
+ENDIF()
 
 set_target_properties(etch-cpp-helloworld-client PROPERTIES OUTPUT_NAME "helloworld-client")
 

Modified: etch/trunk/examples/helloworld/cpp/build.xml
URL: http://svn.apache.org/viewvc/etch/trunk/examples/helloworld/cpp/build.xml?rev=1460559&r1=1460558&r2=1460559&view=diff
==============================================================================
--- etch/trunk/examples/helloworld/cpp/build.xml (original)
+++ etch/trunk/examples/helloworld/cpp/build.xml Mon Mar 25 09:36:42 2013
@@ -94,25 +94,78 @@
    </target>
 
    <target name="build-cpp" depends="generate-sources" if="USE.cmake">
-     <cmake srcdir="${basedir}" bindir="${basedir}/target" buildtype="Debug" >
-     <!-- <generator name="Visual Studio 8 2005" platform="windows" />-->
-      <variable name="ETCH_INCLUDE_CAPU_DIR" type="PATH" value="${Etch.basedir}/binding-cpp/runtime/lib/capu/deliverable/capu/include/capu" />
-      <variable name="ETCH_HOME" type="PATH" value="${etch.home}" />
-     </cmake>
-     <copy todir="${bin}" flatten="true">
-        <fileset dir="${target}" >
-           <include name="helloworld-client" />
-           <include name="helloworld-server" />
-           <include name="Debug/helloworld-client.exe" />
-           <include name="Debug/helloworld-server.exe" />
-        </fileset>
-     </copy>
-     <chmod perm="+x">
-        <fileset dir="${bin}">
-           <include name="helloworld-client" />
-           <include name="helloworld-server" />
-        </fileset>
-     </chmod>
+       <if>
+            <not><isset property="${target.platforms}"/></not>
+            <then>
+                <echo level="warn">No target.platforms set. Trying to build for detected host platform...</echo>
+                    <if>
+                        <os family="windows" />
+                        <then>
+                            <property name="target.platforms" value="Windows_X86_32"/>
+                        </then>
+                    </if>
+                    <if>
+                        <os family="unix" />
+                        <then>
+                            <property name="target.platforms" value="Linux_X86_32"/>
+                        </then>
+                    </if>
+            </then>
+        </if>
+
+        <if>
+            <equals arg1="${target.platforms}" arg2=""/>
+            <then>
+                <fail message="Not able to detect platform. target.platforms is not set. Aborting."/>
+            </then>
+        </if>
+        
+        <var  name="platform" value="${target.platforms}"/>
+        
+        <property name="defaultCMakeToolchainDir" value="${Etch.basedir}/binding-cpp/runtime/toolchains/"/>
+        <if>
+            <isset property="target.platforms.${platform}.toolchainfile"/>
+            <then>
+                <propertycopy name="cmake.toolchainfile" from="target.platforms.${platform}.toolchainfile" />
+            </then>
+            <else>
+                <property name="cmake.toolchainfile" value="${defaultCMakeToolchainDir}/${platform}.toolchain"/>
+            </else>
+        </if>
+        <if>
+            <isset property="target.platforms.${platform}.generator"/>
+            <then>
+                <!-- use specified generator -->
+                <propertycopy name="cmake.generator" from="target.platforms.${platform}.generator" />
+                <echo>Configuring CMake build</echo>
+                <echo>Using generator: ${cmake.generator}</echo>
+                <echo>Using toolchain file: ${cmake.toolchainfile}</echo>
+                
+                <!-- CMake configuration -->
+                <cmake srcdir="${basedir}" bindir="${basedir}/target/${platform}/${Etch.build.target}" buildtype="${Etch.build.target}" >
+                    <generator name="${cmake.generator}" />
+                    <variable name="ETCH_HOME" type="PATH" value="${etch.home}" />
+                    <variable name="ETCH_BUILD_TARGET" type="STRING" value="${Etch.build.target}" />
+                    <variable name="CMAKE_TOOLCHAIN_FILE" type="FILEPATH" value="${cmake.toolchainfile}" />
+                </cmake>
+
+            </then>
+            <else>
+                <!-- try default generator -->
+                <echo>Configuring CMake build</echo>
+                <echo>Using default generator</echo>
+                <echo>Using toolchain file: ${cmake.toolchainfile}</echo>
+                
+                <!-- CMake configuration -->
+                <cmake srcdir="${basedir}" bindir="${basedir}/target/${platform}/${Etch.build.target}" buildtype="${Etch.build.target}" >
+                    <variable name="ETCH_INCLUDE_CAPU_DIR" type="PATH" value="${Etch.basedir}/binding-cpp/runtime/lib/capu/deliverable/capu/include/capu" />
+                    <variable name="CMAKE_TOOLCHAIN_FILE" type="FILEPATH" value="${cmake.toolchainfile}" />
+                    <variable name="ETCH_HOME" type="PATH" value="${etch.home}" />
+                </cmake>
+            </else>
+        </if>
+        
+
    </target>
 
     <target name="build" depends="build-cpp" />
@@ -132,7 +185,7 @@
      ======================
      To run cpp example:
 
-     > cd cpp\target\bin
+     > cd cpp\target\$Platform\$BuildTarget>
      > ./helloworld-server.exe
      > ./helloworld-client.exe
 
@@ -142,7 +195,7 @@
 
     <!-- build everything -->
     <target name="init-debug" >
-        <property name="build.target" value="Debug" />
+        <property name="Etch.build.target" value="Debug" />
     </target>
 
     <target name="init-release" >

Modified: etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldClient.cpp
URL: http://svn.apache.org/viewvc/etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldClient.cpp?rev=1460559&r1=1460558&r2=1460559&view=diff
==============================================================================
--- etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldClient.cpp (original)
+++ etch/trunk/examples/helloworld/cpp/src/main/src/MainHelloWorldClient.cpp Mon Mar 25 09:36:42 2013
@@ -12,9 +12,7 @@
 #include "MainHelloWorldClient.h"
 #include "ImplHelloWorldClient.h"
 #include "transport/EtchTransportData.h"
-#ifdef BUILD_CHECK_MEMORY
-#include "vld.h"
-#endif
+
 
 using namespace org_apache_etch_examples_helloworld_HelloWorld;