diff options
author | Lenny Komow <lenny@lunarg.com> | 2018-06-06 15:40:13 -0600 |
---|---|---|
committer | Lenny Komow <lenny@lunarg.com> | 2018-06-06 15:40:13 -0600 |
commit | 77909b481f4cc1db66b587deadab5715942012a2 (patch) | |
tree | 1b35a3c6e45a83dbaf08e9b1069bc06e420e60da | |
parent | 0f3ba0365eff45262a5b49a5961fc9f9fe66c0c8 (diff) | |
download | Vulkan-Loader-77909b481f4cc1db66b587deadab5715942012a2.tar.gz Vulkan-Loader-77909b481f4cc1db66b587deadab5715942012a2.tar.bz2 Vulkan-Loader-77909b481f4cc1db66b587deadab5715942012a2.zip |
repo: Make tests not try to build without gtest
Change-Id: Idf3ed7bca713cb7ec1964513ac072344feaf17e6
-rw-r--r-- | external/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 224 |
2 files changed, 114 insertions, 112 deletions
diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 59af5d95..64f9be61 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -12,5 +12,5 @@ elseif(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/googletest") # 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 - test based on that will not build") + message(STATUS "Google Test was not found - tests based on that will not build") endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9e12943d..ec590895 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,138 +1,140 @@ cmake_minimum_required(VERSION 2.8.11) -if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN) - # Workaround for TR1 deprecation in Visual Studio 15.5 until Google Test is updated - add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) - set(DisplayServer Win32) -elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") - add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR) -elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") - if (BUILD_WSI_XCB_SUPPORT) - add_definitions(-DVK_USE_PLATFORM_XCB_KHR) - endif() - - if (BUILD_WSI_XLIB_SUPPORT) - add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) - endif() - - if (BUILD_WSI_WAYLAND_SUPPORT) - add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR) +if(TARGET gtest_main) + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN) + # Workaround for TR1 deprecation in Visual Studio 15.5 until Google Test is updated + add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) + set(DisplayServer Win32) + elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") + add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR) + elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + if (BUILD_WSI_XCB_SUPPORT) + add_definitions(-DVK_USE_PLATFORM_XCB_KHR) + endif() + + if (BUILD_WSI_XLIB_SUPPORT) + add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) + endif() + + if (BUILD_WSI_WAYLAND_SUPPORT) + add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR) + endif() + + if (BUILD_WSI_MIR_SUPPORT) + add_definitions(-DVK_USE_PLATFORM_MIR_KHR) + include_directories(${MIR_INCLUDE_DIR}) + endif() + elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + add_definitions(-DVK_USE_PLATFORM_MACOS_MVK) + else() + message(FATAL_ERROR "Unsupported Platform!") endif() - if (BUILD_WSI_MIR_SUPPORT) - add_definitions(-DVK_USE_PLATFORM_MIR_KHR) - include_directories(${MIR_INCLUDE_DIR}) + # On Windows, we must pair Debug and Release appropriately + if (WIN32) + # For Windows, since 32-bit and 64-bit items can co-exist, we build each in its own build directory. + # 32-bit target data goes in build32, and 64-bit target data goes into build. So, include/link the + # appropriate data at build time. + if (CMAKE_CL_64) + set (BUILDTGT_DIR build) + else () + set (BUILDTGT_DIR build32) + endif() endif() -elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - add_definitions(-DVK_USE_PLATFORM_MACOS_MVK) -else() - message(FATAL_ERROR "Unsupported Platform!") -endif() -# On Windows, we must pair Debug and Release appropriately -if (WIN32) - # For Windows, since 32-bit and 64-bit items can co-exist, we build each in its own build directory. - # 32-bit target data goes in build32, and 64-bit target data goes into build. So, include/link the - # appropriate data at build time. - if (CMAKE_CL_64) - set (BUILDTGT_DIR build) - else () - set (BUILDTGT_DIR build32) - endif() -endif() + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") + if(WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES") -if(WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES") + # If MSVC, disable some signed/unsigned mismatch warnings. + if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") + endif() - # If MSVC, disable some signed/unsigned mismatch warnings. - if (MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") endif() -else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -endif() - -set (LIBGLM_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/libs) + set (LIBGLM_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/libs) -include_directories( - ${PROJECT_SOURCE_DIR}/external - ${GTEST_SOURCE_DIR}/googletest/include - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} - ${PROJECT_BINARY_DIR} + include_directories( + ${PROJECT_SOURCE_DIR}/external + ${GTEST_SOURCE_DIR}/googletest/include + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${PROJECT_BINARY_DIR} ) -if (NOT WIN32) - # extra setup for out-of-tree builds - if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) - add_custom_target(binary-dir-symlinks ALL - COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_wrap_objects_tests.sh - COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_loader_tests.sh - COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_extra_loader_tests.sh - COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh - VERBATIM + if (NOT WIN32) + # extra setup for out-of-tree builds + if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) + add_custom_target(binary-dir-symlinks ALL + COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_wrap_objects_tests.sh + COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_loader_tests.sh + COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_extra_loader_tests.sh + COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh + VERBATIM ) - endif() -else() - if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) - FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_run_all_tests.ps1 RUN_ALL) - add_custom_target(binary-dir-symlinks ALL - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL} run_all_tests.ps1 - VERBATIM + endif() + else() + if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) + FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_run_all_tests.ps1 RUN_ALL) + add_custom_target(binary-dir-symlinks ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL} run_all_tests.ps1 + VERBATIM ) - set_target_properties(binary-dir-symlinks PROPERTIES FOLDER ${LVL_TARGET_FOLDER}) + set_target_properties(binary-dir-symlinks PROPERTIES FOLDER ${LVL_TARGET_FOLDER}) + endif() endif() -endif() -add_executable(vk_loader_validation_tests loader_validation_tests.cpp) -set_target_properties(vk_loader_validation_tests - PROPERTIES - COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") -if(NOT WIN32) + add_executable(vk_loader_validation_tests loader_validation_tests.cpp) set_target_properties(vk_loader_validation_tests PROPERTIES - COMPILE_FLAGS "-Wno-sign-compare") -endif() + COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") + if(NOT WIN32) + set_target_properties(vk_loader_validation_tests + PROPERTIES + COMPILE_FLAGS "-Wno-sign-compare") + endif() -if(TARGET vulkan) - set(LOADER_LIB vulkan) -elseif(WIN32 AND NOT $ENV{VULKAN_SDK} EQUAL "") - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(LOADER_LIB "$ENV{VULKAN_SDK}/Lib/vulkan-1.lib") + if(TARGET vulkan) + set(LOADER_LIB vulkan) + elseif(WIN32 AND NOT $ENV{VULKAN_SDK} EQUAL "") + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(LOADER_LIB "$ENV{VULKAN_SDK}/Lib/vulkan-1.lib") + else() + set(LOADER_LIB "$ENV{VULKAN_SDK}/Lib32/vulkan-1.lib") + endif() else() - set(LOADER_LIB "$ENV{VULKAN_SDK}/Lib32/vulkan-1.lib") + set(LOADER_LIB vulkan) endif() -else() - set(LOADER_LIB vulkan) -endif() -target_link_libraries(vk_loader_validation_tests "${LOADER_LIB}" gtest gtest_main) -if(BUILD_LOADER AND ENABLE_STATIC_LOADER) - set_target_properties(vk_loader_validation_tests PROPERTIES LINK_FLAGS "/ignore:4098") -endif() -if(WIN32) - file(COPY vk_loader_validation_tests.vcxproj.user DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") -endif() + target_link_libraries(vk_loader_validation_tests "${LOADER_LIB}" gtest gtest_main) + if(BUILD_LOADER AND ENABLE_STATIC_LOADER) + set_target_properties(vk_loader_validation_tests PROPERTIES LINK_FLAGS "/ignore:4098") + endif() + if(WIN32) + file(COPY vk_loader_validation_tests.vcxproj.user DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") + endif() -# Copy googletest (gtest) libs to test dir so the test executable can find them. -if(WIN32) - if (CMAKE_GENERATOR MATCHES "^Visual Studio.*") - file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/external/googletest/googletest/$<CONFIG>/gtest_main$<$<CONFIG:Debug>:d>.dll GTEST_COPY_SRC1) - file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/external/googletest/googletest/$<CONFIG>/gtest$<$<CONFIG:Debug>:d>.dll GTEST_COPY_SRC2) - file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG> GTEST_COPY_DEST) - else() - file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/external/googletest/googeltest/gtest_main.dll GTEST_COPY_SRC1) - file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/external/googletest/googletest/gtest.dll GTEST_COPY_SRC2) - file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR} GTEST_COPY_DEST) + # Copy googletest (gtest) libs to test dir so the test executable can find them. + if(WIN32) + if (CMAKE_GENERATOR MATCHES "^Visual Studio.*") + file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/external/googletest/googletest/$<CONFIG>/gtest_main$<$<CONFIG:Debug>:d>.dll GTEST_COPY_SRC1) + file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/external/googletest/googletest/$<CONFIG>/gtest$<$<CONFIG:Debug>:d>.dll GTEST_COPY_SRC2) + file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG> GTEST_COPY_DEST) + else() + file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/external/googletest/googeltest/gtest_main.dll GTEST_COPY_SRC1) + file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR}/external/googletest/googletest/gtest.dll GTEST_COPY_SRC2) + file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR} GTEST_COPY_DEST) + endif() + add_custom_command(TARGET vk_loader_validation_tests POST_BUILD + COMMAND xcopy /Y /I ${GTEST_COPY_SRC1} ${GTEST_COPY_DEST} + COMMAND xcopy /Y /I ${GTEST_COPY_SRC2} ${GTEST_COPY_DEST} + ) endif() - add_custom_command(TARGET vk_loader_validation_tests POST_BUILD - COMMAND xcopy /Y /I ${GTEST_COPY_SRC1} ${GTEST_COPY_DEST} - COMMAND xcopy /Y /I ${GTEST_COPY_SRC2} ${GTEST_COPY_DEST} - ) -endif() -add_subdirectory(layers) + add_subdirectory(layers) +endif() |