2014-09-07 23:52:03 +00:00
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
include(ExternalProject)
|
|
|
|
|
|
|
|
if(MSYS OR MINGW)
|
2015-05-19 03:44:54 +00:00
|
|
|
set(DISABLE_PTHREADS ON)
|
2014-09-07 23:52:03 +00:00
|
|
|
else()
|
2015-05-19 03:44:54 +00:00
|
|
|
set(DISABLE_PTHREADS OFF)
|
2014-09-07 23:52:03 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (MSVC)
|
2015-05-19 03:44:54 +00:00
|
|
|
set(RELEASE_LIB_DIR ReleaseLibs)
|
|
|
|
set(DEBUG_LIB_DIR DebugLibs)
|
2015-12-26 23:07:37 +00:00
|
|
|
elseif(XCODE_VERSION)
|
|
|
|
set(RELEASE_LIB_DIR Release)
|
|
|
|
set(DEBUG_LIB_DIR Debug)
|
2015-12-26 23:15:14 +00:00
|
|
|
else()
|
2015-05-19 03:44:54 +00:00
|
|
|
set(RELEASE_LIB_DIR "")
|
|
|
|
set(DEBUG_LIB_DIR "")
|
2014-09-07 23:52:03 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(GTEST_CMAKE_ARGS
|
2015-05-19 03:44:54 +00:00
|
|
|
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
|
|
|
|
"-Dgtest_force_shared_crt=ON"
|
|
|
|
"-Dgtest_disable_pthreads:BOOL=${DISABLE_PTHREADS}")
|
2014-09-07 23:52:03 +00:00
|
|
|
set(GTEST_RELEASE_LIB_DIR "")
|
|
|
|
set(GTEST_DEBUGLIB_DIR "")
|
|
|
|
if (MSVC)
|
2015-05-19 03:44:54 +00:00
|
|
|
set(GTEST_CMAKE_ARGS ${GTEST_CMAKE_ARGS}
|
|
|
|
"-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=${DEBUG_LIB_DIR}"
|
|
|
|
"-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=${RELEASE_LIB_DIR}")
|
|
|
|
set(GTEST_LIB_DIR)
|
2014-09-07 23:52:03 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(GTEST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gtest")
|
|
|
|
|
2015-05-31 12:14:16 +00:00
|
|
|
# try to find git - if found, setup gtest
|
|
|
|
find_package(Git)
|
|
|
|
if(NOT GIT_FOUND)
|
2015-05-19 03:44:54 +00:00
|
|
|
set(AddGTest_FOUND false CACHE BOOL "Was gtest setup correctly?")
|
2015-05-31 12:14:16 +00:00
|
|
|
else(NOT GIT_FOUND)
|
2015-05-19 03:44:54 +00:00
|
|
|
set(AddGTest_FOUND true CACHE BOOL "Was gtest setup correctly?")
|
2014-09-07 23:52:03 +00:00
|
|
|
|
2015-05-19 03:44:54 +00:00
|
|
|
ExternalProject_Add(gtest
|
|
|
|
GIT_REPOSITORY https://chromium.googlesource.com/external/googletest
|
|
|
|
TIMEOUT 10
|
|
|
|
PREFIX "${GTEST_PREFIX}"
|
|
|
|
CMAKE_ARGS "${GTEST_CMAKE_ARGS}"
|
|
|
|
LOG_DOWNLOAD ON
|
|
|
|
LOG_CONFIGURE ON
|
|
|
|
LOG_BUILD ON
|
|
|
|
# Disable install
|
|
|
|
INSTALL_COMMAND ""
|
|
|
|
)
|
2014-09-07 23:52:03 +00:00
|
|
|
|
2015-05-19 03:44:54 +00:00
|
|
|
set(LIB_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}")
|
|
|
|
set(LIB_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
|
|
|
set(GTEST_LOCATION "${GTEST_PREFIX}/src/gtest-build")
|
|
|
|
set(GTEST_DEBUG_LIBRARIES
|
|
|
|
"${GTEST_LOCATION}/${DEBUG_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}"
|
|
|
|
"${CMAKE_THREAD_LIBS_INIT}")
|
|
|
|
SET(GTEST_RELEASE_LIBRARIES
|
|
|
|
"${GTEST_LOCATION}/${RELEASE_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}"
|
|
|
|
"${CMAKE_THREAD_LIBS_INIT}")
|
2014-09-07 23:52:03 +00:00
|
|
|
|
2015-05-19 03:44:54 +00:00
|
|
|
if(MSVC_VERSION EQUAL 1700)
|
|
|
|
add_definitions(-D_VARIADIC_MAX=10)
|
|
|
|
endif()
|
2014-09-07 23:52:03 +00:00
|
|
|
|
2015-05-19 03:44:54 +00:00
|
|
|
ExternalProject_Get_Property(gtest source_dir)
|
|
|
|
include_directories(${source_dir}/include)
|
|
|
|
include_directories(${source_dir}/gtest/include)
|
|
|
|
|
|
|
|
ExternalProject_Get_Property(gtest binary_dir)
|
|
|
|
link_directories(${binary_dir})
|
2015-05-31 12:14:16 +00:00
|
|
|
endif(NOT GIT_FOUND)
|