diff --git a/test/utests/CMakeLists.txt b/test/utests/CMakeLists.txt index a49bae849a..a9b5211d35 100644 --- a/test/utests/CMakeLists.txt +++ b/test/utests/CMakeLists.txt @@ -39,10 +39,12 @@ find_package(PkgConfig REQUIRED) pkg_check_modules(OPENSSL REQUIRED openssl) include_directories(${OPENSSL_INCLUDE_DIRS}) -pkg_check_modules(GTEST REQUIRED gtest) -pkg_check_modules(GMOCK REQUIRED gmock) -# Note: We call pkg_check_modules above to satisfy any legacy checks, but we'll override -# the variables below after FetchContent provides the actual googletest targets +# Try to find gtest/gmock via pkg-config (for systems with pre-installed googletest) +# but don't require it - FetchContent will provide it if not found +pkg_check_modules(GTEST gtest) +pkg_check_modules(GMOCK gmock) +# Note: If pkg-config finds gtest/gmock, we'll still override with FetchContent below +# to ensure consistent versions and avoid ABI mismatches # Middleware headers are now provided via: # - External middleware-player-interface pkg-config (for CI builds) @@ -95,6 +97,8 @@ FetchContent_MakeAvailable(googletest) # Now that googletest targets exist, set up include dirs and link libraries set(GTEST_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/_deps/googletest-src/googletest/include") set(GMOCK_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/_deps/googletest-src/googlemock/include") +# FetchContent creates CMake targets: gtest, gmock +# These are proper CMake targets that will be resolved during linking set(GTEST_LINK_LIBRARIES gtest) set(GMOCK_LINK_LIBRARIES gmock gtest) # Add FetchContent gtest/gmock include dirs globally diff --git a/test/utests/fakes/CMakeLists.txt b/test/utests/fakes/CMakeLists.txt index d023392dc9..4174643f71 100644 --- a/test/utests/fakes/CMakeLists.txt +++ b/test/utests/fakes/CMakeLists.txt @@ -22,10 +22,13 @@ set(UTESTS_ROOT "..") # Middleware headers - use external middleware-player-interface if available via pkg-config # Otherwise fall back to middleware-player-interface repo (GitHub Actions) or internal aamp/middleware -# Note: .libs/include is NOT used because it contains gtest headers that conflict with FetchContent if(PLAYERFBINTERFACE_INCLUDE_DIRS) # External middleware via pkg-config (preferred for installed middleware) message(STATUS "Using external middleware-player-interface via pkg-config") + # Add FetchContent gtest/gmock FIRST with BEFORE SYSTEM to ensure they take precedence + # over any gmock/gtest subdirectories in .libs/include + include_directories(BEFORE SYSTEM ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS}) + # Now add middleware include dirs (which may include .libs/include with middleware headers) include_directories(${PLAYERFBINTERFACE_INCLUDE_DIRS}) include_directories(${BASECONVERSION_INCLUDE_DIRS}) include_directories(${PLAYERLOGMANAGER_INCLUDE_DIRS}) diff --git a/test/utests/tests/AampDRMLicManagerTests/CMakeLists.txt b/test/utests/tests/AampDRMLicManagerTests/CMakeLists.txt index e1958e78e0..e3cce7952e 100644 --- a/test/utests/tests/AampDRMLicManagerTests/CMakeLists.txt +++ b/test/utests/tests/AampDRMLicManagerTests/CMakeLists.txt @@ -26,7 +26,9 @@ include_directories(${DRM_ROOT}) include_directories(${DRM_ROOT}/mocks) include_directories(${AAMP_ROOT}/drm) include_directories(${AAMP_ROOT}/test/utests/drm/ocdm) -include_directories(${AAMP_ROOT}/.libs/include) +# Note: .libs/include is NOT used because it contains old gtest/gmock headers +# that conflict with FetchContent googletest. Middleware headers are provided +# via conditional logic in fakes/CMakeLists.txt and tests/CommonTestIncludes.cmake set(TEST_SOURCES AampDRMLicManagerTestCases.cpp diff --git a/test/utests/tests/AampLogManagerTests/CMakeLists.txt b/test/utests/tests/AampLogManagerTests/CMakeLists.txt index 634b9eabec..81369edd5e 100644 --- a/test/utests/tests/AampLogManagerTests/CMakeLists.txt +++ b/test/utests/tests/AampLogManagerTests/CMakeLists.txt @@ -36,8 +36,9 @@ include_directories(${LibXml2_INCLUDE_DIRS}) include_directories(SYSTEM ${UTESTS_ROOT}/mocks) include_directories(${LIBCJSON_INCLUDE_DIRS}) include_directories(${AAMP_ROOT}/tsb/api) -# Use external middleware headers instead of deprecated aamp/middleware -include_directories(${AAMP_ROOT}/.libs/include) +# Note: .libs/include is NOT used because it contains old gtest/gmock headers +# that conflict with FetchContent googletest. Middleware headers are provided +# via conditional logic in fakes/CMakeLists.txt and tests/CommonTestIncludes.cmake set(TEST_SOURCES AampLogManagerTests.cpp diff --git a/test/utests/tests/CommonTestIncludes.cmake b/test/utests/tests/CommonTestIncludes.cmake index 06dc2508a5..3a6a4e4a72 100644 --- a/test/utests/tests/CommonTestIncludes.cmake +++ b/test/utests/tests/CommonTestIncludes.cmake @@ -44,6 +44,10 @@ include_directories(SYSTEM ${UTESTS_ROOT}/mocks) # For legacy builds without external middleware, fall back to middleware-player-interface repo or internal paths if(PLAYERFBINTERFACE_INCLUDE_DIRS) # External middleware (preferred) + # Add FetchContent gtest/gmock FIRST with BEFORE SYSTEM to ensure they take precedence + # over any gmock/gtest subdirectories in .libs/include + include_directories(BEFORE SYSTEM ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS}) + # Now add middleware include dirs (which may include .libs/include with middleware headers) include_directories(${PLAYERFBINTERFACE_INCLUDE_DIRS}) include_directories(${BASECONVERSION_INCLUDE_DIRS}) include_directories(${PLAYERLOGMANAGER_INCLUDE_DIRS}) diff --git a/test/utests/tests/FragmentCollectorMpdTests/CMakeLists.txt b/test/utests/tests/FragmentCollectorMpdTests/CMakeLists.txt index dc905c57af..e0c7df1237 100644 --- a/test/utests/tests/FragmentCollectorMpdTests/CMakeLists.txt +++ b/test/utests/tests/FragmentCollectorMpdTests/CMakeLists.txt @@ -37,8 +37,9 @@ include_directories(${LibXml2_INCLUDE_DIRS}) include_directories(SYSTEM ${UTESTS_ROOT}/mocks) include_directories(${LIBCJSON_INCLUDE_DIRS}) include_directories(${AAMP_ROOT}/tsb/api) -# Use external middleware headers instead of deprecated aamp/middleware -include_directories(${AAMP_ROOT}/.libs/include) +# Note: .libs/include is NOT used because it contains old gtest/gmock headers +# that conflict with FetchContent googletest. Middleware headers are provided +# via conditional logic in fakes/CMakeLists.txt and tests/CommonTestIncludes.cmake set(TEST_SOURCES FragmentCollectorMpdTests.cpp diff --git a/test/utests/tests/Scte35Tests/CMakeLists.txt b/test/utests/tests/Scte35Tests/CMakeLists.txt index a8b6871e1e..98e7e4d5b9 100644 --- a/test/utests/tests/Scte35Tests/CMakeLists.txt +++ b/test/utests/tests/Scte35Tests/CMakeLists.txt @@ -25,9 +25,9 @@ set(EXEC_NAME Scte35Tests) include(${CMAKE_CURRENT_LIST_DIR}/../CommonTestIncludes.cmake) include_directories(${AAMP_ROOT}/test/aampcli) -if(CMAKE_SYSTEM_NAME STREQUAL Linux) - include_directories(${AAMP_ROOT}/.libs/include) -endif(CMAKE_SYSTEM_NAME STREQUAL Linux) +# Note: .libs/include is NOT used because it contains old gtest/gmock headers +# that conflict with FetchContent googletest. Middleware headers are provided +# via conditional logic in fakes/CMakeLists.txt and tests/CommonTestIncludes.cmake set(TEST_SOURCES Scte35Tests.cpp Scte35SectionTests.cpp