Commit 7262c7b1 authored by Timo Aaltonen's avatar Timo Aaltonen

Build using system gtest.

parent 11f6de7c
intel-mediasdk (18.4.1-2) UNRELEASED; urgency=medium
* copyright: Updated.
* Build using system gtest.
-- Timo Aaltonen <tjaalton@debian.org> Tue, 26 Mar 2019 20:24:19 +0200
......
......@@ -5,6 +5,8 @@ Maintainer: Timo Aaltonen <tjaalton@debian.org>
Build-Depends: debhelper (>= 11),
cmake,
libdrm-dev,
libgmock-dev,
libgtest-dev,
libpciaccess-dev,
libva-dev,
libx11-dev,
......
usr/bin/asg-hevc
usr/bin/hevc_fei_extractor
usr/share/mfx/samples/*
usr/share/mfx/tests/mfx_dispatch_test
From bb8710d9030a8f10bea7ade067180f297ca0a7ab Mon Sep 17 00:00:00 2001
From: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Date: Tue, 5 Feb 2019 12:34:32 -0800
Subject: [PATCH 1/5] build: do not install gtest
Fixes: #1165
cmake option() rewrites set() without FORCE flag which we tried
to use to instuct gtest to avoid installation path.
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
---
CMakeLists.txt | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -80,6 +80,7 @@ cmake_dependent_option(BUILD_SAMPLES "Bu
# following BUILD_TOOLS option declaration assures that.
cmake_dependent_option(BUILD_TOOLS "Build tools?" "${BUILD_ALL}" "BUILD_SAMPLES" OFF)
option(BUILD_TESTS "Build tests?" "${BUILD_ALL}")
+option(USE_SYSTEM_GTEST "Use system installed gtest?" OFF)
include( ${BUILDER_ROOT}/FindOpenCL.cmake )
include( ${BUILDER_ROOT}/FindFunctions.cmake )
@@ -90,6 +91,29 @@ include( ${BUILDER_ROOT}/FindInternals.c
include( ${BUILDER_ROOT}/FindITT.cmake )
include( ${BUILDER_ROOT}/ConfTargets.cmake )
+if (BUILD_TESTS)
+ if (NOT USE_SYSTEM_GTEST)
+ # Our intent is to use gtest for building, we do not want to install it.
+ # To achieve that we need to force set INSTALL_GTEST=OFF otherwise
+ # according to cmake rules it will be overwritten by option() default
+ # which might be ON.
+ set(INSTALL_GTEST OFF CACHE BOOL "Do _not_ install gtest" FORCE)
+
+ add_subdirectory(${CMAKE_HOME_DIRECTORY}/googletest)
+
+ # For some Linux distro versions there is an unused-result warning
+ # generated inside the Gtest code at a call to fwrite. Since Gtest sets -Werror
+ # internally the only way to make it compile without modifying its source is to disable the
+ # unused-result warnings for Gtest/Gmock only.
+ target_compile_options (gtest PRIVATE "-Wno-unused-result")
+ target_compile_options (gmock PRIVATE "-Wno-unused-result")
+ target_compile_options (gtest_main PRIVATE "-Wno-unused-result")
+ target_compile_options (gmock_main PRIVATE "-Wno-unused-result")
+ endif()
+
+ enable_testing()
+endif()
+
# should prepend others to define target mfx
if (BUILD_DISPATCHER)
add_subdirectory(api/mfx_dispatch/linux)
@@ -109,21 +133,6 @@ if (BUILD_RUNTIME)
endif()
if (BUILD_TESTS)
- enable_testing()
-
-
- set (INSTALL_GTEST OFF)
- add_subdirectory(${CMAKE_HOME_DIRECTORY}/googletest)
-
- # For some Linux distro versions there is an unused-result warning
- # generated inside the Gtest code at a call to fwrite. Since Gtest sets -Werror
- # internally the only way to make it compile without modifying its source is to disable the
- # unused-result warnings for Gtest/Gmock only.
- target_compile_options (gtest PRIVATE "-Wno-unused-result")
- target_compile_options (gmock PRIVATE "-Wno-unused-result")
- target_compile_options (gtest_main PRIVATE "-Wno-unused-result")
- target_compile_options (gmock_main PRIVATE "-Wno-unused-result")
-
add_subdirectory(tests)
endif()
--- a/samples/metrics_monitor/CMakeLists.txt
+++ b/samples/metrics_monitor/CMakeLists.txt
@@ -44,8 +44,6 @@ if( PKG_LIBDRM_FOUND AND
set_target_properties(test_monitor PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BIN_DIR}/${CMAKE_BUILD_TYPE})
- install( TARGETS test_monitor RUNTIME DESTINATION ${MFX_SAMPLES_INSTALL_BIN_DIR} )
-
else()
if( NOT PKG_PCIACCESS_FOUND )
--- a/tests/mfx_dispatch/linux/CMakeLists.txt
+++ b/tests/mfx_dispatch/linux/CMakeLists.txt
@@ -59,7 +59,23 @@ add_test(NAME run_mfx_dispatch_test
COMMAND ./mfx_dispatch_test
WORKING_DIRECTORY ${CMAKE_BIN_DIR}/${CMAKE_BUILD_TYPE})
-set_property(TEST run_mfx_dispatch_test PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BIN_DIR}/${CMAKE_BUILD_TYPE}")
+set(LIBRARY_PATH "${CMAKE_BIN_DIR}/${CMAKE_BUILD_TYPE}")
-install(TARGETS mfx_dispatch_test RUNTIME DESTINATION ${MFX_APPS_DIR}/tests)
+# If we build against embedded copy of gtest/gmock, we need to make sure that
+# we load those .so libraries which we built and avoid system libraries which
+# also might present. Hence, we explicitly set LD_LIBRARY_PATH per target
+# properties.
+if(TARGET gtest)
+ get_target_property(type gtest TYPE)
+ if(type STREQUAL "SHARED_LIBRARY")
+ set(LIBRARY_PATH "${LIBRARY_PATH}:$<TARGET_FILE_DIR:gtest>")
+ endif()
+endif()
+if(TARGET gmock)
+ get_target_property(type gmock TYPE)
+ if(type STREQUAL "SHARED_LIBRARY")
+ set(LIBRARY_PATH "${LIBRARY_PATH}:$<TARGET_FILE_DIR:gmock>")
+ endif()
+endif()
+set_property(TEST run_mfx_dispatch_test PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=${LIBRARY_PATH}")
allow-system-gtest.diff
......@@ -10,6 +10,7 @@ override_dh_auto_configure:
-DENABLE_TEXTLOG=ON \
-DENABLE_STAT=ON \
-DBUILD_ALL=ON \
-DUSE_SYSTEM_GTEST=ON \
-DINSTALL_GTEST=OFF
# needs intel-graphics-compiler
# -DBUILD_KERNELS=ON
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment