aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorKarl Schultz <karl@lunarg.com>2018-06-22 15:14:33 -0600
committerKarl Schultz <karl@lunarg.com>2018-06-25 09:02:15 -0600
commita80ef66cbafc7520e2864559b0390d2e4ae5a015 (patch)
tree2d5182978cec094bde47c971c11839e9ff3bb7ad /external
parent93c774e110307f3878b0469ff8b136412622183c (diff)
downloadvulkan-validation-layers-a80ef66cbafc7520e2864559b0390d2e4ae5a015.tar.gz
build: Improve googletest handling
Behavior is largely unchanged except that specifying BUILD_TESTS=ON with googletest not present no longer quietly skips building the tests. - Make inclusion of external directory unconditional. We may someday put something there is not related to testing. - Make default for BUILD_TEST dependent on googletest presence. - Remove if() around entire contents of tests CMake file. - Add CMake messaging to clarify googletest activity. - Throw a CMake error if googletest not present and BUILD_TESTS=ON
Diffstat (limited to 'external')
-rw-r--r--external/CMakeLists.txt39
1 files changed, 23 insertions, 16 deletions
diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
index d0fc32afa..91cfe7e0f 100644
--- a/external/CMakeLists.txt
+++ b/external/CMakeLists.txt
@@ -1,19 +1,26 @@
-# googletest is an external dependency for the tests in the ValidationLayers
-# repo. Check for its presence before trying to build tests.
+if(BUILD_TESTS)
+ # googletest is an external dependency for the tests in the ValidationLayers
+ # repo. Add googletest to the project if present and not already defined.
-# Suppress all warnings from external projects.
-set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -w)
+ # Suppress all warnings from external projects.
+ set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -w)
-if(TARGET gtest_main)
- message(STATUS "Google Test (googletest) already configured - use it")
-elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
- SET(BUILD_GTEST ON CACHE BOOL "Builds the googletest subproject")
- SET(BUILD_GMOCK OFF CACHE BOOL "Builds the googlemock subproject")
- SET(gtest_force_shared_crt ON CACHE BOOL "Link gtest runtimes dynamically")
- SET(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")
- # EXCLUDE_FROM_ALL keeps the install target from installing GTEST files.
- add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/googletest EXCLUDE_FROM_ALL)
-else()
- message(STATUS
- "Google Test was not found - tests based on that will not build")
+ if(TARGET gtest_main)
+ # It is possible that a project enclosing this one has defined the gtest target
+ message(STATUS "Vulkan-ValidationLayers/external: "
+ "Google Test (googletest) already configured - use it")
+ elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
+ message(STATUS "Vulkan-ValidationLayers/external: "
+ "googletests found - configuring it for tests")
+ SET(BUILD_GTEST ON CACHE BOOL "Builds the googletest subproject")
+ SET(BUILD_GMOCK OFF CACHE BOOL "Builds the googlemock subproject")
+ SET(gtest_force_shared_crt ON CACHE BOOL "Link gtest runtimes dynamically")
+ SET(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")
+ # EXCLUDE_FROM_ALL keeps the install target from installing GTEST files.
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/googletest EXCLUDE_FROM_ALL)
+ else()
+ message(SEND_ERROR
+ "Vulkan-ValidationLayers/external: Google Test was not found. "
+ "Provide Google Test in external/googletest or set BUILD_TESTS=OFF")
+ endif()
endif()