diff options
| author | Martin Jansa <Martin.Jansa@gmail.com> | 2021-11-18 12:32:19 +0100 |
|---|---|---|
| committer | Armin Kuster <akuster808@gmail.com> | 2021-11-18 07:37:57 -0800 |
| commit | d9717dea53557840e600b3fe3f19e2616acf23e4 (patch) | |
| tree | d8ba77c38e44f9588ecb8f01abda32c8a0924c76 | |
| parent | c618e90cdad6bc7f9776f4d75be3f583a6dfbb1d (diff) | |
| download | meta-openembedded-d9717dea53557840e600b3fe3f19e2616acf23e4.tar.gz | |
sdbus-c++: don't fetch googletest during do_configure
* with PTEST_ENABLED it enables with-tests PACKAGECONFIG which
instead of using system googletest gmock, tries to fetch googletest
from github and fails because branch was recently renamed from master to main
| -- Found PkgConfig: /OE/tmp-glibc/work/qemux86-oe-linux/sdbus-c++/0.8.3-r0/recipe-sysroot-native/usr/bin/pkg-config (found version "0.29.2")
| -- Checking for module 'libsystemd>=236'
| -- Found libsystemd, version 249
| -- Building with tests
| Fetching googletest...
| [1/9] Creating directories for 'googletest-populate'
| [1/9] Performing download step (git clone) for 'googletest-populate'
| Cloning into 'googletest-src'...
| fatal: invalid reference: master
| CMake Error at googletest-subbuild/googletest-populate-prefix/tmp/googletest-populate-gitclone.cmake:40 (message):
| Failed to checkout tag: 'master'
|
|
| FAILED: googletest-populate-prefix/src/googletest-populate-stamp/googletest-populate-download
| cd /OE/tmp-glibc/work/qemux86-oe-linux/sdbus-c++/0.8.3-r0/build/_deps && /OE/tmp-glibc/work/qemux86-oe-linux/sdbus-c++/0.8.3-r0/recipe-sysroot-native/usr/bin/cmake -P /OE/tmp-glibc/work/qemux86-oe-linux/sdbus-c++/0.8.3-r0/build/_deps/googletest-subbuild/googletest-populate-prefix/tmp/googletest-populate-gitclone.cmake && /OE/tmp-glibc/work/qemux86-oe-linux/sdbus-c++/0.8.3-r0/recipe-sysroot-native/usr/bin/cmake -E touch /OE/tmp-glibc/work/qemux86-oe-linux/sdbus-c++/0.8.3-r0/build/_deps/googletest-subbuild/googletest-populate-prefix/src/googletest-populate-stamp/googletest-populate-download
| ninja: build stopped: subcommand failed.
|
| CMake Error at /OE/tmp-glibc/work/qemux86-oe-linux/sdbus-c++/0.8.3-r0/recipe-sysroot-native/usr/share/cmake-3.19/Modules/FetchContent.cmake:989 (message):
| Build step for googletest failed: 1
| Call Stack (most recent call first):
| /OE/tmp-glibc/work/qemux86-oe-linux/sdbus-c++/0.8.3-r0/recipe-sysroot-native/usr/share/cmake-3.19/Modules/FetchContent.cmake:1118:EVAL:2 (__FetchContent_directPopulate)
| /OE/tmp-glibc/work/qemux86-oe-linux/sdbus-c++/0.8.3-r0/recipe-sysroot-native/usr/share/cmake-3.19/Modules/FetchContent.cmake:1118 (cmake_language)
| tests/CMakeLists.txt:17 (FetchContent_Populate)
|
|
| -- Configuring incomplete, errors occurred!
* unfortunately this backported patch fixes the fetching failure, because
it uses release-${GOOGLETEST_VERSION} tag instead of now non-existent
master branch, but is not enough to prevent fetching from github during
do_configure:
-- Building with tests
-- Could NOT find GTest (missing: GTest_DIR)
-- Checking for module 'gmock>=1.10.0'
-- No package 'gmock' found
Fetching googletest...
we also need to add googletest dependency to with-tests PACKAGECONFIG was fixed in meta-oe/master with the upgrade to 1.0.0:
https://github.com/openembedded/meta-openembedded/commit/b26b66e5da92718b4e99a57fbfaaef9e751c3cfe#diff-48a847e7323703994fd2ce0fcb731ff860fa955a77cdfe39d71a9cc84a042c06L15
then it's ok and not fetching:
-- Building with tests
-- Looking for pthread.h
-- Looking for pthread.h - found
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
| -rw-r--r-- | meta-oe/recipes-core/sdbus-c++/sdbus-c++-0.8.1/0001-Try-to-first-find-googletest-in-the-system-before-do.patch | 96 | ||||
| -rw-r--r-- | meta-oe/recipes-core/sdbus-c++/sdbus-c++_0.8.1.bb | 9 |
2 files changed, 102 insertions, 3 deletions
diff --git a/meta-oe/recipes-core/sdbus-c++/sdbus-c++-0.8.1/0001-Try-to-first-find-googletest-in-the-system-before-do.patch b/meta-oe/recipes-core/sdbus-c++/sdbus-c++-0.8.1/0001-Try-to-first-find-googletest-in-the-system-before-do.patch new file mode 100644 index 0000000000..89cb593e60 --- /dev/null +++ b/meta-oe/recipes-core/sdbus-c++/sdbus-c++-0.8.1/0001-Try-to-first-find-googletest-in-the-system-before-do.patch | |||
| @@ -0,0 +1,96 @@ | |||
| 1 | From b073e1c2b9a8138da83300f598b9a56fc9762b4b Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?Stanislav=20Angelovi=C4=8D?= <angelovic.s@gmail.com> | ||
| 3 | Date: Mon, 16 Nov 2020 17:05:36 +0100 | ||
| 4 | Subject: [PATCH] Try to first find googletest in the system before downloading | ||
| 5 | it (#125) | ||
| 6 | |||
| 7 | Upstream-Status: Backport [d6fdaca] | ||
| 8 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> | ||
| 9 | |||
| 10 | --- | ||
| 11 | tests/CMakeLists.txt | 62 ++++++++++++++++++++++++++++---------------- | ||
| 12 | 1 file changed, 40 insertions(+), 22 deletions(-) | ||
| 13 | |||
| 14 | diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt | ||
| 15 | index 97f7c1a..7ecc327 100644 | ||
| 16 | --- a/tests/CMakeLists.txt | ||
| 17 | +++ b/tests/CMakeLists.txt | ||
| 18 | @@ -2,26 +2,44 @@ | ||
| 19 | # DOWNLOAD AND BUILD OF GOOGLETEST | ||
| 20 | #------------------------------- | ||
| 21 | |||
| 22 | -include(FetchContent) | ||
| 23 | - | ||
| 24 | -message("Fetching googletest...") | ||
| 25 | -FetchContent_Declare(googletest | ||
| 26 | - GIT_REPOSITORY https://github.com/google/googletest.git | ||
| 27 | - GIT_TAG master | ||
| 28 | - GIT_SHALLOW 1 | ||
| 29 | - UPDATE_COMMAND "") | ||
| 30 | - | ||
| 31 | -#FetchContent_MakeAvailable(googletest) # Not available in CMake 3.13 :-( Let's do it manually: | ||
| 32 | -FetchContent_GetProperties(googletest) | ||
| 33 | -if(NOT googletest_POPULATED) | ||
| 34 | - FetchContent_Populate(googletest) | ||
| 35 | - set(gtest_force_shared_crt ON CACHE INTERNAL "" FORCE) | ||
| 36 | - set(BUILD_GMOCK ON CACHE INTERNAL "" FORCE) | ||
| 37 | - set(INSTALL_GTEST OFF CACHE INTERNAL "" FORCE) | ||
| 38 | - set(BUILD_SHARED_LIBS_BAK ${BUILD_SHARED_LIBS}) | ||
| 39 | - set(BUILD_SHARED_LIBS OFF) | ||
| 40 | - add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) | ||
| 41 | - set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_BAK}) | ||
| 42 | +set(GOOGLETEST_VERSION 1.10.0 CACHE STRING "Version of gmock to use") | ||
| 43 | +set(GOOGLETEST_GIT_REPO "https://github.com/google/googletest.git" CACHE STRING "A git repo to clone and build googletest from if gmock is not found in the system") | ||
| 44 | + | ||
| 45 | +find_package(GTest ${GOOGLETEST_VERSION} CONFIG) | ||
| 46 | +if (NOT TARGET GTest::gmock) | ||
| 47 | + # Try pkg-config if GTest was not found through CMake config | ||
| 48 | + find_package(PkgConfig) | ||
| 49 | + if (PkgConfig_FOUND) | ||
| 50 | + pkg_check_modules(GMock IMPORTED_TARGET GLOBAL gmock>=${GOOGLETEST_VERSION}) | ||
| 51 | + if(TARGET PkgConfig::GMock) | ||
| 52 | + add_library(GTest::gmock ALIAS PkgConfig::GMock) | ||
| 53 | + endif() | ||
| 54 | + endif() | ||
| 55 | + # GTest was not found in the system, build it on our own | ||
| 56 | + if (NOT TARGET GTest::gmock) | ||
| 57 | + include(FetchContent) | ||
| 58 | + | ||
| 59 | + message("Fetching googletest...") | ||
| 60 | + FetchContent_Declare(googletest | ||
| 61 | + GIT_REPOSITORY ${GOOGLETEST_GIT_REPO} | ||
| 62 | + GIT_TAG release-${GOOGLETEST_VERSION} | ||
| 63 | + GIT_SHALLOW 1 | ||
| 64 | + UPDATE_COMMAND "") | ||
| 65 | + | ||
| 66 | + #FetchContent_MakeAvailable(googletest) # Not available in CMake 3.13 :-( Let's do it manually: | ||
| 67 | + FetchContent_GetProperties(googletest) | ||
| 68 | + if(NOT googletest_POPULATED) | ||
| 69 | + FetchContent_Populate(googletest) | ||
| 70 | + set(gtest_force_shared_crt ON CACHE INTERNAL "" FORCE) | ||
| 71 | + set(BUILD_GMOCK ON CACHE INTERNAL "" FORCE) | ||
| 72 | + set(INSTALL_GTEST OFF CACHE INTERNAL "" FORCE) | ||
| 73 | + set(BUILD_SHARED_LIBS_BAK ${BUILD_SHARED_LIBS}) | ||
| 74 | + set(BUILD_SHARED_LIBS OFF) | ||
| 75 | + add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) | ||
| 76 | + set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_BAK}) | ||
| 77 | + add_library(GTest::gmock ALIAS gmock) | ||
| 78 | + endif() | ||
| 79 | + endif() | ||
| 80 | endif() | ||
| 81 | |||
| 82 | #------------------------------- | ||
| 83 | @@ -87,11 +105,11 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
| 84 | |||
| 85 | add_executable(sdbus-c++-unit-tests ${UNITTESTS_SRCS}) | ||
| 86 | target_compile_definitions(sdbus-c++-unit-tests PRIVATE LIBSYSTEMD_VERSION=${LIBSYSTEMD_VERSION}) | ||
| 87 | -target_link_libraries(sdbus-c++-unit-tests sdbus-c++-objlib gmock gmock_main) | ||
| 88 | +target_link_libraries(sdbus-c++-unit-tests sdbus-c++-objlib GTest::gmock) | ||
| 89 | |||
| 90 | add_executable(sdbus-c++-integration-tests ${INTEGRATIONTESTS_SRCS}) | ||
| 91 | target_compile_definitions(sdbus-c++-integration-tests PRIVATE LIBSYSTEMD_VERSION=${LIBSYSTEMD_VERSION}) | ||
| 92 | -target_link_libraries(sdbus-c++-integration-tests sdbus-c++ gmock gmock_main) | ||
| 93 | +target_link_libraries(sdbus-c++-integration-tests sdbus-c++ GTest::gmock) | ||
| 94 | |||
| 95 | # Manual performance and stress tests | ||
| 96 | option(ENABLE_PERF_TESTS "Build and install manual performance tests (default OFF)" OFF) | ||
diff --git a/meta-oe/recipes-core/sdbus-c++/sdbus-c++_0.8.1.bb b/meta-oe/recipes-core/sdbus-c++/sdbus-c++_0.8.1.bb index c4d63fd272..a94fb8deff 100644 --- a/meta-oe/recipes-core/sdbus-c++/sdbus-c++_0.8.1.bb +++ b/meta-oe/recipes-core/sdbus-c++/sdbus-c++_0.8.1.bb | |||
| @@ -12,13 +12,16 @@ PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'with-exte | |||
| 12 | ${@bb.utils.contains('PTEST_ENABLED', '1', 'with-tests', '', d)}" | 12 | ${@bb.utils.contains('PTEST_ENABLED', '1', 'with-tests', '', d)}" |
| 13 | PACKAGECONFIG[with-builtin-libsystemd] = ",,sdbus-c++-libsystemd,libcap" | 13 | PACKAGECONFIG[with-builtin-libsystemd] = ",,sdbus-c++-libsystemd,libcap" |
| 14 | PACKAGECONFIG[with-external-libsystemd] = ",,systemd,libsystemd" | 14 | PACKAGECONFIG[with-external-libsystemd] = ",,systemd,libsystemd" |
| 15 | PACKAGECONFIG[with-tests] = "-DBUILD_TESTS=ON -DTESTS_INSTALL_PATH=${libdir}/${BPN}/tests,-DBUILD_TESTS=OFF" | 15 | PACKAGECONFIG[with-tests] = "-DBUILD_TESTS=ON -DTESTS_INSTALL_PATH=${libdir}/${BPN}/tests,-DBUILD_TESTS=OFF,googletest gmock" |
| 16 | 16 | ||
| 17 | DEPENDS += "expat" | 17 | DEPENDS += "expat" |
| 18 | 18 | ||
| 19 | SRCREV = "3a4f343fb924650e7639660efa5f143961162044" | 19 | SRCREV = "3a4f343fb924650e7639660efa5f143961162044" |
| 20 | SRC_URI = "git://github.com/Kistler-Group/sdbus-cpp.git;protocol=https;branch=master" | 20 | |
| 21 | SRC_URI += "file://run-ptest" | 21 | SRC_URI = "git://github.com/Kistler-Group/sdbus-cpp.git;protocol=https;branch=master \ |
| 22 | file://0001-Try-to-first-find-googletest-in-the-system-before-do.patch \ | ||
| 23 | file://run-ptest \ | ||
| 24 | " | ||
| 22 | 25 | ||
| 23 | EXTRA_OECMAKE = "-DBUILD_CODE_GEN=ON \ | 26 | EXTRA_OECMAKE = "-DBUILD_CODE_GEN=ON \ |
| 24 | -DBUILD_DOC=ON \ | 27 | -DBUILD_DOC=ON \ |
