You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by th...@apache.org on 2011/10/12 19:11:23 UTC

svn commit: r1182482 - in /avro/trunk: CHANGES.txt lang/c++/ lang/c++/CMakeLists.txt lang/c++/build.sh

Author: thiru
Date: Wed Oct 12 17:11:22 2011
New Revision: 1182482

URL: http://svn.apache.org/viewvc?rev=1182482&view=rev
Log:
AVRO-913. CMake/C++ build should work for out-of-tree builds

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/c++/   (props changed)
    avro/trunk/lang/c++/CMakeLists.txt
    avro/trunk/lang/c++/build.sh

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1182482&r1=1182481&r2=1182482&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Wed Oct 12 17:11:22 2011
@@ -115,6 +115,8 @@ Avro 1.6.0 (unreleased)
 
     AVRO-915. Large number of warnings in C++ builds. (thiru)
 
+    AVRO-913. CMake/C++ build should work for out-of-tree builds.  (Nebojsa Sabovic via thiru)
+
   BUG FIXES
 
     AVRO-824. Java: Fix usage message of BinaryFragmentToJsonTool.

Propchange: avro/trunk/lang/c++/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Oct 12 17:11:22 2011
@@ -1,9 +1,3 @@
-CMakeFiles
-CMakeCache.txt
-CPackSourceConfig.cmake
-CPackConfig.cmake
-Makefile
-cmake_install.cmake
 build
 test.avro
 doc

Modified: avro/trunk/lang/c++/CMakeLists.txt
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/CMakeLists.txt?rev=1182482&r1=1182481&r2=1182482&view=diff
==============================================================================
--- avro/trunk/lang/c++/CMakeLists.txt (original)
+++ avro/trunk/lang/c++/CMakeLists.txt Wed Oct 12 17:11:22 2011
@@ -29,10 +29,6 @@ endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR
 
 set (AVRO_VERSION_MAJOR ${AVRO_VERSION})
 set (AVRO_VERSION_MINOR "0")
-set (BUILD_DIRECTORY build)
-set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BUILD_DIRECTORY})
-set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIRECTORY})
-set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BUILD_DIRECTORY})
 
 project (Avro-cpp)
 
@@ -43,7 +39,7 @@ endif ()
 find_package (Boost 1.38 REQUIRED
     COMPONENTS regex filesystem system program_options)
 
-include_directories (api ${BUILD_DIRECTORY} ${Boost_INCLUDE_DIRS})
+include_directories (api ${CMAKE_CURRENT_BINARY_DIR} ${Boost_INCLUDE_DIRS})
 
 set (SOURCE_FILES
         impl/Compiler.cc impl/CompilerNode.cc impl/Node.cc
@@ -57,12 +53,18 @@ set (SOURCE_FILES
         impl/parsing/ValidatingCodec.cc
         impl/parsing/JsonCodec.cc
         impl/parsing/ResolvingDecoder.cc
-        ${BUILD_DIRECTORY}/AvroYacc.cc ${BUILD_DIRECTORY}/AvroLex.cc)
+        ${CMAKE_CURRENT_BINARY_DIR}/AvroYacc.cc ${CMAKE_CURRENT_BINARY_DIR}/AvroLex.cc)
 
 add_library (avrocpp SHARED ${SOURCE_FILES})
 
 add_library (avrocpp_s STATIC ${SOURCE_FILES})
 
+set_target_properties (avrocpp PROPERTIES
+    VERSION ${AVRO_VERSION_MAJOR}.${AVRO_VERSION_MINOR})
+
+set_target_properties (avrocpp_s PROPERTIES
+    VERSION ${AVRO_VERSION_MAJOR}.${AVRO_VERSION_MINOR})
+
 target_link_libraries (avrocpp ${Boost_LIBRARIES})
 
 add_executable (precompile test/precompile.cc)
@@ -71,72 +73,80 @@ add_dependencies(avrocpp parser lexer)
 
 target_link_libraries (precompile avrocpp ${Boost_LIBRARIES})
 
