Skip to content

Commit

Permalink
Remove gtest source code from DART codebase (#1205)
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 authored Dec 19, 2018
1 parent d65d237 commit 0b5b6dd
Show file tree
Hide file tree
Showing 40 changed files with 112 additions and 31,439 deletions.
3 changes: 2 additions & 1 deletion .ci/install_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ $SUDO apt-get -y install \
build-essential \
cmake \
pkg-config \
curl
curl \
git
if [ $COMPILER = clang ]; then
$SUDO apt-get -qq -y install clang
fi
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@

* Reorganized OpenGL and GLUT files: [#1088](https://github.com/dartsim/dart/pull/1088)

* Misc

* Remove gtest source code from DART codebase: [#1205](https://github.com/dartsim/dart/pull/1205)

### [DART 6.6.2 (2018-09-03)](https://github.com/dartsim/dart/milestone/47?closed=1)

* Utils
Expand Down
89 changes: 89 additions & 0 deletions cmake/GoogleTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Copyright (c) 2011-2018, The DART development contributors
# All rights reserved.
#
# The list of contributors can be found at:
# https://github.com/dartsim/dart/blob/master/LICENSE
#
# This file is provided under the "BSD-style" License
#
# This sets the following variables:
# - GTEST_INCLUDE_DIRS
# - GTEST_LIBRARY
# - GTEST_MAIN_LIBRARY
# - GMOCK_INCLUDE_DIRS
# - GMOCK_LIBRARY
# - GMOCK_MAIN_LIBRARY

find_package(Threads REQUIRED)

include(ExternalProject)

if (NOT TARGET googletest)
ExternalProject_Add(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.8.1
UPDATE_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
)
endif()

ExternalProject_Get_Property(googletest source_dir)
set(GTEST_INCLUDE_DIRS ${source_dir}/googletest/include)
set(GMOCK_INCLUDE_DIRS ${source_dir}/googlemock/include)

ExternalProject_Get_Property(googletest binary_dir)
set(GTEST_LIBRARY_PATH ${binary_dir}/googlemock/gtest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a)
set(GTEST_LIBRARY gtest)
add_library(${GTEST_LIBRARY} UNKNOWN IMPORTED)
set_target_properties(${GTEST_LIBRARY} PROPERTIES
IMPORTED_LOCATION ${GTEST_LIBRARY_PATH}
)
if(CMAKE_THREAD_LIBS_INIT)
set_target_properties(${GTEST_LIBRARY} PROPERTIES
IMPORTED_LINK_INTERFACE_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}
)
endif()
add_dependencies(${GTEST_LIBRARY} googletest)

set(GTEST_MAIN_LIBRARY_PATH ${binary_dir}/googlemock/gtest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a)
set(GTEST_MAIN_LIBRARY gtest_main)
add_library(${GTEST_MAIN_LIBRARY} UNKNOWN IMPORTED)
set_target_properties(${GTEST_MAIN_LIBRARY} PROPERTIES
IMPORTED_LOCATION ${GTEST_MAIN_LIBRARY_PATH}
)
if(CMAKE_THREAD_LIBS_INIT)
set_target_properties(${GTEST_MAIN_LIBRARY} PROPERTIES
IMPORTED_LINK_INTERFACE_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}
)
endif()
add_dependencies(${GTEST_MAIN_LIBRARY} googletest)

set(GMOCK_LIBRARY_PATH ${binary_dir}/googlemock/${CMAKE_FIND_LIBRARY_PREFIXES}gmock.a)
set(GMOCK_LIBRARY gmock)
add_library(${GMOCK_LIBRARY} UNKNOWN IMPORTED)
set_target_properties(${GMOCK_LIBRARY} PROPERTIES
IMPORTED_LOCATION ${GMOCK_LIBRARY_PATH}
)
if(CMAKE_THREAD_LIBS_INIT)
set_target_properties(${GMOCK_LIBRARY} PROPERTIES
IMPORTED_LINK_INTERFACE_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}
)
endif()
add_dependencies(${GMOCK_LIBRARY} googletest)

set(GMOCK_MAIN_LIBRARY_PATH ${binary_dir}/googlemock/${CMAKE_FIND_LIBRARY_PREFIXES}gmock_main.a)
set(GMOCK_MAIN_LIBRARY gmock_main)
add_library(${GMOCK_MAIN_LIBRARY} UNKNOWN IMPORTED)
set_target_properties(${GMOCK_MAIN_LIBRARY} PROPERTIES
IMPORTED_LOCATION ${GMOCK_MAIN_LIBRARY_PATH}
)
if(CMAKE_THREAD_LIBS_INIT)
set_target_properties(${GMOCK_MAIN_LIBRARY} PROPERTIES
IMPORTED_LINK_INTERFACE_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}
)
endif()
add_dependencies(${GMOCK_MAIN_LIBRARY} ${GTEST_LIBRARY})
5 changes: 3 additions & 2 deletions extras/dartc/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include_directories(BEFORE SYSTEM ${CMAKE_SOURCE_DIR}/unittests/gtest/include)
include_directories(BEFORE SYSTEM ${CMAKE_SOURCE_DIR}/unittests/gtest)
include(GoogleTest)

include_directories(BEFORE SYSTEM ${GTEST_INCLUDE_DIRS})

function(dartc_add_test test_type target_name) # ARGN for source files

Expand Down
34 changes: 14 additions & 20 deletions unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,8 @@
#

# GoogleTest setup
include_directories(BEFORE SYSTEM ${CMAKE_SOURCE_DIR}/unittests/gtest/include)
include_directories(BEFORE SYSTEM ${CMAKE_SOURCE_DIR}/unittests/gtest)
add_library(gtest STATIC gtest/src/gtest-all.cc)
add_library(gtest_main STATIC gtest/src/gtest_main.cc)
target_link_libraries(gtest_main gtest)
if(NOT WIN32)
target_link_libraries(gtest pthread)
endif()
set_target_properties(
gtest PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
)
include(GoogleTest)
include_directories(BEFORE SYSTEM ${GTEST_INCLUDE_DIRS})

#===============================================================================
# This function uses following global properties:
Expand All @@ -69,12 +59,16 @@ function(dart_add_test test_type target_name) # ARGN for source files

if(MSVC)
target_link_libraries(${target_name}
dart
optimized gtest debug gtestd
optimized gtest_main debug gtest_maind
optimized ${GTEST_MAIN_LIBRARY}
debug ${GTEST_MAIN_LIBRARY}${CMAKE_DEBUG_POSTFIX}
optimized ${GTEST_LIBRARY}
debug ${GTEST_LIBRARY}${CMAKE_DEBUG_POSTFIX}
dart
)
else()
target_link_libraries(${target_name} dart gtest gtest_main)
target_link_libraries(${target_name}
${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} dart
)
endif()

endfunction()
Expand Down Expand Up @@ -130,10 +124,10 @@ else()
"${comprehensive_tests_len} + ${regression_tests_len} + ${unit_tests_len}"
)
message(STATUS "Adding ${tests_len} tests ("
"comprehensive: ${comprehensive_tests_len}, "
"regression: ${regression_tests_len}, "
"unit: ${unit_tests_len}"
")"
"comprehensive: ${comprehensive_tests_len}, "
"regression: ${regression_tests_len}, "
"unit: ${unit_tests_len}"
")"
)
endif()

Expand Down
Loading

0 comments on commit 0b5b6dd

Please sign in to comment.