From 8d3a140f4f96ac54aa5ef3260c441d375c48ae76 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 5 Apr 2019 20:57:34 +0200 Subject: [PATCH] cmake: improve supported combination of compile options --- CMakeLists.txt | 104 +++++++++++++++++++------------ include/villas/config.hpp | 2 +- include/villas/config_helper.hpp | 7 +-- lib/CMakeLists.txt | 4 +- lib/api/CMakeLists.txt | 11 +++- lib/nodes/CMakeLists.txt | 12 ++-- lib/super_node.cpp | 1 + lib/web.cpp | 2 + tests/unit/io.cpp | 2 +- 9 files changed, 88 insertions(+), 57 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 652c30151..183e5be91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ set(PROJECT_HOMEPAGE_URL "https://www.fein-aachen.org/projects/villas-node/") # Several CMake settings/defaults set(CMAKE_C_STANDARD 11) -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_THREAD_PREFER_PTHREAD ON) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake;${PROJECT_SOURCE_DIR}/common/cmake") @@ -52,6 +52,7 @@ include(CheckIncludeFile) include(FeatureSummary) include(GNUInstallDirs) include(GetVersion) +include(CMakeDependentOption) # Compiler flags if(BUILD32) @@ -114,37 +115,37 @@ if(NOT RE_FOUND) endif() # Build options -option(WITH_HOOKS "Build with support for processing hook plugins" ON) -option(WITH_WEB "Build with internal webserver" ON) -option(WITH_API "Build with remote control API" ON) -option(WITH_CONFIG "Build with support for libconfig configuration syntax" ${LIBCONFIG_FOUND}) -option(WITH_SRC "Build villas-* executables" ${TOPLEVEL_PROJECT}) -option(WITH_TOOLS "Build auxilary tools" ${TOPLEVEL_PROJECT}) -option(WITH_TESTS "Run tests" ${TOPLEVEL_PROJECT}) -option(WITH_PLUGINS "Build plugins" ${TOPLEVEL_PROJECT}) -option(WITH_CLIENTS "Build client applications" ${TOPLEVEL_PROJECT}) -option(WITH_DOC "Build documentation" ${TOPLEVEL_PROJECT}) +cmake_dependent_option(WITH_HOOKS "Build with support for processing hook plugins" ON "" OFF) +cmake_dependent_option(WITH_WEB "Build with internal webserver" ON "LIBWEBSOCKETS_FOUND" OFF) +cmake_dependent_option(WITH_API "Build with remote control API" ON "" OFF) +cmake_dependent_option(WITH_CONFIG "Build with support for libconfig configuration syntax" ON "LIBCONFIG_FOUND" OFF) +cmake_dependent_option(WITH_SRC "Build villas-* executables" ON "TOPLEVEL_PROJECT" OFF) +cmake_dependent_option(WITH_TOOLS "Build auxilary tools" ON "TOPLEVEL_PROJECT" OFF) +cmake_dependent_option(WITH_TESTS "Run tests" ON "TOPLEVEL_PROJECT" OFF) +cmake_dependent_option(WITH_PLUGINS "Build plugins" ON "TOPLEVEL_PROJECT" OFF) +cmake_dependent_option(WITH_CLIENTS "Build client applications" ON "TOPLEVEL_PROJECT" OFF) +cmake_dependent_option(WITH_DOC "Build documentation" ON "TOPLEVEL_PROJECT" OFF) -option(WITH_NODE_AMQP "Build with amqp node-type" ${RABBITMQ_C_FOUND}) -option(WITH_NODE_COMEDI "Build with comedi node-type" ${COMEDILIB_FOUND}) -option(WITH_NODE_FILE "Build with file node-type" ON) -option(WITH_NODE_IEC61850 "Build with iec61850 node-types" ${LIBIEC61850_FOUND}) -option(WITH_NODE_INFINIBAND "Build with infiniband node-type" ${IBVerbs_FOUND}) -option(WITH_NODE_INFLUXDB "Build with influxdb node-type" ON) -option(WITH_NODE_LOOPBACK "Build with loopback node-type" ON) -option(WITH_NODE_MQTT "Build with mqtt node-type" ${Mosquitto_FOUND}) -option(WITH_NODE_NANOMSG "Build with nanomsg node-type" ${NANOMSG_FOUND}) -option(WITH_NODE_NGSI "Build with ngsi node-type" ${CURL_FOUND}) -option(WITH_NODE_OPAL "Build with opal node-type" ${Opal_FOUND}) -option(WITH_NODE_RTP "Build with rtp node-type" ${RE_FOUND}) -option(WITH_NODE_SHMEM "Build with shmem node-type" ON) -option(WITH_NODE_SIGNAL_GENERATOR "Build with signal node-type" ON) -option(WITH_NODE_SOCKET "Build with socket node-type" ${LIBNL3_ROUTE_FOUND}) -option(WITH_NODE_STATS "Build with stats node-type" ON) -option(WITH_NODE_TEST_RTT "Build with test_rtt node-type" ON) -option(WITH_NODE_ULDAQ "Build with uldaq node-type" ${ULDAQ_FOUND}) -option(WITH_NODE_WEBSOCKET "Build with websocket node-type" ${LIBWEBSOCKETS_LDFLAGS}) -option(WITH_NODE_ZEROMQ "Build with zeromq node-type" ${LIBZMQ_FOUND}) +cmake_dependent_option(WITH_NODE_AMQP "Build with amqp node-type" ON "RABBITMQ_C_FOUND" OFF) +cmake_dependent_option(WITH_NODE_COMEDI "Build with comedi node-type" ON "COMEDILIB_FOUND" OFF) +cmake_dependent_option(WITH_NODE_FILE "Build with file node-type" ON "" OFF) +cmake_dependent_option(WITH_NODE_IEC61850 "Build with iec61850 node-types" ON "LIBIEC61850_FOUND" OFF) +cmake_dependent_option(WITH_NODE_INFINIBAND "Build with infiniband node-type" ON "IBVERBS_FOUND; RDMACM_FOUND" OFF) +cmake_dependent_option(WITH_NODE_INFLUXDB "Build with influxdb node-type" ON "" OFF) +cmake_dependent_option(WITH_NODE_LOOPBACK "Build with loopback node-type" ON "" OFF) +cmake_dependent_option(WITH_NODE_MQTT "Build with mqtt node-type" ON "Mosquitto_FOUND" OFF) +cmake_dependent_option(WITH_NODE_NANOMSG "Build with nanomsg node-type" ON "NANOMSG_FOUND" OFF) +cmake_dependent_option(WITH_NODE_NGSI "Build with ngsi node-type" ON "" OFF) +cmake_dependent_option(WITH_NODE_OPAL "Build with opal node-type" ON "BUILD32; Opal_FOUND" OFF) +cmake_dependent_option(WITH_NODE_RTP "Build with rtp node-type" ON "RE_FOUND" OFF) +cmake_dependent_option(WITH_NODE_SHMEM "Build with shmem node-type" ON "HAS_SEMAPHORE; HAS_MMAN" OFF) +cmake_dependent_option(WITH_NODE_SIGNAL "Build with signal node-type" ON "" OFF) +cmake_dependent_option(WITH_NODE_SOCKET "Build with socket node-type" ON "LIBNL3_ROUTE_FOUND" OFF) +cmake_dependent_option(WITH_NODE_STATS "Build with stats node-type" ON "" OFF) +cmake_dependent_option(WITH_NODE_TEST_RTT "Build with test_rtt node-type" ON "" OFF) +cmake_dependent_option(WITH_NODE_ULDAQ "Build with uldaq node-type" ON "LIBULDAQ_FOUND" OFF) +cmake_dependent_option(WITH_NODE_WEBSOCKET "Build with websocket node-type" ON "WITH_WEB; LIBWEBSOCKETS_FOUND" OFF) +cmake_dependent_option(WITH_NODE_ZEROMQ "Build with zeromq node-type" ON "LIBZMQ_FOUND" OFF) # Add more build configurations include(cmake/config/Debug.cmake) @@ -192,15 +193,36 @@ configure_file( ) # Show feature summary -add_feature_info(HOOKS WITH_HOOKS "Build with support for processing hook plugins") -add_feature_info(WEB WITH_WEB "Build with internal webserver") -add_feature_info(API WITH_API "Build with remote control API") -add_feature_info(CONFIG WITH_CONFIG "Build with support for libconfig configuration syntax") -add_feature_info(TOOLS WITH_TOOLS "Build auxilary tools") -add_feature_info(TESTS WITH_TESTS "Run tests") -add_feature_info(PLUGINS WITH_PLUGINS "Build plugins") -add_feature_info(CLIENTS WITH_CLIENTS "Build client applications") -add_feature_info(DOC WITH_DOC "Build documentation") +add_feature_info(HOOKS WITH_HOOKS "Build with support for processing hook plugins") +add_feature_info(WEB WITH_WEB "Build with internal webserver") +add_feature_info(API WITH_API "Build with remote control API") +add_feature_info(CONFIG WITH_CONFIG "Build with support for libconfig configuration syntax") +add_feature_info(TOOLS WITH_TOOLS "Build auxilary tools") +add_feature_info(TESTS WITH_TESTS "Run tests") +add_feature_info(PLUGINS WITH_PLUGINS "Build plugins") +add_feature_info(CLIENTS WITH_CLIENTS "Build client applications") +add_feature_info(DOC WITH_DOC "Build documentation") + +add_feature_info(NODE_AMQP WITH_NODE_AMQP "Build with amqp node-type") +add_feature_info(NODE_COMEDI WITH_NODE_COMEDI "Build with comedi node-type") +add_feature_info(NODE_FILE WITH_NODE_FILE "Build with file node-type") +add_feature_info(NODE_IEC61850 WITH_NODE_IEC61850 "Build with iec61850 node-types") +add_feature_info(NODE_INFINIBAND WITH_NODE_INFINIBAND "Build with infiniband node-type") +add_feature_info(NODE_INFLUXDB WITH_NODE_INFLUXDB "Build with influxdb node-type") +add_feature_info(NODE_LOOPBACK WITH_NODE_LOOPBACK "Build with loopback node-type") +add_feature_info(NODE_MQTT WITH_NODE_MQTT "Build with mqtt node-type") +add_feature_info(NODE_NANOMSG WITH_NODE_NANOMSG "Build with nanomsg node-type") +add_feature_info(NODE_NGSI WITH_NODE_NGSI "Build with ngsi node-type") +add_feature_info(NODE_OPAL WITH_NODE_OPAL "Build with opal node-type") +add_feature_info(NODE_RTP WITH_NODE_RTP "Build with rtp node-type") +add_feature_info(NODE_SHMEM WITH_NODE_SHMEM "Build with shmem node-type") +add_feature_info(NODE_SIGNAL_GENERATOR WITH_NODE_SIGNAL "Build with signal node-type") +add_feature_info(NODE_SOCKET WITH_NODE_SOCKET "Build with socket node-type") +add_feature_info(NODE_STATS WITH_NODE_STATS "Build with stats node-type") +add_feature_info(NODE_TEST_RTT WITH_NODE_TEST_RTT "Build with test_rtt node-type") +add_feature_info(NODE_ULDAQ WITH_NODE_ULDAQ "Build with uldaq node-type") +add_feature_info(NODE_WEBSOCKET WITH_NODE_WEBSOCKET "Build with websocket node-type") +add_feature_info(NODE_ZEROMQ WITH_NODE_ZEROMQ "Build with zeromq node-type") if(TOPLEVEL_PROJECT) feature_summary(WHAT ALL VAR FEATURES) @@ -213,6 +235,8 @@ if(TOPLEVEL_PROJECT) message(STATUS " VARIANT: ${CMAKE_PROJECT_VARIANT}") message(STATUS " BUILD_ID: ${CMAKE_PROJECT_BUILD_ID}") message(STATUS " BUILD_DATE: ${CMAKE_PROJECT_BUILD_DATE}") + message(STATUS " ARCH: ${CMAKE_SYSTEM_PROCESSOR}") + message(STATUS " OS: ${CMAKE_SYSTEM_NAME}") endif() include(VILLASnodePackaging) diff --git a/include/villas/config.hpp b/include/villas/config.hpp index 3780dd7b5..c583a1657 100644 --- a/include/villas/config.hpp +++ b/include/villas/config.hpp @@ -25,7 +25,7 @@ #include -#include +#include #include namespace villas { diff --git a/include/villas/config_helper.hpp b/include/villas/config_helper.hpp index 31fb6e368..da8dcf21a 100644 --- a/include/villas/config_helper.hpp +++ b/include/villas/config_helper.hpp @@ -24,13 +24,12 @@ #include -#ifdef WITH_CONFIG - #include -#endif /* WITH_CONFIG */ - +#include #include #ifdef WITH_CONFIG + #include + /** Convert a libconfig object to a jansson object */ json_t *config_to_json(config_setting_t *cfg); diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index d2a2f2ab0..bdacb9737 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -68,7 +68,7 @@ set(LIB_SRC ) -if(IBVERBS_FOUND AND RDMACM_FOUND) +if(WITH_NODE_INFINIBAND) list(APPEND LIB_SRC memory/ib.c) endif() @@ -102,7 +102,7 @@ if(WITH_WEB) list(APPEND LIBRARIES PkgConfig::LIBWEBSOCKETS) endif() -if(WITH_API AND WITH_WEB) +if(WITH_API) list(APPEND LIB_SRC api.cpp ) diff --git a/lib/api/CMakeLists.txt b/lib/api/CMakeLists.txt index e6395e942..458df4102 100644 --- a/lib/api/CMakeLists.txt +++ b/lib/api/CMakeLists.txt @@ -26,9 +26,6 @@ set(API_SRC server.cpp sessions/socket.cpp - sessions/wsi.cpp - sessions/http.cpp - sessions/websocket.cpp actions/capabiltities.cpp actions/shutdown.cpp @@ -40,6 +37,14 @@ set(API_SRC actions/node.cpp ) +if(WITH_WEB) + list(APPEND API_SRC + sessions/wsi.cpp + sessions/http.cpp + sessions/websocket.cpp + ) +endif() + add_library(api STATIC ${API_SRC}) target_include_directories(api PUBLIC ${INCLUDE_DIRS}) target_link_libraries(api INTERFACE ${LIBRARIES} PUBLIC villas-common) diff --git a/lib/nodes/CMakeLists.txt b/lib/nodes/CMakeLists.txt index e2e514e8d..5fe860a46 100644 --- a/lib/nodes/CMakeLists.txt +++ b/lib/nodes/CMakeLists.txt @@ -35,7 +35,7 @@ if(WITH_NODE_STATS) list(APPEND NODE_SRC stats.c) endif() -if(WITH_NODE_SIGNAL_GENERATOR) +if(WITH_NODE_SIGNAL) list(APPEND NODE_SRC signal_generator.c) endif() @@ -63,7 +63,7 @@ if(WITH_NODE_ULDAQ) endif() # Enable shared memory node-type -if(WITH_NODE_SHMEM AND HAS_SEMAPHORE AND HAS_MMAN) +if(WITH_NODE_SHMEM) list(APPEND NODE_SRC shmem.c) if(CMAKE_SUSTEM_NAME STREQUAL Linux) @@ -79,7 +79,7 @@ if(WITH_NODE_IEC61850) endif() # Enable OPAL-RT Asynchronous Process support (will result in 32bit binary!!!) -if(WITH_NODE_OPAL AND BUILD32) +if(WITH_NODE_OPAL) list(APPEND NODE_SRC opal.c) list(APPEND INCLUDE_DIRS ${OPAL_INCLUDE_DIRS}) list(APPEND LIBRARIES ${OPAL_LIBRARIES}) @@ -100,14 +100,14 @@ if(WITH_NODE_ZEROMQ) endif() # Enable NGSI support -if(WITH_NGSI) +if(WITH_NODE_NGSI) list(APPEND NODE_SRC ngsi.c) list(APPEND INCLUDE_DIRS ${CURL_INCLUDE_DIRS}) list(APPEND LIBRARIES ${CURL_LIBRARIES}) endif() # Enable WebSocket support -if(WITH_NODE_WEBSOCKET AND WITH_WEB) +if(WITH_NODE_WEBSOCKET) list(APPEND NODE_SRC websocket.c) list(APPEND INCLUDE_DIRS ${LIBWEBSOCKETS_INCLUDE_DIRS}) list(APPEND LIBRARIES ${LIBWEBSOCKETS_LDLIBS}) @@ -142,7 +142,7 @@ if(WITH_NODE_INFINIBAND) endif() # Enable RTP node type when libre is available -if(WITH_NODE_RE) +if(WITH_NODE_RTP) list(APPEND NODE_SRC rtp.cpp) list(APPEND INCLUDE_DIRS ${RE_INCLUDE_DIRS}) list(APPEND LIBRARIES PkgConfig::RE) diff --git a/lib/super_node.cpp b/lib/super_node.cpp index 0dee3e80e..2bf3629ee 100644 --- a/lib/super_node.cpp +++ b/lib/super_node.cpp @@ -458,6 +458,7 @@ void SuperNode::stop() #ifdef WITH_API api.stop(); #endif + #ifdef WITH_WEB web.stop(); #endif diff --git a/lib/web.cpp b/lib/web.cpp index a799906c6..955c19f1c 100644 --- a/lib/web.cpp +++ b/lib/web.cpp @@ -61,12 +61,14 @@ lws_protocols protocols[] = { .rx_buffer_size = 0 }, #endif /* WITH_API */ +#ifdef WITH_NODE_WEBSOCKET { .name = "live", .callback = websocket_protocol_cb, .per_session_data_size = sizeof(websocket_connection), .rx_buffer_size = 0 }, +#endif /* WITH_NODE_WEBSOCKET */ { .name = nullptr /* terminator */ } diff --git a/tests/unit/io.cpp b/tests/unit/io.cpp index 9f56ccf07..d3386cad5 100644 --- a/tests/unit/io.cpp +++ b/tests/unit/io.cpp @@ -62,7 +62,7 @@ static struct param params[] = { { "villas.binary", 10, 0 }, { "csv", 10, 0 }, { "json", 10, 0 }, -#ifdef LIBPROTOBUF_FOUND +#ifdef PROTOBUF_FOUND { "protobuf", 10, 0 } #endif };