瀏覽代碼

Make sure there is no race condition for amalgamation.

This should fix additional build errors on Travis and should again allow multiprocessor compilation on AppVeyor
Stefan Profanter 7 年之前
父節點
當前提交
84f712d0db
共有 2 個文件被更改,包括 8 次插入3 次删除
  1. 6 1
      CMakeLists.txt
  2. 2 2
      examples/CMakeLists.txt

+ 6 - 1
CMakeLists.txt

@@ -406,7 +406,7 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.c
                            ${OPEN62541_VER_COMMIT} ${CMAKE_CURRENT_BINARY_DIR}/open62541.c ${internal_headers} ${lib_sources}
                    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py ${internal_headers} ${lib_sources})
 
-ADD_CUSTOM_TARGET(open625451_amalgamation DEPENDS ${PROJECT_BINARY_DIR}/open62541.h
+ADD_CUSTOM_TARGET(open62541_amalgamation DEPENDS ${PROJECT_BINARY_DIR}/open62541.h
                                                   ${PROJECT_BINARY_DIR}/open62541.c)
 
 # example information model from nodeset xml
@@ -436,6 +436,11 @@ assign_source_group(${exported_headers})
 
 if(UA_ENABLE_AMALGAMATION)
     add_library(open62541-object OBJECT ${PROJECT_BINARY_DIR}/open62541.c ${PROJECT_BINARY_DIR}/open62541.h)
+
+    # make sure the open62541_amalgamation target builds before so that amalgamation is finished and it is not executed again for open62541-object 
+    # and thus may overwrite the amalgamation result during multiprocessor compilation
+    add_dependencies(open62541-object open62541_amalgamation)
+
     target_include_directories(open62541-object PRIVATE ${PROJECT_BINARY_DIR})
     if(UA_COMPILE_AS_CXX)
         set_source_files_properties(${PROJECT_BINARY_DIR}/open62541.c PROPERTIES LANGUAGE CXX)

+ 2 - 2
examples/CMakeLists.txt

@@ -40,7 +40,7 @@ macro(add_example EXAMPLE_NAME EXAMPLE_SOURCE)
   add_executable(${EXAMPLE_NAME} ${STATIC_OBJECTS} ${EXAMPLE_SOURCE})
   target_link_libraries(${EXAMPLE_NAME} ${LIBS})
   assign_source_group(${EXAMPLE_SOURCE})
-  add_dependencies(${EXAMPLE_NAME} open625451_amalgamation)
+  add_dependencies(${EXAMPLE_NAME} open62541_amalgamation)
   set_target_properties(${EXAMPLE_NAME} PROPERTIES FOLDER "open62541/examples")
   if(UA_COMPILE_AS_CXX)
     set_source_files_properties(${EXAMPLE_SOURCE} PROPERTIES LANGUAGE CXX)
@@ -126,4 +126,4 @@ if(UA_ENABLE_DISCOVERY)
     if(UA_ENABLE_DISCOVERY_MULTICAST)
         add_example(discovery_server_multicast discovery/server_multicast.c)
     endif()
-endif()
+endif()