-add_custom_command (OUTPUT ${BUILD_DIRECTORY}/bigrecord
-    COMMAND precompile jsonschemas/bigrecord ${BUILD_DIRECTORY}/bigrecord
+add_custom_command (OUTPUT bigrecord
+    COMMAND precompile ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/bigrecord
+        bigrecord
     DEPENDS precompile)
 
 add_custom_target (testgen
-    COMMAND python ../scripts/gen-cppcode.py -n testgen
-    -i bigrecord -o testgen.hh
-    WORKING_DIRECTORY ${BUILD_DIRECTORY}
-    DEPENDS ${BUILD_DIRECTORY}/bigrecord)
-
-add_custom_command (OUTPUT ${BUILD_DIRECTORY}/bigrecord2
-    COMMAND precompile jsonschemas/bigrecord2 ${BUILD_DIRECTORY}/bigrecord2
+    COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen-cppcode.py
+        -n testgen -i bigrecord -o testgen.hh
+    DEPENDS bigrecord)
+
+add_custom_command (OUTPUT bigrecord2
+    COMMAND precompile ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/bigrecord2
+        bigrecord2
     DEPENDS precompile)
 
 add_custom_target (testgen2
-    COMMAND python ../scripts/gen-cppcode.py -n testgen2
-    -i bigrecord2 -o testgen2.hh
-    WORKING_DIRECTORY ${BUILD_DIRECTORY}
-    DEPENDS ${BUILD_DIRECTORY}/bigrecord2)
-
-add_custom_command (OUTPUT ${BUILD_DIRECTORY}/AvroYacc.cc
-    COMMAND bison --defines=AvroYacc.hh -o AvroYacc.cc ../parser/AvroYacc.yy
-    WORKING_DIRECTORY ${BUILD_DIRECTORY})
-
-add_custom_command (OUTPUT ${BUILD_DIRECTORY}/AvroLex.cc
-    COMMAND flex -oAvroLex.cc ../parser/AvroLex.ll
-    WORKING_DIRECTORY ${BUILD_DIRECTORY})
+    COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen-cppcode.py
+        -n testgen2 -i bigrecord2 -o testgen2.hh
+    DEPENDS bigrecord2)
+
+add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/AvroYacc.cc
+    COMMAND bison --defines=${CMAKE_CURRENT_BINARY_DIR}/AvroYacc.hh -o ${CMAKE_CURRENT_BINARY_DIR}/AvroYacc.cc
+        ${CMAKE_CURRENT_SOURCE_DIR}/parser/AvroYacc.yy)
+
+add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/AvroLex.cc
+    COMMAND flex -oAvroLex.cc
+        ${CMAKE_CURRENT_SOURCE_DIR}/parser/AvroLex.ll)
     
 add_custom_target (bigrecord_hh
-    COMMAND avrogencpp -i jsonschemas/bigrecord
-        -o ${BUILD_DIRECTORY}/bigrecord.hh -n testgen
+    COMMAND avrogencpp
+        -i ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/bigrecord
+        -o bigrecord.hh -n testgen
     DEPENDS avrogencpp)
 
 add_custom_target (bigrecord2_hh
-    COMMAND avrogencpp -i jsonschemas/bigrecord2
-        -o ${BUILD_DIRECTORY}/bigrecord2.hh -n testgen2
+    COMMAND avrogencpp
+        -i ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/bigrecord2
+        -o bigrecord2.hh -n testgen2
     DEPENDS avrogencpp)
 
 add_custom_target (union_array_union_hh
-    COMMAND avrogencpp -i jsonschemas/union_array_union
-        -o ${BUILD_DIRECTORY}/union_array_union.hh -n uau
+    COMMAND avrogencpp
+        -i ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/union_array_union
+        -o union_array_union.hh -n uau
     DEPENDS avrogencpp)
 
 add_custom_target (union_map_union_hh
-    COMMAND avrogencpp -i jsonschemas/union_map_union
-        -o ${BUILD_DIRECTORY}/union_map_union.hh -n umu
+    COMMAND avrogencpp
+        -i ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/union_map_union
+        -o union_map_union.hh -n umu
     DEPENDS avrogencpp)
 
 add_custom_target (union_conflict_hh
-    COMMAND avrogencpp -i jsonschemas/union_conflict
-        -o ${BUILD_DIRECTORY}/union_conflict.hh -n uc -U
+    COMMAND avrogencpp
+        -i ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/union_conflict
+        -o union_conflict.hh -n uc -U
     DEPENDS avrogencpp)
 
 add_custom_target (recursive_hh
-    COMMAND avrogencpp -i jsonschemas/recursive
-        -o ${BUILD_DIRECTORY}/recursive.hh -n rec
+    COMMAND avrogencpp
+        -i ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/recursive
+        -o recursive.hh -n rec
     DEPENDS avrogencpp)
 
 add_custom_target (reuse_hh
-    COMMAND avrogencpp -i jsonschemas/reuse
-        -o ${BUILD_DIRECTORY}/reuse.hh -n reu
+    COMMAND avrogencpp
+        -i ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/reuse
+        -o reuse.hh -n reu
     DEPENDS avrogencpp)
 
 add_custom_target (circulardep_hh
-    COMMAND avrogencpp -i jsonschemas/circulardep
-        -o ${BUILD_DIRECTORY}/circulardep.hh -n reu
+    COMMAND avrogencpp
+        -i ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/circulardep
+        -o circulardep.hh -n reu
     DEPENDS avrogencpp)
 
 macro (test name)

Modified: avro/trunk/lang/c++/build.sh
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/build.sh?rev=1182482&r1=1182481&r2=1182482&view=diff
==============================================================================
--- avro/trunk/lang/c++/build.sh (original)
+++ avro/trunk/lang/c++/build.sh Wed Oct 12 17:11:22 2011
@@ -44,7 +44,7 @@ DOC_CPP=$BUILD/$AVRO_DOC/api/cpp
 DIST_DIR=../../dist/cpp
 TARFILE=../dist/cpp/$AVRO_CPP.tar.gz 
 
-cmake -G "Unix Makefiles"
+(mkdir -p build; cd build; cmake -G "Unix Makefiles" ..)
 for target in "$@"
 do
 
@@ -76,15 +76,15 @@ function do_dist() {
 
 case "$target" in
     test)
-    make
-    ./build/buffertest
-    ./build/unittest
-    ./build/testgentest
-    ./build/CodecTests
-    ./build/StreamTests
-    ./build/SpecificTests
-    ./build/AvrogencppTests
-    ./build/DataFileTests
+    (cd build && make && cd ..
+        ./build/buffertest
+        ./build/unittest
+        ./build/testgentest
+        ./build/CodecTests
+        ./build/StreamTests
+        ./build/SpecificTests
+        ./build/AvrogencppTests
+        ./build/DataFileTests)
 	;;
 
     dist)
@@ -93,7 +93,7 @@ case "$target" in
     ;;
 
     clean)
-    make clean
+    (cd build && make clean)
 	;;
 
     *)