From d5fd7d9fc253b5dc713bd79dd275b64d26dbe0aa Mon Sep 17 00:00:00 2001 From: Martin Willers Date: Tue, 5 Oct 2021 03:35:57 +0200 Subject: Make the legacy include path a CMake option (#332) Signed-off-by: Martin Willers --- CMakeLists.txt | 3 +++ doc/dlt_for_developers.md | 11 +++++++++-- src/lib/CMakeLists.txt | 8 +++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index adaa7fc..915b583 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,8 @@ option(WITH_DLT_KPI "Set to ON to build src/kpi binaries" 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_LEGACY_INCLUDE_PATH "Set to ON to add /dlt to include paths for the CMake config file, in addition to only " + OFF) 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_DLT_DAEMON_VSOCK_IPC "Set to ON to enable VSOCK support in daemon" OFF) @@ -316,6 +318,7 @@ message(STATUS "DLT_VSOCK_PORT = ${DLT_VSOCK_PORT}") message(STATUS "WITH_UDP_CONNECTION = ${WITH_UDP_CONNECTION}") message(STATUS "WITH_DLT_QNX_SYSTEM = ${WITH_DLT_QNX_SYSTEM}") message(STATUS "WITH_LIB_SHORT_VERSION = ${WITH_LIB_SHORT_VERSION}") +message(STATUS "WITH_LEGACY_INCLUDE_PATH = ${WITH_LEGACY_INCLUDE_PATH}") message(STATUS "WITH_EXTENDED_FILTERING = ${WITH_EXTENDED_FILTERING}") message(STATUS "Change a value with: cmake -D=") message(STATUS "-------------------------------------------------------------------------------") diff --git a/doc/dlt_for_developers.md b/doc/dlt_for_developers.md index 844eb40..bedb802 100644 --- a/doc/dlt_for_developers.md +++ b/doc/dlt_for_developers.md @@ -24,8 +24,6 @@ within the standard include directory. This example gives an overview of DLT usage inside an application by using a minimal code example. Detailed information about the API can be found later in this document. -Please note that for backwards compatibility also the legacy #include statement -`` is supported. Using it for new code is not recommended, though. ``` #include @@ -81,6 +79,15 @@ exports an IMPORTED CMake target; it does not set any variables, except for the `automotive-dlt_FOUND` variable that can be used to treat DLT as an optional dependency. +The generated CMake config file (which is implicitly being used when you call +`find_package(automotive-dlt)`) by default only adds the top-level directory +to the compiler's header search path; this requires that users' #include +directives are written in the regular form e.g. ``. If you want +to be able to use the legacy form `` as well (as is always allowed by +the pkg-config module for backwards compatibility reasons), you can configure +DLT with the CMake option `-DWITH_LEGACY_INCLUDE_PATH=On` in order to +achieve that. + ### DLT with pkg-config Alternatively to the CMake integration detailed above, it is also possible diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index acf1587..fb5a2a4 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -51,8 +51,14 @@ target_include_directories(dlt $ $ $ - $ ) +# With this option set, a legacy include path is added in addition to the regular one. +if(WITH_LEGACY_INCLUDE_PATH) + target_include_directories(dlt + PUBLIC + $ + ) +endif() if(WITH_LIB_SHORT_VERSION) set_target_properties(dlt PROPERTIES VERSION ${PROJECT_VERSION_MAJOR} SOVERSION ${PROJECT_VERSION_MAJOR}) -- cgit v1.2.1