Skip to content

Commit

Permalink
[cmake] Add optionto no build libwebocket along Open OCPP library and…
Browse files Browse the repository at this point in the history
… use the one provided by the compiler SDK
  • Loading branch information
c-jimenez committed Nov 12, 2023
1 parent 1c8683c commit d04f35d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
33 changes: 18 additions & 15 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@ target_include_directories(doctest INTERFACE doctest/doctest)
# SQLite 3
add_subdirectory(sqlite3)

# Use default flags for the libwebsockets library
if (NOT MSVC)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT} -O0 -g3 -ggdb3")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT} -O0 -g3 -ggdb3")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_INIT} -O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_INIT} -O2 -DNDEBUG")
else()
set(DISABLED_WARNING_LWS "/WX- /wd4191 /wd4996")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT} ${DISABLED_WARNING_LWS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT} ${DISABLED_WARNING_LWS}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_INIT} ${DISABLED_WARNING_LWS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_INIT} ${DISABLED_WARNING_LWS}")
endif()
# libwebsockets
if(${BUILD_LWS_LIBRARY})
# Use default flags for the libwebsockets library
if (NOT MSVC)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT} -O0 -g3 -ggdb3")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT} -O0 -g3 -ggdb3")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_INIT} -O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_INIT} -O2 -DNDEBUG")
else()
set(DISABLED_WARNING_LWS "/WX- /wd4191 /wd4996")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT} ${DISABLED_WARNING_LWS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT} ${DISABLED_WARNING_LWS}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_INIT} ${DISABLED_WARNING_LWS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_INIT} ${DISABLED_WARNING_LWS}")
endif()

set(LWS_WITH_NETLINK OFF)
add_subdirectory(libwebsockets)
set(LWS_WITH_NETLINK OFF)
add_subdirectory(libwebsockets)
endif()
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ add_subdirectory(3rdparty)
# OpenSSL is mandatory
find_package(OpenSSL REQUIRED COMPONENTS SSL Crypto)

# libwesockets is mandatory if not built along the Open OCPP library
if(NOT ${BUILD_LWS_LIBRARY})
find_package(PkgConfig)
pkg_check_modules(LIB_WEBSOCKETS REQUIRED libwebsockets)
else()
set(LIB_WEBSOCKETS websockets)
endif()

# Tests
if(${BUILD_UNIT_TESTS})
enable_testing()
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists_Options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ option(BUILD_UNIT_TESTS "Build unit tests" ON)

# Examples
option(BUILD_EXAMPLES "Build examples" ON)

# Build the libwebsocket library along with the Open OCPP library
option(BUILD_LWS_LIBRARY "Build libwebsocket library" ON)
2 changes: 1 addition & 1 deletion src/websockets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ target_include_directories(ws PUBLIC . stubs)

# Dependencies
target_link_libraries(ws PUBLIC
websockets
${LIB_WEBSOCKETS}
helpers
)

0 comments on commit d04f35d

Please sign in to comment.