forked from apache/orc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindGTest.cmake
92 lines (79 loc) · 2.89 KB
/
FindGTest.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# GTEST_HOME environmental variable is used to check for GTest headers and static library
# GTEST_INCLUDE_DIR: directory containing headers
# GMOCK_LIBRARY: path to libgmock
# GTEST_LIBRARY: path to libgtest
# GMOCK_STATIC_LIB: is set to gmock.a static library
# GTEST_STATIC_LIB: is set to gtest.a static library
# GTEST_FOUND is set if GTEST is found
if (NOT "${GTEST_HOME}" STREQUAL "")
message (STATUS "GTEST_HOME set: ${GTEST_HOME}")
endif ()
file (TO_CMAKE_PATH "${GTEST_HOME}" _gtest_path )
find_path (GTEST_INCLUDE_DIR gmock/gmock.h HINTS
${_gtest_path}
NO_DEFAULT_PATH
PATH_SUFFIXES "include")
find_library (GMOCK_LIBRARY NAMES gmock HINTS
${_gtest_path}
PATH_SUFFIXES "lib")
find_library (GTEST_LIBRARY NAMES gtest HINTS
${_gtest_path}
PATH_SUFFIXES "lib")
find_library (GMOCK_STATIC_LIB NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX} HINTS
${_gtest_path}
PATH_SUFFIXES "lib")
find_library (GTEST_STATIC_LIB NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} HINTS
${_gtest_path}
PATH_SUFFIXES "lib")
if (GTEST_INCLUDE_DIR AND GMOCK_LIBRARY)
set (GTEST_FOUND TRUE)
set (GTEST_HEADER_NAME gmock/gmock.h)
set (GTEST_HEADER ${GTEST_INCLUDE_DIR}/${GTEST_HEADER_NAME})
else ()
set (GTEST_FOUND FALSE)
endif ()
if (GTEST_FOUND)
message (STATUS "Found the GTest header: ${GTEST_HEADER}")
message (STATUS "Found the GTest library: ${GTEST_LIBRARY}")
message (STATUS "Found the GMock library: ${GMOCK_LIBRARY}")
if (GTEST_STATIC_LIB)
message (STATUS "Found the GTest static library: ${GTEST_STATIC_LIB}")
endif ()
if (GMOCK_STATIC_LIB)
message (STATUS "Found the GMock static library: ${GMOCK_STATIC_LIB}")
endif ()
else ()
if (_gtest_path)
set (GTEST_ERR_MSG "Could not find GTest. Looked in ${_gtest_path}.")
else ()
set (GTEST_ERR_MSG "Could not find GTest in system search paths.")
endif()
if (GTest_FIND_REQUIRED)
message (FATAL_ERROR "${GTEST_ERR_MSG}")
else ()
message (STATUS "${GTEST_ERR_MSG}")
endif ()
endif ()
mark_as_advanced (
GTEST_INCLUDE_DIR
GMOCK_STATIC_LIB
GTEST_STATIC_LIB
GMOCK_LIBRARY
GTEST_LIBRARY
)