Browse Source

edited for compatiblity to Windows with MinGW

LEvertz 10 years ago
parent
commit
9ac88930b6
3 changed files with 11 additions and 3 deletions
  1. 6 2
      CMakeLists.txt
  2. 4 0
      src/ua_types.c
  3. 1 1
      src/ua_util.h

+ 6 - 2
CMakeLists.txt

@@ -39,14 +39,14 @@ set(lib_sources src/ua_types.c
 
 # compiler flags
 if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
-add_definitions(-std=c99 -pedantic -pipe -fvisibility=hidden -fPIC -Wall -Wextra -Werror -Wformat
+add_definitions(-std=c99 -pedantic -pipe -Wall -Wextra -Werror -Wformat
                 -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wreturn-type -Wsign-compare -Wmultichar
                 -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security -ffunction-sections -fdata-sections)
     if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
         add_definitions(-Wformat-nonliteral -Wl,--gc-sections)
     endif()
 	if(NOT WIN32)
-	    add_definitions(-fstack-protector)
+	    add_definitions(-fstack-protector -fPIC -fvisibility=hidden)
 	endif()
 endif()
 add_definitions(-Dopen62541_EXPORTS) # dllexport/dllimport differentiation in ua_config.h when building the lib on windows
@@ -161,6 +161,8 @@ if(CLIENT)
 endif()
 
 # build example server
+option(EXAMPLESERVER "Build a test server" OFF)
+if(EXAMPLESERVER)
 set(server_sources examples/opcuaServer.c
                    examples/logger_stdout.c)
 if(NOT ENABLE_MULTITHREADING)
@@ -177,6 +179,8 @@ if(ENABLE_MULTITHREADING)
     find_package(LibUV REQUIRED)
     target_link_libraries(exampleServer urcu-cds urcu uv)
 endif()
+endif()
+
 
 # build unit tests
 option(ENABLE_UNIT_TESTS "Run unit tests after building" OFF)

+ 4 - 0
src/ua_types.c

@@ -183,11 +183,15 @@ UA_Int32 UA_String_copyprintf(char const *fmt, UA_String *dst, ...) {
     UA_Int32 len;
     va_list  ap;
     va_start(ap, dst);
+#ifndef __MINGW32__
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
+#endif
     // vsnprintf should only take a literal and no variable to be secure
     len = vsnprintf(src, UA_STRING_COPYPRINTF_BUFSIZE, fmt, ap);
+#ifndef __MINGW32__
 #pragma GCC diagnostic pop
+#endif
     va_end(ap);
     if(len < 0) {  // FIXME: old glibc 2.0 would return -1 when truncated
         dst->length = 0;

+ 1 - 1
src/ua_util.h

@@ -9,7 +9,7 @@
 #include "ua_config.h"
 
 #include <stddef.h> /* Needed for sys/queue.h */
-#ifndef MSVC
+#if !defined(MSVC) && !defined(__MINGW32__)
 #include <sys/queue.h>
 #else
 #include "queue.h"