Warning, /multimedia/amarok/cmake/modules/FindGooglemock.cmake is written in an unsupported language. File is not indexed.

0001 # - Find Googlemock
0002 # Find the google mock includes and the google mock libraries
0003 # This module defines
0004 # GOOGLEMOCK_INCLUDE_DIR, root google mock include dir
0005 # GOOGLEMOCK_LIBRARY, the path to Google Mock library
0006 # GOOGLEMOCK_LIBRARIES, the path to Google Mock and Google Test library
0007 # GOOGLEMOCK_FOUND, whether Google Mock was found
0008 #
0009 # since google test and google mock is not supposed to be supplied pre-compiled
0010 # we try to find the google mock sources as a fallback
0011 
0012 find_program(GMOCK-CONFIG_EXECUTABLE NAMES gmock-config PATHS
0013        ${BIN_INSTALL_DIR}
0014        /opt/local/bin
0015        /usr/bin
0016 )
0017 
0018 if(GMOCK-CONFIG_EXECUTABLE)
0019 exec_program(${GMOCK-CONFIG_EXECUTABLE} ARGS --includedir OUTPUT_VARIABLE GOOGLEMOCK_INCLUDE_DIR)
0020 exec_program(${GMOCK-CONFIG_EXECUTABLE} ARGS --ldflags OUTPUT_VARIABLE GOOGLEMOCK_LDFLAGS)
0021 exec_program(${GMOCK-CONFIG_EXECUTABLE} ARGS --libs OUTPUT_VARIABLE GOOGLEMOCK_libs_tmp)
0022 set(GOOGLEMOCK_LIBRARIES ${GOOGLEMOCK_LDFLAGS} ${GOOGLEMOCK_libs_tmp})
0023 
0024 if(GOOGLEMOCK_INCLUDE_DIR AND GOOGLEMOCK_LIBRARIES)
0025    set(GOOGLEMOCK_FOUND TRUE)
0026    message(STATUS "Found libgmock: ${GOOGLEMOCK_INCLUDE_DIR}, ${GOOGLEMOCK_LIBRARIES}")
0027 else()
0028    set(GOOGLEMOCK_FOUND FALSE)
0029    if (GOOGLEMOCK_FIND_REQUIRED)
0030       message(FATAL_ERROR "Could NOT find required package Googlemock")
0031    endif()
0032 endif()
0033 
0034 else()
0035 
0036 find_path(GOOGLEMOCK_INCLUDE_DIR NAMES gmock/gmock.h
0037    HINTS
0038    ~/usr/include
0039    /opt/local/include
0040    /usr/include
0041    /usr/local/include
0042 )
0043 
0044 find_library( GOOGLEMOCK_LIBRARY NAMES gmock
0045     PATHS
0046     ~/usr/lib
0047    /opt/local/lib
0048    /usr/lib
0049    /usr/lib64
0050    /usr/local/lib
0051 )
0052 
0053 find_library( GOOGLEMOCK_DEP_GTEST_LIBRARY NAMES gtest
0054     PATHS
0055     ~/usr/lib
0056    /opt/local/lib
0057    /usr/lib
0058    /usr/lib64
0059    /usr/local/lib
0060 )
0061 
0062 # google-mock >= 1.5 requires pthread
0063 # see: http://code.google.com/p/googlemock/source/browse/trunk/CHANGES
0064 if( NOT WIN32 AND GOOGLEMOCK_LIBRARY )
0065     find_library( GOOGLEMOCK_DEP_PTHREAD_LIBRARY NAMES pthread
0066         PATHS
0067         ~/usr/lib
0068        /opt/local/lib
0069        /usr/lib
0070        /usr/lib64
0071        /usr/local/lib
0072     )
0073 
0074 endif()
0075 
0076 # Google recommends not to distribute a pre-build libary and ubuntu is following
0077 # this advice with libgtest 1.6.0
0078 # However they are distributing sources, so we are looking if we at least have
0079 # them available
0080 if( NOT GOOGLEMOCK_DEP_GTEST_LIBRARY )
0081     find_path( GOOGLEMOCK_SOURCES NAMES gmock
0082         PATHS /usr/src
0083         NO_DEFAULT_PATH
0084         NO_CMAKE_PATH
0085     )
0086 
0087     # found googlemock as sources. then we also have the gtest sources since they
0088     # are included
0089     if( GOOGLEMOCK_SOURCES )
0090         find_path( GOOGLEMOCK_DEP_GTEST_SOURCES NAMES gtest
0091             PATHS "${GOOGLEMOCK_SOURCES}/gmock"
0092             NO_DEFAULT_PATH
0093             NO_CMAKE_PATH
0094         )
0095 
0096         # make sure that we use the gtest supplied with googlemock
0097         set(GOOGLEMOCK_INCLUDE_DIR
0098             "${GOOGLEMOCK_INCLUDE_DIR}" 
0099             "${GOOGLEMOCK_SOURCES}/gmock" 
0100             "${GOOGLEMOCK_DEP_GTEST_SOURCES}/gtest/include"
0101         )
0102 
0103     elseif( GOOGLEMOCK_SOURCES )
0104         find_path( GOOGLEMOCK_DEP_GTEST_SOURCES NAMES gtest
0105             PATHS /usr/src
0106             NO_DEFAULT_PATH
0107             NO_CMAKE_PATH
0108         )
0109 
0110         # in this case we also have to use the static google mock library
0111         set( OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
0112         set( CMAKE_FIND_LIBRARY_SUFFIXES .a)
0113         find_library( GOOGLEMOCK_LIBRARY_STATIC NAMES gmock
0114             PATHS
0115             ~/usr/lib
0116            /opt/local/lib
0117            /usr/lib
0118            /usr/lib64
0119            /usr/local/lib
0120         )
0121         set( CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES})
0122     endif()
0123 
0124 endif()
0125 
0126 # -- googlemock and gtest library available
0127 if(GOOGLEMOCK_INCLUDE_DIR AND GOOGLEMOCK_LIBRARY AND GOOGLEMOCK_DEP_GTEST_LIBRARY)
0128    set(GOOGLEMOCK_FOUND TRUE)
0129    set(GOOGLEMOCK_LIBRARIES ${GOOGLEMOCK_LIBRARY} ${GOOGLEMOCK_DEP_GTEST_LIBRARY} ${GOOGLEMOCK_DEP_PTHREAD_LIBRARY})
0130    message(STATUS "Found libgmock: ${GOOGLEMOCK_INCLUDE_DIR}, ${GOOGLEMOCK_LIBRARIES}")
0131 
0132 
0133 # -- googlemock and gtest sources available
0134 elseif(GOOGLEMOCK_INCLUDE_DIR AND GOOGLEMOCK_LIBRARY AND GOOGLEMOCK_DEP_GTEST_SOURCES)
0135    set(GOOGLEMOCK_FOUND TRUE)
0136    set(GOOGLEMOCK_LIBRARIES ${GOOGLEMOCK_LIBRARY_STATIC} gtest)
0137    set(GOOGLEMOCK_GTEST_SOURCES "${GOOGLEMOCK_DEP_GTEST_SOURCES}/gtest" CACHE PATH "Path to the gtest sources")
0138    message(STATUS "Found libgmock but need to build gtest: ${GOOGLEMOCK_INCLUDE_DIR}, ${GOOGLEMOCK_LIBRARIES} ${GOOGLEMOCK_DEP_GTEST_SOURCES}")
0139 
0140 # -- googlemock sources and gtest sources available
0141 elseif(GOOGLEMOCK_SOURCES)
0142    set(GOOGLEMOCK_FOUND TRUE)
0143    set(GOOGLEMOCK_LIBRARIES gtest)
0144    set(GOOGLEMOCK_SRCS "${GOOGLEMOCK_SOURCES}/gmock/src/gmock-all.cc" CACHE PATH "Google mock source file that needs to be added")
0145    set(GOOGLEMOCK_SOURCES "${GOOGLEMOCK_SOURCES}/gmock" CACHE PATH "Path to the google-mock sources")
0146    set(GOOGLEMOCK_GTEST_SOURCES "${GOOGLEMOCK_DEP_GTEST_SOURCES}/gtest" CACHE PATH "Path to the gtest sources")
0147    message(STATUS "Found gmock and gtest but need to build both: ${GOOGLEMOCK_INCLUDE_DIR}, ${GOOGLEMOCK_DEP_GTEST_SOURCES}")
0148    mark_as_advanced(GOOGLEMOCK_SRCS)
0149 
0150 # -- googlemock but no gtest
0151 else()
0152    set(GOOGLEMOCK_FOUND FALSE)
0153    if (GOOGLEMOCK_FIND_REQUIRED)
0154       message(FATAL_ERROR "Could NOT find required package Googlemock or gtest")
0155    endif()
0156 endif()
0157 
0158 endif()
0159 
0160 mark_as_advanced(GOOGLEMOCK_INCLUDE_DIR GOOGLEMOCK_LIBRARIES)