Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[draft] cmake: enable submodule init and update #505

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 106 additions & 52 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,63 +44,71 @@ if(NOT CMAKE_BUILD_TYPE)
endif()

# Set of indiviual options
option(BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON)
option(WITH_SYSTEMD "Set to ON to create unit files and systemd check on dlt-daemon startup" OFF)
option(WITH_SYSTEMD_WATCHDOG "Set to ON to use the systemd watchdog in dlt-daemon" OFF)
option(WITH_SYSTEMD_WATCHDOG_ENFORCE_MSG_RX "Set to ON to trigger systemd watchdog of dlt-daemon only when a message was received since the last trigger" OFF)
option(WITH_SYSTEMD_WATCHDOG_ENFORCE_MSG_RX_DLT_SYSTEM "Set to ON to trigger systemd watchdog of dlt-system only when a message was received since the last trigger" OFF)
option(WITH_SYSTEMD_JOURNAL "Set to ON to use the systemd journal in dlt-system" OFF)
option(BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON)
option(WITH_SYSTEMD "Set to ON to create unit files and systemd check on dlt-daemon startup" OFF)
option(WITH_SYSTEMD_WATCHDOG "Set to ON to use the systemd watchdog in dlt-daemon" OFF)
option(WITH_SYSTEMD_WATCHDOG_ENFORCE_MSG_RX "Set to ON to trigger systemd watchdog of dlt-daemon
only when a message was received since the last trigger" OFF)
option(WITH_SYSTEMD_WATCHDOG_ENFORCE_MSG_RX_DLT_SYSTEM "Set to ON to trigger systemd watchdog
of dlt-system only when a message was received since the last trigger" OFF)
option(WITH_SYSTEMD_JOURNAL "Set to ON to use the systemd journal in dlt-system" OFF)
option(WITH_SYSTEMD_SOCKET_ACTIVATION "Set to ON to use systemd socket activation" OFF)
option(WITH_DOC "Set to ON to build documentation target" OFF)
option(WITH_MAN "Set to ON to build man pages" OFF)
option(WITH_CHECK_CONFIG_FILE "Set to ON to create a configure file of CheckIncludeFiles and CheckFunctionExists" OFF)
option(WITH_TESTSCRIPTS "Set to ON to run CMakeLists.txt in testscripts" OFF)
option(WITH_GPROF "Set -pg to compile flags" OFF)
option(WITH_DLTTEST "Set to ON to build with modifications to test User-Daemon communication with corrupt messages" OFF)
option(WITH_DLT_SHM_ENABLE "EXPERIMENTAL! Set to ON to use shared memory as IPC. EXPERIMENTAL!" OFF)
option(WITH_DLT_ADAPTOR "Set to ON to build src/adaptor binaries" OFF)
option(WITH_DOC "Set to ON to build documentation target" OFF)
option(WITH_MAN "Set to ON to build man pages" OFF)
option(WITH_CHECK_CONFIG_FILE "Set to ON to create a configure file for CheckIncludeFiles, CheckFunctionExists" OFF)
option(WITH_TESTSCRIPTS "Set to ON to run CMakeLists.txt in testscripts" OFF)
option(WITH_GPROF "Set -pg to compile flags" OFF)
option(WITH_DLTTEST "Set to ON to build with modifications
to test User-Daemon communication with corrupt messages" OFF)
option(WITH_DLT_SHM_ENABLE "EXPERIMENTAL! Set to ON to use shared memory as IPC. EXPERIMENTAL!" OFF)
option(WITH_DLT_ADAPTOR "Set to ON to build src/adaptor binaries" OFF)
option(WITH_DLT_ADAPTOR_STDIN "Set to ON to build src/adaptor/stdin binaries" OFF)
option(WITH_DLT_ADAPTOR_UDP "Set to ON to build src/adaptor/udp binaries" OFF)
option(WITH_DLT_CONSOLE "Set to ON to build src/console binaries" ON)
option(WITH_DLT_CONSOLE_WO_CTRL "Set to ON not to build control commands under src/console" OFF)
option(WITH_DLT_CONSOLE_WO_SBTM "Set to ON not to build dlt-sortbytimestamp under src/console" OFF)
option(WITH_DLT_CONSOLE_RECEIVE "Set to OFF to skip building dlt_receive" ON)
option(WITH_DLT_CONSOLE_CONVERT "Set to OFF to skip building dlt_convert" ON)
option(WITH_DLT_CONSOLE_CONTROL "Set to OFF to skip building dlt_control" ON)
option(WITH_DLT_CONSOLE_PASSIVE_NODE_CTRL "Set to OFF to skip building dlt_passive_node_ctrl" ON)

option(WITH_DLT_EXAMPLES "Set to ON to build src/examples binaries" ON)
option(WITH_DLT_FILETRANSFER "Set to ON to build dlt-system with filetransfer support" OFF)
option(WITH_DLT_SYSTEM "Set to ON to build src/system binaries" OFF)
option(WITH_DLT_DBUS "Set to ON to build src/dbus binaries" OFF)
option(WITH_DLT_TESTS "Set to ON to build src/test binaries" ON)
option(WITH_DLT_UNIT_TESTS "Set to ON to build gtest framework and tests/binaries" OFF)
option(WITH_DLT_COVERAGE "Set to ON to generate coverage report for dlt-daemon source code" OFF)
option(WITH_DLT_QNX_SYSTEM "Set to ON to build QNX system binary dlt-qnx-system" OFF)
option(WITH_DLT_FILE_LOGGING_SYSLOG_FALLBACK "Set to ON to enable fallback to syslog if dlt logging to file fails" OFF)
option(WITH_DLT_ADAPTOR_UDP "Set to ON to build src/adaptor/udp binaries" OFF)
option(WITH_DLT_CONSOLE "Set to ON to build src/console binaries" ON)
option(WITH_DLT_CONSOLE_WO_CTRL "Set to ON not to build control commands under src/console" OFF)
option(WITH_DLT_CONSOLE_WO_SBTM "Set to ON not to build dlt-sortbytimestamp under src/console" OFF)
option(WITH_DLT_CONSOLE_RECEIVE "Set to OFF to skip building dlt_receive" ON)
option(WITH_DLT_CONSOLE_CONVERT "Set to OFF to skip building dlt_convert" ON)
option(WITH_DLT_CONSOLE_CONTROL "Set to OFF to skip building dlt_control" ON)
option(WITH_DLT_CONSOLE_PASSIVE_NODE_CTRL "Set to OFF to skip building dlt_passive_node_ctrl" ON)

option(WITH_DLT_EXAMPLES "Set to ON to build src/examples binaries" ON)
option(WITH_DLT_FILETRANSFER "Set to ON to build dlt-system with filetransfer support" OFF)
option(WITH_DLT_SYSTEM "Set to ON to build src/system binaries" OFF)
option(WITH_DLT_DBUS "Set to ON to build src/dbus binaries" OFF)
option(WITH_DLT_TESTS "Set to ON to build src/test binaries" ON)
option(WITH_DLT_UNIT_TESTS "Set to ON to build gtest framework and tests/binaries" OFF)
option(WITH_DLT_COVERAGE "Set to ON to generate coverage report for dlt-daemon source code" OFF)
option(WITH_DLT_QNX_SYSTEM "Set to ON to build QNX system binary dlt-qnx-system" OFF)
option(WITH_DLT_FILE_LOGGING_SYSLOG_FALLBACK "Set to ON to enable fallback to syslog if logging to file fails" OFF)
option(WITH_DLT_NETWORK_TRACE "Set to ON to enable network trace (if message queue is supported)" ON)
option(WITH_DLT_LOG_LEVEL_APP_CONFIG "Set to ON to enable default log levels based on application ids" OFF)

set(DLT_IPC "FIFO" CACHE STRING "UNIX_SOCKET,FIFO")
set(DLT_USER "genivi" CACHE STRING "Set user for process not run as root")
set(DLT_QNX_SLOG_ADAPTER_WAIT_BUFFER_TIMEOUT_MS "100" CACHE STRING "Timeout in milliseconds to wait before messages are dropped when input buffer is full")

option(WITH_DLT_PKGCONFIG "Set to ON to generate pkgconfig .pc files" ON)
option(WITH_DLT_CXX11_EXT "Set to ON to build C++11 extensions" OFF)
option(WITH_DLT_COREDUMPHANDLER "EXPERIMENTAL! Set to ON to build src/core_dump_handler binaries. EXPERIMENTAL" OFF)
option(WITH_DLT_LOGSTORAGE_CTRL_UDEV "PROTOTYPE! Set to ON to build logstorage control application with udev support" OFF)
option(WITH_DLT_LOGSTORAGE_GZIP "Set to ON to build logstorage control application with gzip compression support" OFF)
option(WITH_DLT_USE_IPv6 "Set to ON for IPv6 support" ON)
option(WITH_DLT_KPI "Set to ON to build src/kpi binaries" OFF)
set(DLT_QNX_SLOG_ADAPTER_WAIT_BUFFER_TIMEOUT_MS "100" CACHE STRING "Timeout in milliseconds
to wait before messages are dropped when input buffer is full")

option(BUILD_GMOCK "Set to ON to enable gmock build" OFF)
option(WITH_GIT_SUBMODULE "Set to on to update submodules during build" OFF)
option(WITH_DLT_PKGCONFIG "Set to ON to generate pkgconfig .pc files" ON)
option(WITH_DLT_CXX11_EXT "Set to ON to build C++11 extensions" OFF)
option(WITH_DLT_COREDUMPHANDLER "EXPERIMENTAL! Set to ON to build src/core_dump_handler binaries" OFF)
option(WITH_DLT_LOGSTORAGE_CTRL_UDEV "PROTOTYPE! Set to ON to build logstorage control with udev support" OFF)
option(WITH_DLT_LOGSTORAGE_GZIP "Set to ON to build logstorage control with gzip compression support" OFF)
option(WITH_DLT_USE_IPv6 "Set to ON for IPv6 support" ON)
option(WITH_DLT_KPI "Set to ON to build src/kpi binaries" OFF)
option(WITH_DLT_FATAL_LOG_TRAP "Set to ON to enable DLT_LOG_FATAL trap(trigger segv inside dlt-user library)" OFF)
option(WITH_UDP_CONNECTION "Set to ON to enable dlt UDP multicast SUPPORT" OFF)
option(WITH_LIB_SHORT_VERSION "Set to ON to build library with only major number in version" OFF)
option(WITH_DLT_DISABLE_MACRO "Set to ON to build code without Macro interface support" OFF)
option(WITH_LEGACY_INCLUDE_PATH "Set to ON to add <prefix>/dlt to include paths for the CMake config file, in addition to only <prefix>" ON)
option(WITH_EXTENDED_FILTERING "Set to OFF to build without extended filtering. Using json filter files is only supported for Linux based system with json-c and QNX." OFF)
option(WITH_UDP_CONNECTION "Set to ON to enable dlt UDP multicast SUPPORT" OFF)
option(WITH_LIB_SHORT_VERSION "Set to ON to build library with only major number in version" OFF)
option(WITH_DLT_DISABLE_MACRO "Set to ON to build code without Macro interface support" OFF)
option(WITH_LEGACY_INCLUDE_PATH "Set to ON to add <prefix>/dlt to include paths
for the CMake config file, in addition to only <prefix>" ON)
option(WITH_EXTENDED_FILTERING "Set to OFF to build without extended filtering,
only supported for Linux based system with json-c and QNX" OFF)

option(WITH_DLT_DAEMON_VSOCK_IPC "Set to ON to enable VSOCK support in daemon" OFF)
option(WITH_DLT_LIB_VSOCK_IPC "Set to ON to enable VSOCK support in library (DLT_IPC is not used in library)" OFF)
option(WITH_DLT_LIB_VSOCK_IPC "Set to ON to enable VSOCK support in library (DLT_IPC is not used in library)" OFF)

set(DLT_VSOCK_PORT "13490" CACHE STRING "VSOCK port number for logging traffic.")
set(DLT_WRITEV_TIMEOUT_SEC "1" CACHE STRING "Set sec timeout for writev to prevent blocking indefinitely")
Expand Down Expand Up @@ -149,15 +157,19 @@ add_definitions(-DDLT_QNX_SLOG_ADAPTER_WAIT_BUFFER_TIMEOUT_MS=${DLT_QNX_SLOG_ADA
if(NOT DLT_IPC STREQUAL "UNIX_SOCKET" AND NOT DLT_IPC STREQUAL "FIFO")
message(FATAL_ERROR "${DLT_IPC} is not a valid value for DLT_IPC")
endif()

add_definitions(-DDLT_DAEMON_USE_${DLT_IPC}_IPC)

if(WITH_DLT_DAEMON_VSOCK_IPC)
add_definitions(-DDLT_DAEMON_VSOCK_IPC_ENABLE)
endif()

if(NOT WITH_DLT_LIB_VSOCK_IPC)
add_definitions(-DDLT_LIB_USE_${DLT_IPC}_IPC)
else()
add_definitions(-DDLT_LIB_USE_VSOCK_IPC)
endif()

if(WITH_DLT_DAEMON_VSOCK_IPC OR WITH_DLT_LIB_VSOCK_IPC)
add_definitions(-DDLT_VSOCK_PORT=${DLT_VSOCK_PORT})
endif()
Expand Down Expand Up @@ -192,7 +204,7 @@ if(WITH_DLT_FILE_LOGGING_SYSLOG_FALLBACK)
endif()

if(WITH_DLT_LOGSTORAGE_GZIP)
add_definitions(-DDLT_LOGSTORAGE_USE_GZIP)
add_definitions(-DDLT_LOGSTORAGE_USE_GZIP)
endif()

if(WITH_GPROF)
Expand Down Expand Up @@ -233,6 +245,10 @@ else()
set(CMAKE_STATIC_LIB_PATH "-L\$\{libdir\}/static")
endif()

if(WITH_GIT_SUBMODULE)
add_definitions(-DWITH_GIT_SUBMODULE)
endif()

if(WITH_DLT_PKGCONFIG)
configure_file(${PROJECT_SOURCE_DIR}/${PROJECT_NAME}.spec.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.spec)
configure_file(${PROJECT_SOURCE_DIR}/${PROJECT_NAME}.pc.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY)
Expand Down Expand Up @@ -337,19 +353,52 @@ else()
set(DLT_JSON_LIBRARY "")
endif()

if (WITH_DLT_LOG_LEVEL_APP_CONFIG)
if(WITH_DLT_LOG_LEVEL_APP_CONFIG)
add_definitions(-DDLT_LOG_LEVEL_APP_CONFIG)
endif()

add_subdirectory(doc)
add_subdirectory(src)
add_subdirectory(include)
add_subdirectory(testscripts)

if(WITH_DLT_UNIT_TESTS)
find_package(GTest)
if(GTEST_FOUND)
find_package(PkgConfig REQUIRED)
execute_process(COMMAND pkg-config --modversion gtest OUTPUT_VARIABLE GTEST_VERSION)
string(REPLACE "\n" "" GTEST_VERSION ${GTEST_VERSION})
if(${GTEST_VERSION} GREATER 1.11.0)
set(WITH_GIT_SUBMODULE ON)
message(STATUS "The Gtest version ${GTEST_VERSION} is not compatible with current implementation, preparing Gtest v1.11.0")
else()
set(WITH_GIT_SUBMODULE OFF)
endif()
else()
set(WITH_GIT_SUBMODULE ON)
message(STATUS "No Gtest package found, preparing Gtest v1.11.0")
endif()

if(NOT GTEST_FOUND)
add_subdirectory(googletest)
if(WITH_GIT_SUBMODULE)
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/googletest/CMakeLists.txt")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
else()
add_subdirectory(googletest)
if(NOT BUILD_GMOCK)
add_definitions(-DBUILD_GMOCK)
endif()
endif()
endif()
enable_testing()
add_subdirectory(tests)
Expand All @@ -374,10 +423,15 @@ message(STATUS "WITH_DLT_SYSTEM = ${WITH_DLT_SYSTEM}")
message(STATUS "WITH_DLT_FILETRANSFER = ${WITH_DLT_FILETRANSFER}")
message(STATUS "WITH_DLT_DBUS = ${WITH_DLT_DBUS}")
message(STATUS "WITH_DLT_TESTS = ${WITH_DLT_TESTS}")
message(STATUS "WITH_DLT_UNIT_TESTS = ${WITH_DLT_UNIT_TESTS}")
if(WITH_DLT_UNIT_TESTS)
message(STATUS "WITH_DLT_UNIT_TESTS = ${WITH_DLT_UNIT_TESTS}")
message(STATUS "GTEST_VERSION = ${GTEST_VERSION}")
endif()
message(STATUS "WITH_DLT_COVERAGE = ${WITH_DLT_COVERAGE}")
message(STATUS "WITH_DLT_SHM_ENABLE = ${WITH_DLT_SHM_ENABLE}")
message(STATUS "WITH_DLTTEST = ${WITH_DLTTEST}")
message(STATUS "BUILD_GMOCK = ${BUILD_GMOCK}")
message(STATUS "WITH_GIT_SUBMODULE = ${WITH_GIT_SUBMODULE}")
message(STATUS "WITH_DLT_PKGCONFIG = ${WITH_DLT_PKGCONFIG}")
message(STATUS "WITH_DLT_CXX11_EXT = ${WITH_DLT_CXX11_EXT}")
message(STATUS "WITH_DLT_COREDUMPHANDLER = ${WITH_DLT_COREDUMPHANDLER}")
Expand Down
Loading