Commit ad02cf34 authored by Attila Krasznahorkay's avatar Attila Krasznahorkay
Browse files

Merge branch 'GMockFix-master-20220505' into 'master'

FindGMock Fix, master branch (2022.05.05.)

See merge request !950
parents 40f4022c 27e74c21
Pipeline #3961877 passed with stage
in 75 minutes and 33 seconds
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
#
# A simple module for finding the GoogleMock headers and libraries. It
# tries to mimic the behaviour of CMake's own FindGTest.cmake module,
......@@ -15,9 +15,16 @@ include( LCGFunctions )
lcg_external_module( NAME GMock
INCLUDE_SUFFIXES include INCLUDE_NAMES gmock/gmock.h
LIBRARY_SUFFIXES lib lib64
DEFAULT_COMPONENTS gmock
DEFAULT_COMPONENTS gmock gmockd
SEARCH_PATHS ${GTEST_LCGROOT} )
# If both the debug and optimised versions of the library were found, let's
# declare them correctly to CMake.
if( GMOCK_gmock_LIBRARY AND GMOCK_gmockd_LIBRARY )
set( GMOCK_LIBRARIES optimized ${GMOCK_gmock_LIBRARY}
debug ${GMOCK_gmockd_LIBRARY} )
endif()
# Handle the standard find_package arguments.
include( FindPackageHandleStandardArgs )
find_package_handle_standard_args( GMock DEFAULT_MSG GMOCK_INCLUDE_DIR
......@@ -28,9 +35,20 @@ mark_as_advanced( GMOCK_FOUND GMOCK_INCLUDE_DIR GMOCK_INCLUDE_DIRS
# If the main GMock library was found, set up variables mimicking those
# configured by CMake's own FindGTest.cmake.
if( GMOCK_FOUND )
find_library( GMOCK_MAIN_LIBRARIES
find_library( GMOCK_MAIN_LIBRARY
NAMES gmock_main PATH_SUFFIXES lib lib64
PATHS ${GMOCK_LCGROOT} )
find_library( GMOCK_MAIN_LIBRARY_DEBUG
NAMES gmock_maind PATH_SUFFIXES lib lib64
PATHS ${GMOCK_LCGROOT} )
if( GMOCK_MAIN_LIBRARY AND GMOCK_MAIN_LIBRARY_DEBUG )
set( GMOCK_MAIN_LIBRARIES optimized ${GMOCK_MAIN_LIBRARY}
debug ${GMOCK_MAIN_LIBRARY_DEBUG} )
elseif( GMOCK_MAIN_LIBRARY )
set( GMOCK_MAIN_LIBRARIES ${GMOCK_MAIN_LIBRARY} )
elseif( GMOCK_MAIN_LIBRARY_DEBUG )
set( GMOCK_MAIN_LIBRARIES ${GMOCK_MAIN_LIBRARY_DEBUG} )
endif()
endif()
# Set up an RPM dependency.
......
......@@ -150,8 +150,8 @@ function( lcg_external_module )
# Find the library/libraries:
if( ${ARG_NAME}_FIND_COMPONENTS )
# Clear out the library variables:
set( ${nameUpper}_LIBRARIES )
set( ${nameUpper}_LIBRARY_DIRS )
set( ${nameUpper}_LIBRARIES ${nameUpper}_LIBRARIES-NOTFOUND )
set( ${nameUpper}_LIBRARY_DIRS ${nameUpper}_LIBRARY_DIRS-NOTFOUND )
# Find the requested component(s):
foreach( component ${${ARG_NAME}_FIND_COMPONENTS} )
# Search for the requested library:
......@@ -193,11 +193,20 @@ function( lcg_external_module )
$<INSTALL_INTERFACE:${_relocatableLib}> PARENT_SCOPE )
endif()
list( APPEND ${nameUpper}_FOUND_COMPONENTS ${component} )
list( APPEND ${nameUpper}_LIBRARIES
${${nameUpper}_${component}_LIBRARY} )
if( NOT ${nameUpper}_LIBRARIES )
set( ${nameUpper}_LIBRARIES
${${nameUpper}_${component}_LIBRARY} )
else()
list( APPEND ${nameUpper}_LIBRARIES
${${nameUpper}_${component}_LIBRARY} )
endif()
get_filename_component( _libdir
${_${nameUpper}_${component}_library} PATH )
list( APPEND ${nameUpper}_LIBRARY_DIRS ${_libdir} )
if( NOT ${nameUpper}_LIBRARY_DIRS )
set( ${nameUpper}_LIBRARY_DIRS ${_libdir} )
else()
list( APPEND ${nameUpper}_LIBRARY_DIRS ${_libdir} )
endif()
unset( _relocatableLib )
unset( _libdir )
else()
......
Supports Markdown
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