|
@@ -48,19 +48,30 @@ if(CMAKE_COMPILER_IS_GNUCC OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang")
|
|
# binary size reduction settings
|
|
# binary size reduction settings
|
|
add_definitions(-ffunction-sections -fdata-sections -fno-stack-protector -fno-unwind-tables
|
|
add_definitions(-ffunction-sections -fdata-sections -fno-stack-protector -fno-unwind-tables
|
|
-fno-asynchronous-unwind-tables -fno-math-errno -fmerge-all-constants -fno-ident)
|
|
-fno-asynchronous-unwind-tables -fno-math-errno -fmerge-all-constants -fno-ident)
|
|
- set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--gc-sections")
|
|
|
|
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
|
|
|
|
- set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # cmake sets -rdynamic by default
|
|
|
|
|
|
+ if (APPLE)
|
|
|
|
+ set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,-dead_strip")
|
|
|
|
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-dead_strip")
|
|
|
|
+ else()
|
|
|
|
+ set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--gc-sections")
|
|
|
|
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
|
|
|
|
+ endif()
|
|
|
|
+ set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # cmake sets -rdynamic by default
|
|
if(NOT WIN32)
|
|
if(NOT WIN32)
|
|
if(NOT CYGWIN)
|
|
if(NOT CYGWIN)
|
|
add_definitions(-fvisibility=hidden -fPIC)
|
|
add_definitions(-fvisibility=hidden -fPIC)
|
|
- set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,--build-id=none")
|
|
|
|
|
|
+ if (NOT APPLE)
|
|
|
|
+ set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,-z,norelro -Wl,--hash-style=gnu -Wl,--build-id=none")
|
|
|
|
+ endif()
|
|
endif()
|
|
endif()
|
|
endif()
|
|
endif()
|
|
if(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" OR CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
if(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" OR CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -s")
|
|
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -s")
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -s")
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -s")
|
|
endif()
|
|
endif()
|
|
|
|
+ if (APPLE)
|
|
|
|
+ set(CMAKE_MACOSX_RPATH 1)
|
|
|
|
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_DARWIN_C_SOURCE=1")
|
|
|
|
+ endif()
|
|
endif()
|
|
endif()
|
|
|
|
|
|
# build the main library
|
|
# build the main library
|
|
@@ -220,7 +231,10 @@ if(EXTENSION_UDP)
|
|
message(STATUS "Extensions: enabling udp")
|
|
message(STATUS "Extensions: enabling udp")
|
|
add_definitions(-DEXTENSION_UDP)
|
|
add_definitions(-DEXTENSION_UDP)
|
|
add_executable(exampleServerUDP $<TARGET_OBJECTS:open62541-object> examples/networklayer_udp.c examples/server_udp.c)
|
|
add_executable(exampleServerUDP $<TARGET_OBJECTS:open62541-object> examples/networklayer_udp.c examples/server_udp.c)
|
|
- target_link_libraries(exampleServerUDP rt)
|
|
|
|
|
|
+ target_link_libraries(exampleServerUDP urcu-cds urcu urcu-common)
|
|
|
|
+ if (NOT APPLE)
|
|
|
|
+ target_link_libraries(exampleServerUDP rt)
|
|
|
|
+ endif()
|
|
endif()
|
|
endif()
|
|
|
|
|
|
option(EXTENSION_STATELESS "Enable stateless extension" OFF)
|
|
option(EXTENSION_STATELESS "Enable stateless extension" OFF)
|
|
@@ -263,6 +277,9 @@ target_compile_definitions(open62541 PRIVATE -DUA_DYNAMIC_LINKING)
|
|
if(WIN32)
|
|
if(WIN32)
|
|
target_link_libraries(open62541 ws2_32) #since networklayer_tcp is linked into the amalgate
|
|
target_link_libraries(open62541 ws2_32) #since networklayer_tcp is linked into the amalgate
|
|
endif()
|
|
endif()
|
|
|
|
+if(ENABLE_MULTITHREADING)
|
|
|
|
+ target_link_libraries(open62541 urcu-cds urcu urcu-common pthread)
|
|
|
|
+endif()
|
|
|
|
|
|
# build language bindings for the library
|
|
# build language bindings for the library
|
|
option(ENABLE_BINDING_LUA "Build Lua bindings" OFF)
|
|
option(ENABLE_BINDING_LUA "Build Lua bindings" OFF)
|
|
@@ -294,7 +311,7 @@ if(BUILD_EXAMPLESERVER)
|
|
if(WIN32)
|
|
if(WIN32)
|
|
target_link_libraries(server_static ws2_32)
|
|
target_link_libraries(server_static ws2_32)
|
|
target_link_libraries(server ws2_32)
|
|
target_link_libraries(server ws2_32)
|
|
- else()
|
|
|
|
|
|
+ elseif(NOT APPLE)
|
|
target_link_libraries(server_static rt)
|
|
target_link_libraries(server_static rt)
|
|
target_link_libraries(server rt)
|
|
target_link_libraries(server rt)
|
|
endif()
|
|
endif()
|
|
@@ -331,7 +348,7 @@ if(BUILD_EXAMPLECLIENT)
|
|
if(WIN32)
|
|
if(WIN32)
|
|
target_link_libraries(client_static ws2_32)
|
|
target_link_libraries(client_static ws2_32)
|
|
target_link_libraries(client ws2_32)
|
|
target_link_libraries(client ws2_32)
|
|
- else()
|
|
|
|
|
|
+ elseif(NOT APPLE)
|
|
target_link_libraries(client_static rt)
|
|
target_link_libraries(client_static rt)
|
|
target_link_libraries(client rt)
|
|
target_link_libraries(client rt)
|
|
endif()
|
|
endif()
|