|
@@ -1,169 +1,129 @@
|
|
|
-##############################################################################
|
|
|
-# @file FindGMock.cmake
|
|
|
-# @brief Find Google Mock package.
|
|
|
-#
|
|
|
-# @par Input variables:
|
|
|
-# <table border="0">
|
|
|
-# <tr>
|
|
|
-# @tp @b GMock_DIR @endtp
|
|
|
-# <td>The Google Mock package files are searched under the specified
|
|
|
-# root directory. If they are not found there, the default search
|
|
|
-# paths are considered. This variable can also be set as environment
|
|
|
-# variable.</td>
|
|
|
-# </tr>
|
|
|
-# <tr>
|
|
|
-# @tp @b GMOCK_DIR @endtp
|
|
|
-# <td>Alternative environment variable for @p GMock_DIR.</td>
|
|
|
-# </tr>
|
|
|
-# <tr>
|
|
|
-# @tp @b GMock_SHARED_LIBRARIES @endtp
|
|
|
-# <td>Forces this module to search for shared libraries.
|
|
|
-# Otherwise, static libraries are preferred.</td>
|
|
|
-# </tr>
|
|
|
-# </table>
|
|
|
-#
|
|
|
-# @par Output variables:
|
|
|
-# <table border="0">
|
|
|
-# <tr>
|
|
|
-# @tp @b GMock_FOUND @endtp
|
|
|
-# <td>Whether the package was found and the following CMake variables are valid.</td>
|
|
|
-# </tr>
|
|
|
-# <tr>
|
|
|
-# @tp @b GMock_INCLUDE_DIR @endtp
|
|
|
-# <td>Package include directories.</td>
|
|
|
-# </tr>
|
|
|
-# <tr>
|
|
|
-# @tp @b GMock_INCLUDES @endtp
|
|
|
-# <td>Include directories including prerequisite libraries.</td>
|
|
|
-# </tr>
|
|
|
-# <tr>
|
|
|
-# @tp @b GMock_LIBRARY @endtp
|
|
|
-# <td>Package libraries.</td>
|
|
|
-# </tr>
|
|
|
-# <tr>
|
|
|
-# @tp @b GMock_LIBRARIES @endtp
|
|
|
-# <td>Package ibraries and prerequisite libraries.</td>
|
|
|
-# </tr>
|
|
|
-# </table>
|
|
|
-#
|
|
|
-# @ingroup CMakeFindModules
|
|
|
-##############################################################################
|
|
|
-
|
|
|
+# Locate the Google C++ Mocking Framework.
|
|
|
+# (This file is almost an identical copy of the original FindGTest.cmake file,
|
|
|
+# feel free to use it as it is or modify it for your own needs.)
|
|
|
+#
|
|
|
+#
|
|
|
+# Defines the following variables:
|
|
|
+#
|
|
|
+# GMOCK_FOUND - Found the Google Testing framework
|
|
|
+# GMOCK_INCLUDE_DIRS - Include directories
|
|
|
+#
|
|
|
+# Also defines the library variables below as normal
|
|
|
+# variables. These contain debug/optimized keywords when
|
|
|
+# a debugging library is found.
|
|
|
+#
|
|
|
+# GMOCK_BOTH_LIBRARIES - Both libgmock & libgmock-main
|
|
|
+# GMOCK_LIBRARIES - libgmock
|
|
|
+# GMOCK_MAIN_LIBRARIES - libgmock-main
|
|
|
+#
|
|
|
+# Accepts the following variables as input:
|
|
|
+#
|
|
|
+# GMOCK_ROOT - (as a CMake or environment variable)
|
|
|
+# The root directory of the gmock install prefix
|
|
|
+#
|
|
|
+# GMOCK_MSVC_SEARCH - If compiling with MSVC, this variable can be set to
|
|
|
+# "MD" or "MT" to enable searching a gmock build tree
|
|
|
+# (defaults: "MD")
|
|
|
+#
|
|
|
+#-----------------------
|
|
|
+# Example Usage:
|
|
|
+#
|
|
|
+# find_package(GMock REQUIRED)
|
|
|
+# include_directories(${GMOCK_INCLUDE_DIRS})
|
|
|
+#
|
|
|
+# add_executable(foo foo.cc)
|
|
|
+# target_link_libraries(foo ${GMOCK_BOTH_LIBRARIES})
|
|
|
+#
|
|
|
#=============================================================================
|
|
|
-# Copyright 2011-2012 University of Pennsylvania
|
|
|
-# Copyright 2013-2016 Andreas Schuh <andreas.schuh.84@gmail.com>
|
|
|
+# This file is released under the MIT licence:
|
|
|
+#
|
|
|
+# Copyright (c) 2011 Matej Svec
|
|
|
#
|
|
|
-# Distributed under the OSI-approved BSD License (the "License");
|
|
|
-# see accompanying file Copyright.txt for details.
|
|
|
+# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
+# of this software and associated documentation files (the "Software"), to
|
|
|
+# deal in the Software without restriction, including without limitation the
|
|
|
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
+# sell copies of the Software, and to permit persons to whom the Software is
|
|
|
+# furnished to do so, subject to the following conditions:
|
|
|
#
|
|
|
-# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
-# See the License for more information.
|
|
|
+# The above copyright notice and this permission notice shall be included in
|
|
|
+# all copies or substantial portions of the Software.
|
|
|
+#
|
|
|
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
+# IN THE SOFTWARE.
|
|
|
#=============================================================================
|
|
|
-# (To distribute this file outside of CMake, substitute the full
|
|
|
-# License text for the above reference.)
|
|
|
-
|
|
|
-# ----------------------------------------------------------------------------
|
|
|
-# initialize search
|
|
|
-if (NOT GMock_DIR)
|
|
|
- if ($ENV{GMOCK_DIR})
|
|
|
- set (GMock_DIR "$ENV{GMOCK_DIR}" CACHE PATH "Installation prefix for Google Mock.")
|
|
|
- else ()
|
|
|
- set (GMock_DIR "$ENV{GMock_DIR}" CACHE PATH "Installation prefix for Google Mock.")
|
|
|
- endif ()
|
|
|
-endif ()
|
|
|
|
|
|
-set (GMock_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
|
|
|
|
|
-if (GMock_SHARED_LIBRARIES)
|
|
|
- if (WIN32)
|
|
|
- set (CMAKE_FIND_LIBRARY_SUFFIXES .dll)
|
|
|
- else ()
|
|
|
- set (CMAKE_FIND_LIBRARY_SUFFIXES .so)
|
|
|
+function(_gmock_append_debugs _endvar _library)
|
|
|
+ if(${_library} AND ${_library}_DEBUG)
|
|
|
+ set(_output optimized ${${_library}} debug ${${_library}_DEBUG})
|
|
|
+ else()
|
|
|
+ set(_output ${${_library}})
|
|
|
endif()
|
|
|
-else ()
|
|
|
- if (WIN32)
|
|
|
- set (CMAKE_FIND_LIBRARY_SUFFIXES .lib)
|
|
|
- else ()
|
|
|
- set (CMAKE_FIND_LIBRARY_SUFFIXES .a)
|
|
|
- endif()
|
|
|
-endif ()
|
|
|
-
|
|
|
-# ----------------------------------------------------------------------------
|
|
|
-# find paths/files
|
|
|
-if (GMock_DIR)
|
|
|
-
|
|
|
- find_path (
|
|
|
- GMock_INCLUDE_DIR
|
|
|
- NAMES gmock.h
|
|
|
- HINTS "${GMock_DIR}"
|
|
|
- PATH_SUFFIXES "include/gmock"
|
|
|
- DOC "Include directory for Google Mock."
|
|
|
- NO_DEFAULT_PATH
|
|
|
- )
|
|
|
-
|
|
|
- find_library (
|
|
|
- GMock_LIBRARY
|
|
|
- NAMES gmock
|
|
|
- HINTS "${GMock_DIR}"
|
|
|
- PATH_SUFFIXES "lib"
|
|
|
- DOC "Link library for Google Mock (gmock)."
|
|
|
- NO_DEFAULT_PATH
|
|
|
+ set(${_endvar} ${_output} PARENT_SCOPE)
|
|
|
+endfunction()
|
|
|
+
|
|
|
+function(_gmock_find_library _name)
|
|
|
+ find_library(${_name}
|
|
|
+ NAMES ${ARGN}
|
|
|
+ HINTS
|
|
|
+ $ENV{GMOCK_ROOT}
|
|
|
+ ${GMOCK_ROOT}
|
|
|
+ PATH_SUFFIXES ${_gmock_libpath_suffixes}
|
|
|
)
|
|
|
+ mark_as_advanced(${_name})
|
|
|
+endfunction()
|
|
|
+
|
|
|
+
|
|
|
+if(NOT DEFINED GMOCK_MSVC_SEARCH)
|
|
|
+ set(GMOCK_MSVC_SEARCH MD)
|
|
|
+endif()
|
|
|
+
|
|
|
+set(_gmock_libpath_suffixes lib)
|
|
|
+if(MSVC)
|
|
|
+ if(GMOCK_MSVC_SEARCH STREQUAL "MD")
|
|
|
+ list(APPEND _gmock_libpath_suffixes
|
|
|
+ msvc/gmock-md/Debug
|
|
|
+ msvc/gmock-md/Release)
|
|
|
+ elseif(GMOCK_MSVC_SEARCH STREQUAL "MT")
|
|
|
+ list(APPEND _gmock_libpath_suffixes
|
|
|
+ msvc/gmock/Debug
|
|
|
+ msvc/gmock/Release)
|
|
|
+ endif()
|
|
|
+endif()
|
|
|
|
|
|
-else ()
|
|
|
-
|
|
|
- find_path (
|
|
|
- GMock_INCLUDE_DIR
|
|
|
- NAMES gmock.h
|
|
|
- HINTS ENV C_INCLUDE_PATH ENV CXX_INCLUDE_PATH
|
|
|
- DOC "Include directory for Google Mock."
|
|
|
- )
|
|
|
-
|
|
|
- find_library (
|
|
|
- GMock_LIBRARY
|
|
|
- NAMES gmock
|
|
|
- HINTS ENV LD_LIBRARY_PATH
|
|
|
- DOC "Link library for Google Mock (gmock)."
|
|
|
- )
|
|
|
-
|
|
|
-endif ()
|
|
|
-
|
|
|
-mark_as_advanced (GMock_INCLUDE_DIR)
|
|
|
-mark_as_advanced (GMock_LIBRARY)
|
|
|
-
|
|
|
-# ----------------------------------------------------------------------------
|
|
|
-# prerequisite libraries
|
|
|
-set (GMock_INCLUDES "${GMock_INCLUDE_DIR}")
|
|
|
-set (GMock_LIBRARIES "${GMock_LIBRARY}")
|
|
|
-
|
|
|
-# ----------------------------------------------------------------------------
|
|
|
-# reset CMake variables
|
|
|
-set (CMAKE_FIND_LIBRARY_SUFFIXES ${GTest_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
|
|
|
-
|
|
|
-# ----------------------------------------------------------------------------
|
|
|
-# aliases / backwards compatibility
|
|
|
-set (GMock_INCLUDE_DIRS "${GTest_INCLUDES}")
|
|
|
-
|
|
|
-# ----------------------------------------------------------------------------
|
|
|
-# handle the QUIETLY and REQUIRED arguments and set *_FOUND to TRUE
|
|
|
-# if all listed variables are found or TRUE
|
|
|
-include (FindPackageHandleStandardArgs)
|
|
|
-
|
|
|
-find_package_handle_standard_args (
|
|
|
- GMock
|
|
|
- REQUIRED_VARS
|
|
|
- GMock_INCLUDE_DIR
|
|
|
- GMock_LIBRARY
|
|
|
+find_path(GMOCK_INCLUDE_DIR gmock/gmock.h
|
|
|
+ HINTS
|
|
|
+ $ENV{GMOCK_ROOT}/include
|
|
|
+ ${GMOCK_ROOT}/include
|
|
|
)
|
|
|
-
|
|
|
-set (GMock_FOUND "${GMOCK_FOUND}")
|
|
|
-
|
|
|
-# ----------------------------------------------------------------------------
|
|
|
-# set GMock_DIR
|
|
|
-if (NOT GMock_DIR AND GMock_FOUND)
|
|
|
- string (REGEX REPLACE "include(/gmock)?/?" "" GMock_PREFIX "${GMock_INCLUDE_DIR}")
|
|
|
- set (GMock_DIR "${GMock_PREFIX}" CACHE PATH "Installation prefix for GMock." FORCE)
|
|
|
- unset (GMock_PREFIX)
|
|
|
-endif ()
|
|
|
+mark_as_advanced(GMOCK_INCLUDE_DIR)
|
|
|
+
|
|
|
+if(MSVC AND GMOCK_MSVC_SEARCH STREQUAL "MD")
|
|
|
+ # The provided /MD project files for Google Mock add -md suffixes to the
|
|
|
+ # library names.
|
|
|
+ _gmock_find_library(GMOCK_LIBRARY gmock-md gmock)
|
|
|
+ _gmock_find_library(GMOCK_LIBRARY_DEBUG gmock-mdd gmockd)
|
|
|
+ _gmock_find_library(GMOCK_MAIN_LIBRARY gmock_main-md gmock_main)
|
|
|
+ _gmock_find_library(GMOCK_MAIN_LIBRARY_DEBUG gmock_main-mdd gmock_maind)
|
|
|
+else()
|
|
|
+ _gmock_find_library(GMOCK_LIBRARY gmock)
|
|
|
+ _gmock_find_library(GMOCK_LIBRARY_DEBUG gmockd)
|
|
|
+ _gmock_find_library(GMOCK_MAIN_LIBRARY gmock_main)
|
|
|
+ _gmock_find_library(GMOCK_MAIN_LIBRARY_DEBUG gmock_maind)
|
|
|
+endif()
|
|
|
+
|
|
|
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMock DEFAULT_MSG GMOCK_LIBRARY GMOCK_INCLUDE_DIR GMOCK_MAIN_LIBRARY)
|
|
|
+
|
|
|
+if(GMOCK_FOUND)
|
|
|
+ set(GMOCK_INCLUDE_DIRS ${GMOCK_INCLUDE_DIR})
|
|
|
+ _gmock_append_debugs(GMOCK_LIBRARIES GMOCK_LIBRARY)
|
|
|
+ _gmock_append_debugs(GMOCK_MAIN_LIBRARIES GMOCK_MAIN_LIBRARY)
|
|
|
+ set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARIES} ${GMOCK_MAIN_LIBRARIES})
|
|
|
+endif()
|
|
|
|