From 666ad879094791bf8d2626b4cc66638a2af8e23a Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Tue, 2 Mar 2021 09:50:15 +0100 Subject: cmake: Add configure test for DLT and fix building GeniviExtras Task-number: AUTOSUITE-1633 Change-Id: Icf2117f9772dccff871c7fa9307479c2488f3965 Reviewed-by: Robert Griebl --- .prev_CMakeLists.txt | 2 +- CMakeLists.txt | 2 +- cmake/FindDLT.cmake | 22 ++++++++++++ examples/CMakeLists.txt | 2 +- examples/geniviextras/qdlt/CMakeLists.txt | 3 +- src/geniviextras/.prev_configure.cmake | 58 +++++++++++++++++++++++++++++++ src/geniviextras/CMakeLists.txt | 2 +- src/geniviextras/configure.cmake | 5 +-- tests/auto/CMakeLists.txt | 2 +- tests/auto/dlt/CMakeLists.txt | 4 +-- 10 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 cmake/FindDLT.cmake create mode 100644 src/geniviextras/.prev_configure.cmake diff --git a/.prev_CMakeLists.txt b/.prev_CMakeLists.txt index af48a27..c7d8cf2 100644 --- a/.prev_CMakeLists.txt +++ b/.prev_CMakeLists.txt @@ -1,6 +1,6 @@ # Generated from qtivi.pro. -cmake_minimum_required(VERSION 3.15.0) +cmake_minimum_required(VERSION 3.16) include(.cmake.conf) project(QtIvi diff --git a/CMakeLists.txt b/CMakeLists.txt index 00bdb19..efe23c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # Generated from qtivi.pro. -cmake_minimum_required(VERSION 3.15.0) +cmake_minimum_required(VERSION 3.16) include(.cmake.conf) project(QtIvi diff --git a/cmake/FindDLT.cmake b/cmake/FindDLT.cmake new file mode 100644 index 0000000..e75fb6b --- /dev/null +++ b/cmake/FindDLT.cmake @@ -0,0 +1,22 @@ +# We can't create the same interface imported target multiple times, CMake will complain if we do +# that. This can happen if the find_package call is done in multiple different subdirectories. +if(TARGET DLT::DLT) + set(DLT_FOUND ON) + return() +endif() + +find_package(PkgConfig) + +pkg_check_modules(DLT automotive-dlt IMPORTED_TARGET) +set(__dlt_target_name "PkgConfig::DLT") + +if (NOT TARGET "${__dlt_target_name}") + set(DLT_FOUND 0) + return() +endif() + +add_library(DLT::DLT INTERFACE IMPORTED) +target_link_libraries(DLT::DLT INTERFACE ${__dlt_target_name}) +target_include_directories(DLT::DLT INTERFACE ${DLT_INCLUDEDIR}) +set(DLT_FOUND TRUE) +unset(__dlt_target_name) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5454d68..7e9779d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,7 @@ endif() if(TARGET Qt::Gui AND TARGET Qt::IviMedia) add_subdirectory(ivimedia) endif() -if(TARGET geniviextras) +if(TARGET Qt::GeniviExtras) add_subdirectory(geniviextras) endif() diff --git a/examples/geniviextras/qdlt/CMakeLists.txt b/examples/geniviextras/qdlt/CMakeLists.txt index d5874e6..8036fb1 100644 --- a/examples/geniviextras/qdlt/CMakeLists.txt +++ b/examples/geniviextras/qdlt/CMakeLists.txt @@ -16,6 +16,7 @@ endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/geniviextras/qdlt") find_package(Qt6 COMPONENTS Core) +find_package(Qt6 COMPONENTS GeniviExtras) qt_add_executable(qdlt loggingcategories.cpp loggingcategories.h @@ -27,7 +28,7 @@ set_target_properties(qdlt PROPERTIES ) target_link_libraries(qdlt PUBLIC Qt::Core - geniviextras + Qt::GeniviExtras ) install(TARGETS qdlt diff --git a/src/geniviextras/.prev_configure.cmake b/src/geniviextras/.prev_configure.cmake new file mode 100644 index 0000000..ac4ba97 --- /dev/null +++ b/src/geniviextras/.prev_configure.cmake @@ -0,0 +1,58 @@ + + +#### Inputs + + + +#### Libraries + +qt_find_package(DLT PROVIDED_TARGETS DLT::DLT MODULE_NAME geniviextras QMAKE_LIB dlt) + + +#### Tests + + + +#### Features + +qt_feature("dlt" PRIVATE + LABEL "DLT" + AUTODETECT UNIX + CONDITION DLT_FOUND +) +qt_feature("dlt_2_12" PRIVATE + LABEL "DLT > 2.12" + AUTODETECT UNIX + CONDITION libs.dlt_2_12 OR FIXME +) +qt_feature("geniviextras-only" PRIVATE + LABEL "Only build Qt GENIVI Extras" + CONDITION INPUT_geniviextras_only STREQUAL 'yes' +) +qt_feature("geniviextras" PUBLIC + LABEL "Qt GENIVI Extras" + CONDITION QT_FEATURE_dlt +) +qt_configure_add_summary_section(NAME "Qt GENIVI Extras") +qt_configure_add_summary_entry(ARGS "dlt") +qt_configure_add_summary_entry(ARGS "dlt_2_12") +qt_configure_end_summary_section() # end of "Qt GENIVI Extras" section +qt_configure_add_summary_entry( + ARGS "geniviextras" + CONDITION NOT QT_FEATURE_geniviextras +) +qt_configure_add_report_entry( + TYPE NOTE + MESSAGE "No DLT libs found. Disabled building Qt GENIVI Extras." + CONDITION NOT QT_FEATURE_dlt +) +qt_configure_add_report_entry( + TYPE NOTE + MESSAGE "Old DLT version detected. Not all features of Qt GENIVI Extras can be enabled." + CONDITION QT_FEATURE_dlt AND NOT QT_FEATURE_dlt_2_12 +) +qt_configure_add_report_entry( + TYPE ERROR + MESSAGE "Mandatory dependency missing for only building Qt GENIVI Extras." + CONDITION NOT QT_FEATURE_dlt AND INPUT_geniviextras_only STREQUAL 'yes' +) diff --git a/src/geniviextras/CMakeLists.txt b/src/geniviextras/CMakeLists.txt index 75cdd82..7dfc8b6 100644 --- a/src/geniviextras/CMakeLists.txt +++ b/src/geniviextras/CMakeLists.txt @@ -10,8 +10,8 @@ qt_add_module(GeniviExtras qdltregistration.cpp qdltregistration.h qdltregistration_p.h qgeniviextrasglobal.h qgeniviextrasglobal_p.h PUBLIC_LIBRARIES + DLT::DLT Qt::Core - dlt ) #### Keys ignored in scope 1:.:.:geniviextras.pro:: diff --git a/src/geniviextras/configure.cmake b/src/geniviextras/configure.cmake index 59ccafe..35196b8 100644 --- a/src/geniviextras/configure.cmake +++ b/src/geniviextras/configure.cmake @@ -6,6 +6,7 @@ #### Libraries +qt_find_package(DLT PROVIDED_TARGETS DLT::DLT MODULE_NAME geniviextras QMAKE_LIB dlt) #### Tests @@ -17,12 +18,12 @@ qt_feature("dlt" PRIVATE LABEL "DLT" AUTODETECT UNIX - CONDITION libs.dlt OR FIXME + CONDITION DLT_FOUND # special case ) qt_feature("dlt_2_12" PRIVATE LABEL "DLT > 2.12" AUTODETECT UNIX - CONDITION libs.dlt_2_12 OR FIXME + CONDITION DLT_VERSION VERSION_GREATER_EQUAL 2.12 # special case ) qt_feature("geniviextras-only" PRIVATE LABEL "Only build Qt GENIVI Extras" diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt index 54f11ee..dec330a 100644 --- a/tests/auto/CMakeLists.txt +++ b/tests/auto/CMakeLists.txt @@ -6,6 +6,6 @@ endif() if(TARGET ivivehiclefunctions) add_subdirectory(vehiclefunctions) endif() -if(TARGET geniviextras) +if(TARGET Qt::GeniviExtras) add_subdirectory(dlt) endif() diff --git a/tests/auto/dlt/CMakeLists.txt b/tests/auto/dlt/CMakeLists.txt index d33ae0b..24cb772 100644 --- a/tests/auto/dlt/CMakeLists.txt +++ b/tests/auto/dlt/CMakeLists.txt @@ -10,9 +10,9 @@ qt_add_test(tst_dlt DEFINES SRCDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/\\\" PUBLIC_LIBRARIES + DLT::DLT + Qt::GeniviExtras Qt::Gui - dlt - geniviextras ) #### Keys ignored in scope 1:.:.:dlt.pro:: -- cgit v1.2.3