download googletest automatically (#6697)

and a small fix for finding QT5 installed via brew on OSX
This commit is contained in:
Raphael Coeffic
2019-09-02 14:36:13 +02:00
committed by Bertrand Songis
parent e91a464352
commit d399a75bf6
3 changed files with 35 additions and 6 deletions
+35
View File
@@ -79,6 +79,14 @@ endif()
option(DISABLE_COMPANION "Disable building companion and simulators" OFF)
if(NOT DISABLE_COMPANION) # FIXME cosmetics/style
if(APPLE AND EXISTS /usr/local/opt/qt5)
# Homebrew installs Qt5 (up to at least 5.9.1) in
# /usr/local/qt5, ensure it can be found by CMake since
# it is not in the default /usr/local prefix.
list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt5")
endif()
find_package(Qt5Core)
find_package(Qt5Widgets)
find_package(Qt5Xml)
@@ -189,6 +197,33 @@ if(WIN32)
endif()
endif()
set(GTEST_ROOT /usr CACHE STRING "Base path to Google Test headers and source.")
find_path(GTEST_INCDIR gtest/gtest.h HINTS "${GTEST_ROOT}/include" DOC "Path to Google Test header files folder ('gtest/gtest.h').")
find_path(GTEST_SRCDIR src/gtest-all.cc HINTS "${GTEST_ROOT}" "${GTEST_ROOT}/src/gtest" DOC "Path of Google Test 'src' folder.")
if(NOT GTEST_INCDIR OR NOT GTEST_SRCDIR)
message(STATUS "Googletest will be downloaded")
set(GTEST_VERSION 1.8.1)
set(GTEST_SRCDIR "${RADIO_SRC_DIRECTORY}/tests/googletest-release-${GTEST_VERSION}/googletest")
set(GTEST_INCDIR "${GTEST_SRCDIR}/include")
set(GTEST_URL "https://github.com/google/googletest/archive/release-${GTEST_VERSION}.tar.gz")
set(GTEST_ARCHIVE "${RADIO_SRC_DIRECTORY}/tests/gtest-${GTEST_VERSION}.tar.gz")
if (NOT EXISTS "${GTEST_ARCHIVE}")
file(DOWNLOAD "${GTEST_URL}" ${GTEST_ARCHIVE} SHOW_PROGRESS)
endif()
if (NOT EXISTS "${GTEST_SRCDIR}")
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar -xf ${GTEST_ARCHIVE}
WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY}/tests)
endif()
endif()
add_subdirectory(${RADIO_SRC_DIRECTORY})
if(Qt5Core_FOUND AND NOT DISABLE_COMPANION)
-3
View File
@@ -1,7 +1,4 @@
set(GTEST_ROOT /usr CACHE STRING "Base path to Google Test headers and source.")
find_path(GTEST_INCDIR gtest/gtest.h HINTS "${GTEST_ROOT}/include" DOC "Path to Google Test header files folder ('gtest/gtest.h').")
find_path(GTEST_SRCDIR src/gtest-all.cc HINTS "${GTEST_ROOT}" "${GTEST_ROOT}/src/gtest" DOC "Path of Google Test 'src' folder.")
if(GTEST_INCDIR AND GTEST_SRCDIR AND Qt5Widgets_FOUND)
add_library(gtests-companion-lib STATIC EXCLUDE_FROM_ALL ${GTEST_SRCDIR}/src/gtest-all.cc )
-3
View File
@@ -1,7 +1,4 @@
set(GTEST_ROOT /usr CACHE STRING "Base path to Google Test headers and source.")
find_path(GTEST_INCDIR gtest/gtest.h HINTS "${GTEST_ROOT}/include" DOC "Path to Google Test header files folder ('gtest/gtest.h').")
find_path(GTEST_SRCDIR src/gtest-all.cc HINTS "${GTEST_ROOT}" "${GTEST_ROOT}/src/gtest" DOC "Path of Google Test 'src' folder.")
if(GTEST_INCDIR AND GTEST_SRCDIR AND Qt5Widgets_FOUND)
add_library(gtests-radio-lib STATIC EXCLUDE_FROM_ALL ${GTEST_SRCDIR}/src/gtest-all.cc )