Skip to content

Commit b2ef8a4

Browse files
committed
change gmock/gtest source to github
1 parent d855fcd commit b2ef8a4

File tree

2 files changed

+95
-48
lines changed

2 files changed

+95
-48
lines changed

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ if(NOT CUKE_DISABLE_GTEST)
8484
set(GMOCK_ROOT "${CMAKE_CURRENT_BINARY_DIR}/gmock")
8585
find_package(GMock REQUIRED)
8686

87-
if(GMOCK_FOUND)
87+
if(GTEST_FOUND)
8888
set(CUKE_GTEST_LIBRARIES
8989
${GTEST_BOTH_LIBRARIES}
9090
${CMAKE_THREAD_LIBS_INIT}
9191
)
92+
endif()
93+
if(GMOCK_FOUND)
9294
set(CUKE_GMOCK_LIBRARIES
9395
${GTEST_BOTH_LIBRARIES}
9496
${GMOCK_BOTH_LIBRARIES}

cmake/modules/FindGMock.cmake

+92-47
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# GMOCK_FOUND - Got the Google Mocking framework
99
# GMOCK_INCLUDE_DIRS - GMock include directory
10-
# GTEST_INCLUDE_DIRS - GTest include direcotry
10+
# GTEST_INCLUDE_DIRS - GTest include direcotry
1111
#
1212
# Also defines the library variables below as normal variables
1313
#
@@ -45,23 +45,23 @@
4545
# Copyright 2000-2016 Kitware, Inc.
4646
# Copyright 2000-2011 Insight Software Consortium
4747
# All rights reserved.
48-
#
48+
#
4949
# Redistribution and use in source and binary forms, with or without
5050
# modification, are permitted provided that the following conditions
5151
# are met:
52-
#
52+
#
5353
# * Redistributions of source code must retain the above copyright
5454
# notice, this list of conditions and the following disclaimer.
55-
#
55+
#
5656
# * Redistributions in binary form must reproduce the above copyright
5757
# notice, this list of conditions and the following disclaimer in the
5858
# documentation and/or other materials provided with the distribution.
59-
#
59+
#
6060
# * Neither the names of Kitware, Inc., the Insight Software Consortium,
6161
# nor the names of their contributors may be used to endorse or promote
6262
# products derived from this software without specific prior written
6363
# permission.
64-
#
64+
#
6565
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6666
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6767
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -73,30 +73,30 @@
7373
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
7474
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
7575
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
76-
#
76+
#
7777
# ------------------------------------------------------------------------------
78-
#
78+
#
7979
# The above copyright and license notice applies to distributions of
8080
# CMake in source and binary form. Some source files contain additional
8181
# notices of original copyright by their contributors; see each source
8282
# for details. Third-party software packages supplied with CMake under
8383
# compatible licenses provide their own copyright notices documented in
8484
# corresponding subdirectories.
85-
#
85+
#
8686
# ------------------------------------------------------------------------------
87-
#
87+
#
8888
# CMake was initially developed by Kitware with the following sponsorship:
89-
#
89+
#
9090
# * National Library of Medicine at the National Institutes of Health
9191
# as part of the Insight Segmentation and Registration Toolkit (ITK).
92-
#
92+
#
9393
# * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
9494
# Visualization Initiative.
95-
#
95+
#
9696
# * National Alliance for Medical Image Computing (NAMIC) is funded by the
9797
# National Institutes of Health through the NIH Roadmap for Medical Research,
9898
# Grant U54 EB005149.
99-
#
99+
#
100100
# * Kitware, Inc.
101101
#=============================================================================
102102
# Thanks to Daniel Blezek <[email protected]> for the GTEST_ADD_TESTS code
@@ -148,21 +148,57 @@ else()
148148
set(GTEST_CMAKE_ARGS -DBUILD_SHARED_LIBS=ON)
149149
endif()
150150

151-
if("${GMOCK_SRC_DIR}" STREQUAL "")
152-
if("${GMOCK_VER}" STREQUAL "")
153-
set(GMOCK_VER "1.7.0")
154-
endif()
155-
message(STATUS "Downloading GMock / GTest version ${GMOCK_VER}")
156-
ExternalProject_Add(
157-
gmock
158-
URL "https://googlemock.googlecode.com/files/gmock-${GMOCK_VER}.zip"
159-
PREFIX ${GMOCK_ROOT}
160-
INSTALL_COMMAND ""
161-
LOG_DOWNLOAD ON
162-
LOG_CONFIGURE ON
163-
LOG_BUILD ON
164-
CMAKE_ARGS ${GTEST_CMAKE_ARGS}
165-
)
151+
if("${GMOCK_SRC_DIR}" STREQUAL "")
152+
if("${GMOCK_VER}" STREQUAL "1.8.0")
153+
set(GMOCK_VER "1.7.0")
154+
message("GMock ver 1.8 not supported -> switching to 1.7")
155+
#todo add 1.8 support from single repo of gtest
156+
endif()
157+
message(STATUS "Downloading GMock / GTest version ${GMOCK_VER}")
158+
ExternalProject_Add(
159+
gtest
160+
GIT_REPOSITORY "https://github.com/google/googletest.git"
161+
GIT_TAG "release-${GMOCK_VER}"
162+
PREFIX "${GMOCK_ROOT}"
163+
INSTALL_COMMAND ""
164+
LOG_DOWNLOAD ON
165+
LOG_CONFIGURE ON
166+
LOG_BUILD ON
167+
CMAKE_ARGS "${GTEST_CMAKE_ARGS}"
168+
)
169+
ExternalProject_Add(
170+
gmock
171+
GIT_REPOSITORY "https://github.com/google/googlemock.git"
172+
GIT_TAG "release-${GMOCK_VER}"
173+
PREFIX "${GMOCK_ROOT}"
174+
INSTALL_COMMAND ""
175+
LOG_DOWNLOAD ON
176+
LOG_CONFIGURE ON
177+
LOG_BUILD ON
178+
CMAKE_ARGS "${GTEST_CMAKE_ARGS}"
179+
)
180+
181+
add_library(libgtest IMPORTED STATIC GLOBAL)
182+
add_dependencies(libgtest gtest)
183+
add_library(libgmock IMPORTED STATIC GLOBAL)
184+
add_dependencies(libgmock gtest)
185+
add_dependencies(libgmock gmock)
186+
187+
ExternalProject_Get_Property(gtest source_dir binary_dir)
188+
set(GTEST_INCLUDE_DIR "${source_dir}/include")
189+
mark_as_advanced(GTEST_INCLUDE_DIR)
190+
set(GTEST_LIBRARY "${binary_dir}/${CMAKE_CFG_INTDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${Suffix}")
191+
mark_as_advanced(GTEST_LIBRARY)
192+
set(GTEST_MAIN_LIBRARY "${binary_dir}/${CMAKE_CFG_INTDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${Suffix}")
193+
mark_as_advanced(GTEST_MAIN_LIBRARY)
194+
ExternalProject_Get_Property(gmock source_dir binary_dir)
195+
set(GMOCK_INCLUDE_DIR "${gmock_source_dir}/include")
196+
mark_as_advanced(GMOCK_INCLUDE_DIR)
197+
set(GMOCK_LIBRARY "${binary_dir}/${CMAKE_CFG_INTDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gmock${Suffix}")
198+
mark_as_advanced(GMOCK_LIBRARY)
199+
set(GMOCK_MAIN_LIBRARY "${binary_dir}/${CMAKE_CFG_INTDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gmock_main${Suffix}")
200+
mark_as_advanced(GMOCK_MAIN_LIBRARY)
201+
166202
else()
167203
Message(STATUS "Building Gmock / Gtest from dir ${GMOCK_SRC_DIR}")
168204
ExternalProject_Add(
@@ -175,31 +211,39 @@ else()
175211
LOG_BUILD ON
176212
CMAKE_ARGS ${GTEST_CMAKE_ARGS}
177213
)
178-
endif()
179214

180-
add_library(libgmock IMPORTED STATIC GLOBAL)
181-
add_dependencies(libgmock gmock)
182-
ExternalProject_Get_Property(gmock source_dir binary_dir)
215+
add_library(libgtest IMPORTED STATIC GLOBAL)
216+
add_dependencies(libgtest gmock)
217+
add_library(libgmock IMPORTED STATIC GLOBAL)
218+
add_dependencies(libgmock gmock)
219+
220+
ExternalProject_Get_Property(gmock source_dir binary_dir)
221+
set(GTEST_INCLUDE_DIR "${source_dir}/gtest/include")
222+
mark_as_advanced(GTEST_INCLUDE_DIR)
223+
set(GTEST_LIBRARY "${binary_dir}/gtest/${CMAKE_CFG_INTDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${Suffix}")
224+
mark_as_advanced(GTEST_LIBRARY)
225+
set(GTEST_MAIN_LIBRARY "${binary_dir}/gtest/${CMAKE_CFG_INTDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${Suffix}")
226+
mark_as_advanced(GTEST_MAIN_LIBRARY)
227+
set(GMOCK_INCLUDE_DIR "${gmock_source_dir}/include")
228+
mark_as_advanced(GMOCK_INCLUDE_DIR)
229+
set(GMOCK_LIBRARY "${binary_dir}/${CMAKE_CFG_INTDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gmock${Suffix}")
230+
mark_as_advanced(GMOCK_LIBRARY)
231+
set(GMOCK_MAIN_LIBRARY "${binary_dir}/${CMAKE_CFG_INTDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gmock_main${Suffix}")
232+
mark_as_advanced(GMOCK_MAIN_LIBRARY)
233+
endif()
183234

184-
set(GTEST_LIB_DIR "${binary_dir}/gtest/${CMAKE_CFG_INTDIR}")
185-
set(GMOCK_LIB_DIR "${binary_dir}/${CMAKE_CFG_INTDIR}")
186235

236+
set_target_properties(libgtest PROPERTIES
237+
"IMPORTED_LOCATION" "${GTEST_LIBRARY}"
238+
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
239+
"INTERFACE_INCLUDE_DIRECTORIES" "${GTEST_INCLUDE_DIR}"
240+
)
187241
set_target_properties(libgmock PROPERTIES
188-
"IMPORTED_LOCATION" "${GMOCK_LIB_DIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gmock.${Suffix}"
242+
"IMPORTED_LOCATION" "${GMOCK_LIBARY}"
189243
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
190-
"INTERFACE_INCLUDE_DIRECTORIES" "${source_dir}/include"
244+
"INTERFACE_INCLUDE_DIRECTORIES" "${GMOCK_INCLUDE_DIR}"
191245
)
192246

193-
set(GMOCK_INCLUDE_DIR ${source_dir}/include)
194-
mark_as_advanced(GMOCK_INCLUDE_DIR)
195-
set(GTEST_INCLUDE_DIR ${source_dir}/gtest/include)
196-
mark_as_advanced(GTEST_INCLUDE_DIR)
197-
198-
set(GTEST_LIBRARY "${GTEST_LIB_DIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${Suffix}")
199-
set(GTEST_MAIN_LIBRARY "${GTEST_LIB_DIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${Suffix}")
200-
set(GMOCK_LIBRARY "${GMOCK_LIB_DIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gmock${Suffix}")
201-
set(GMOCK_MAIN_LIBRARY "${GMOCK_LIB_DIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gmock_main${Suffix}")
202-
203247
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMock DEFAULT_MSG GMOCK_LIBRARY GMOCK_INCLUDE_DIR GMOCK_MAIN_LIBRARY)
204248
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTest DEFAULT_MSG GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
205249

@@ -223,3 +267,4 @@ if(GTEST_FOUND)
223267
Message(STATUS "GTest libs: ${GTEST_BOTH_LIBRARIES}")
224268
endif()
225269
endif()
270+

0 commit comments

Comments
 (0)