瀏覽代碼

cmake: Remove UA_NO_AMALGAMATION and use UA_ENABLE_AMALGAMATION instead

Since default build is without amalgamation, we should assume that and only
ifdefs is amalgamation is enabled
Stefan Profanter 5 年之前
父節點
當前提交
36641ad6a5

+ 0 - 2
CMakeLists.txt

@@ -819,7 +819,6 @@ if(UA_ENABLE_AMALGAMATION)
     add_dependencies(open62541-amalgamation-source open62541-generator-namespace)
     add_dependencies(open62541-amalgamation-header open62541-generator-namespace)
 else()
-    add_definitions(-DUA_NO_AMALGAMATION)
     add_library(open62541-object OBJECT ${lib_sources} ${internal_headers} ${exported_headers})
     add_dependencies(open62541-object
                      open62541-generator-types
@@ -922,7 +921,6 @@ add_custom_target(lint ${CLANG_TIDY_PROGRAM}
                   -I${PROJECT_SOURCE_DIR}/src/server
                   -I${PROJECT_SOURCE_DIR}/src/client
                   -I${PROJECT_BINARY_DIR}/src_generated
-                  -DUA_NO_AMALGAMATION
                   DEPENDS ${lib_sources}
                   COMMENT "Run clang-tidy on the library")
 add_dependencies(lint open62541)

+ 5 - 0
examples/CMakeLists.txt

@@ -9,6 +9,11 @@ set(examples_headers
     ${PROJECT_SOURCE_DIR}/examples/common.h
     )
 
+
+if(UA_ENABLE_AMALGAMATION)
+    add_definitions(-DUA_ENABLE_AMALGAMATION)
+endif()
+
 #############################
 # Compiled binaries folders #
 #############################

+ 7 - 2
examples/common.h

@@ -1,8 +1,13 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#include "ua_types.h"
-#include "ua_types_generated_handling.h"
+
+#ifdef UA_ENABLE_AMALGAMATION
+# include <open62541.h>
+#else
+# include "ua_types.h"
+# include "ua_types_generated_handling.h"
+#endif
 
 /* loadFile parses the certificate file.
  *

+ 3 - 3
examples/nodeset/server_nodeset_plcopen.c

@@ -1,12 +1,12 @@
 /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
 
-#ifdef UA_NO_AMALGAMATION
+#ifdef UA_ENABLE_AMALGAMATION
+#include "open62541.h"
+#else
 #include "ua_server.h"
 #include "ua_log_stdout.h"
 #include "ua_config_default.h"
-#else
-#include "open62541.h"
 #endif
 
 #include <signal.h>

+ 9 - 4
examples/server_ctt.c

@@ -5,10 +5,15 @@
 #define _CRT_SECURE_NO_WARNINGS /* disable fopen deprication warning in msvs */
 #endif
 
-#include <ua_server.h>
-#include <ua_config_default.h>
-#include <ua_log_stdout.h>
-#include "common.h"
+#ifdef UA_ENABLE_AMALGAMATION
+# include <open62541.h>
+#else
+# include <ua_server.h>
+# include <ua_config_default.h>
+# include <ua_log_stdout.h>
+#endif
+
+# include "common.h"
 
 #include <signal.h>
 

+ 3 - 0
include/ua_config.h.in

@@ -20,6 +20,9 @@
  * Changing the feature options has no effect on a pre-compiled library. */
 
 #define UA_LOGLEVEL ${UA_LOGLEVEL}
+#ifndef UA_ENABLE_AMALGAMATION
+#cmakedefine UA_ENABLE_AMALGAMATION
+#endif
 #cmakedefine UA_ENABLE_METHODCALLS
 #cmakedefine UA_ENABLE_NODEMANAGEMENT
 #cmakedefine UA_ENABLE_SUBSCRIPTIONS

+ 1 - 1
src/server/ua_server_discovery_mdns.c

@@ -11,7 +11,7 @@
 
 #ifdef UA_ENABLE_DISCOVERY_MULTICAST
 
-#ifdef UA_NO_AMALGAMATION
+#ifndef UA_ENABLE_AMALGAMATION
 #include "mdnsd/libmdnsd/xht.h"
 #include "mdnsd/libmdnsd/sdtxt.h"
 #endif

+ 11 - 5
tools/generate_datatypes.py

@@ -540,11 +540,11 @@ printh('''/* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + '
 #ifndef ''' + outname.upper() + '''_GENERATED_H_
 #define ''' + outname.upper() + '''_GENERATED_H_
 
-#ifdef UA_NO_AMALGAMATION
+#ifdef UA_ENABLE_AMALGAMATION
+#include "open62541.h"
+#else
 #include "ua_types.h"
 ''' + ('#include "ua_types_generated.h"\n' if outname != "ua_types" else '') + '''
-#else
-#include "open62541.h"
 #endif
 
 _UA_BEGIN_DECLS
@@ -644,8 +644,14 @@ printe('''/* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + '
  * on host ''' + platform.uname()[1] + ''' by user ''' + getpass.getuser() + \
        ''' at ''' + time.strftime("%Y-%m-%d %I:%M:%S") + ''' */
 
-#include "ua_types_encoding_binary.h"
-#include "''' + outname + '''_generated.h"''')
+#ifdef UA_ENABLE_AMALGAMATION
+# include "open62541.h"
+#else
+# include "ua_types_encoding_binary.h"
+# include "''' + outname + '''_generated.h"
+#endif
+
+''')
 
 for t in filtered_types:
     printe("\n/* " + t.name + " */")

+ 9 - 5
tools/nodeset_compiler/backend_open62541.py

@@ -158,10 +158,7 @@ def generateOpen62541Code(nodeset, outfilename, generate_ns0=False, internal_hea
 """ % (outfilebase.upper(), outfilebase.upper()))
     if internal_headers:
         writeh("""
-#ifdef UA_NO_AMALGAMATION
-# include "ua_server.h"
-# include "ua_types_encoding_binary.h"
-#else
+#ifdef UA_ENABLE_AMALGAMATION
 # include "open62541.h"
 
 /* The following declarations are in the open62541.c file so here's needed when compiling nodesets externally */
@@ -190,13 +187,20 @@ UA_findDataTypeByBinary(const UA_NodeId *typeId);
 
 # endif // UA_Nodestore_remove
 
+#else // UA_ENABLE_AMALGAMATION
+# include "ua_server.h"
+# include "ua_types_encoding_binary.h"
 #endif
 
 %s
 """ % (additionalHeaders))
     else:
         writeh("""
-#include "ua_server.h"
+#ifdef UA_ENABLE_AMALGAMATION
+# include "open62541.h"
+#else
+# include "ua_server.h"
+#endif
 """)
     writeh("""
 _UA_BEGIN_DECLS