first commit
This commit is contained in:
79
cmake/SoftbusThirdParty.cmake
Normal file
79
cmake/SoftbusThirdParty.cmake
Normal file
@@ -0,0 +1,79 @@
|
||||
include(FetchContent)
|
||||
|
||||
# nlohmann_json
|
||||
FetchContent_Declare(
|
||||
nlohmann_json
|
||||
GIT_REPOSITORY https://github.com/nlohmann/json.git
|
||||
GIT_TAG v3.11.3
|
||||
GIT_SHALLOW TRUE
|
||||
)
|
||||
FetchContent_MakeAvailable(nlohmann_json)
|
||||
|
||||
# standalone asio
|
||||
FetchContent_Declare(
|
||||
asio
|
||||
GIT_REPOSITORY https://github.com/chriskohlhoff/asio.git
|
||||
GIT_TAG asio-1-30-2
|
||||
GIT_SHALLOW TRUE
|
||||
)
|
||||
FetchContent_GetProperties(asio)
|
||||
if(NOT asio_POPULATED)
|
||||
FetchContent_Populate(asio)
|
||||
add_library(asio INTERFACE)
|
||||
target_include_directories(asio INTERFACE ${asio_SOURCE_DIR}/asio/include)
|
||||
target_compile_definitions(asio INTERFACE ASIO_STANDALONE ASIO_NO_DEPRECATED)
|
||||
if(WIN32)
|
||||
target_compile_definitions(asio INTERFACE _WIN32_WINNT=0x0601)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# open62541
|
||||
if(SOFTBUS_WITH_OPCUA)
|
||||
set(UA_ENABLE_AMALGAMATION OFF CACHE BOOL "" FORCE)
|
||||
|
||||
if(MINGW)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fno-stack-protector")
|
||||
endif()
|
||||
|
||||
set(_softbus_saved_build_shared ${BUILD_SHARED_LIBS})
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
||||
|
||||
set(UA_ENABLE_SUBSCRIPTIONS ON CACHE BOOL "" FORCE)
|
||||
set(UA_ENABLE_METHODCALLS ON CACHE BOOL "" FORCE)
|
||||
set(UA_ENABLE_DISCOVERY ON CACHE BOOL "" FORCE)
|
||||
set(UA_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
set(UA_BUILD_UNIT_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(UA_ENABLE_ENCRYPTION OFF CACHE BOOL "" FORCE)
|
||||
|
||||
FetchContent_Declare(
|
||||
open62541
|
||||
GIT_REPOSITORY https://github.com/open62541/open62541.git
|
||||
GIT_TAG v1.4.6
|
||||
GIT_SHALLOW TRUE
|
||||
)
|
||||
FetchContent_MakeAvailable(open62541)
|
||||
set(BUILD_SHARED_LIBS ${_softbus_saved_build_shared} CACHE BOOL "" FORCE)
|
||||
|
||||
if(MINGW AND TARGET open62541)
|
||||
set_target_properties(open62541 PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "ws2_32;iphlpapi"
|
||||
)
|
||||
target_compile_options(open62541 PRIVATE -fno-stack-protector)
|
||||
target_link_options(open62541 PRIVATE -fno-stack-protector)
|
||||
endif()
|
||||
|
||||
set(SOFTBUS_HAS_OPCUA ON)
|
||||
else()
|
||||
set(SOFTBUS_HAS_OPCUA OFF)
|
||||
endif()
|
||||
|
||||
function(softbus_apply_open62541 target)
|
||||
if(SOFTBUS_HAS_OPCUA)
|
||||
target_compile_definitions(${target} PRIVATE SOFTBUS_HAS_OPCUA=1)
|
||||
target_link_libraries(${target} PRIVATE open62541)
|
||||
else()
|
||||
target_compile_definitions(${target} PRIVATE SOFTBUS_HAS_OPCUA=0)
|
||||
endif()
|
||||
endfunction()
|
||||
Reference in New Issue
Block a user