Commit 25c20bb7 authored by Alexis Girault's avatar Alexis Girault

ENH: Add Google Test as external project

parent 5df7a058
#-----------------------------------------------------------------------------
# Add External Project
#-----------------------------------------------------------------------------
include(imstkAddExternalProject)
imstk_add_external_project( GoogleTest
GIT_REPOSITORY git@github.com:google/googletest.git
GIT_TAG release-1.8.0
INSTALL_COMMAND ${SKIP_STEP_COMMAND}
CMAKE_ARGS
-DBUILD_GMOCK:BOOL=ON
-DBUILD_GTEST:BOOL=ON
-DBUILD_SHARED_LIBS:BOOL=ON
DEPENDENCIES ""
RELATIVE_INCLUDE_PATH ""
#VERBOSE
)
#-----------------------------------------------------------------------------
# Find path
#-----------------------------------------------------------------------------
find_path(GoogleMock_INCLUDE_DIR
NAMES
gmock/gmock.h
PATH_SUFFIXES
googlemock/include
)
mark_as_advanced(GoogleMock_INCLUDE_DIR)
list(APPEND GoogleMock_INCLUDE_DIRS ${GoogleMock_INCLUDE_DIR})
#-----------------------------------------------------------------------------
# Find library
#-----------------------------------------------------------------------------
find_library(GoogleMock_LIBRARY
NAMES
libgmock
gmock
)
mark_as_advanced(GoogleMock_LIBRARY)
list(APPEND GoogleMock_LIBRARIES ${GoogleMock_LIBRARY})
find_library(GoogleMock_main_LIBRARY
NAMES
libgmock_main
gmock_main
)
mark_as_advanced(GoogleMock_main_LIBRARY)
list(APPEND GoogleMock_LIBRARIES ${GoogleMock_main_LIBRARY})
#-----------------------------------------------------------------------------
# Find package
#-----------------------------------------------------------------------------
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GoogleMock
REQUIRED_VARS
GoogleMock_INCLUDE_DIRS
GoogleMock_LIBRARIES)
#-----------------------------------------------------------------------------
# If missing target, create it
#-----------------------------------------------------------------------------
if(GoogleMock_FOUND AND NOT TARGET GoogleMock)
add_library(GoogleMock INTERFACE IMPORTED)
set_target_properties(GoogleMock PROPERTIES
INTERFACE_LINK_LIBRARIES "${GoogleMock_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${GoogleMock_INCLUDE_DIR}"
)
endif()
#-----------------------------------------------------------------------------
# Find path
#-----------------------------------------------------------------------------
find_path(GoogleTest_INCLUDE_DIR
NAMES
gtest/gtest.h
PATH_SUFFIXES
googletest/include
)
mark_as_advanced(GoogleTest_INCLUDE_DIR)
list(APPEND GoogleTest_INCLUDE_DIRS ${GoogleTest_INCLUDE_DIR})
#-----------------------------------------------------------------------------
# Find library
#-----------------------------------------------------------------------------
find_library(GoogleTest_LIBRARY
NAMES
libgtest
gtest
)
mark_as_advanced(GoogleTest_LIBRARY)
list(APPEND GoogleTest_LIBRARIES ${GoogleTest_LIBRARY})
find_library(GoogleTest_main_LIBRARY
NAMES
libgtest_main
gtest_main
)
mark_as_advanced(GoogleTest_main_LIBRARY)
list(APPEND GoogleTest_LIBRARIES ${GoogleTest_main_LIBRARY})
#-----------------------------------------------------------------------------
# Find package
#-----------------------------------------------------------------------------
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GoogleTest
REQUIRED_VARS
GoogleTest_INCLUDE_DIRS
GoogleTest_LIBRARIES)
#-----------------------------------------------------------------------------
# If missing target, create it
#-----------------------------------------------------------------------------
if(GoogleTest_FOUND AND NOT TARGET GoogleTest)
add_library(GoogleTest INTERFACE IMPORTED)
set_target_properties(GoogleTest PROPERTIES
INTERFACE_LINK_LIBRARIES "${GoogleTest_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${GoogleTest_INCLUDE_DIR}"
)
endif()
......@@ -90,6 +90,10 @@ imstk_define_dependency(VTK)
imstk_define_dependency(VRPN)
imstk_define_dependency(LibNiFalcon)
if(BUILD_TESTING)
imstk_define_dependency(GoogleTest)
endif()
#-----------------------------------------------------------------------------
# SUPERBUILD
#-----------------------------------------------------------------------------
......@@ -145,6 +149,14 @@ else()
remove_definitions( -DVRPN_USE_PHANTOM_SERVER )
endif()
# Google Test
if(BUILD_TESTING)
find_package( GoogleTest REQUIRED )
include_directories(${GoogleTest_INCLUDE_DIRS})
find_package( GoogleMock REQUIRED )
include_directories(${GoogleMock_INCLUDE_DIRS})
endif()
#--------------------------------------------------------------------------
# Add Source code subdirectories
#--------------------------------------------------------------------------
......@@ -160,6 +172,7 @@ add_subdirectory(Base/Collision)
add_subdirectory(Base/Scene)
add_subdirectory(Base/SimulationManager)
add_subdirectory(Base/Constraint)
#--------------------------------------------------------------------------
# Export Targets
#--------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment