Petr Kubánek created AVRO-4113:
----------------------------------

             Summary: Don't generate test C++ files when tests aren't selected
                 Key: AVRO-4113
                 URL: https://issues.apache.org/jira/browse/AVRO-4113
             Project: Apache Avro
          Issue Type: Improvement
          Components: c++
            Reporter: Petr Kubánek


The gen macro (which converts interfaces to c++ bindings) is called when tests 
aren't needed. This works fine unless you try to cross-compile Avro - then of 
course avrocppgen is a binary, that cannot be run on your host, and so the 
compilation fails.

This patch should make it possible to skip gen when tests aren't requested:

{code}
diff --git a/lang/c++/CMakeLists.txt b/lang/c++/CMakeLists.txt
index 8e7f12bb5..47d0d42de 100644
--- a/lang/c++/CMakeLists.txt
+++ b/lang/c++/CMakeLists.txt
@@ -170,6 +170,13 @@ if (AVRO_BUILD_EXECUTABLES)

     target_link_libraries (precompile avrocpp_s)

+    add_executable (avrogencpp impl/avrogencpp.cc)
+    target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES})
+endif ()
+
+if (AVRO_BUILD_TESTS)
+    enable_testing()
+
     macro (gen file ns)
         add_custom_command (OUTPUT ${file}.hh
             COMMAND avrogencpp
@@ -201,13 +208,6 @@ if (AVRO_BUILD_EXECUTABLES)
     gen (big_union big_union)
     gen (union_redundant_types redundant_types)

-    add_executable (avrogencpp impl/avrogencpp.cc)
-    target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES})
-endif ()
-
-if (AVRO_BUILD_TESTS)
-    enable_testing()
-
     macro (unittest name)
         add_executable (${name} test/${name}.cc)
         target_link_libraries (${name} avrocpp_s ${Boost_LIBRARIES} 
${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES})
{code}

I marked that as blocked, as without that I will be unable to get 
openembedded/NI cRIO compilation working without some manual tinkering.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to