Home | History | Annotate | Download | only in tests
      1 cmake_minimum_required(VERSION 2.8.11)
      2 
      3 # On Windows, we must pair Debug and Release appropriately
      4 if (WIN32)
      5    # For Windows, since 32-bit and 64-bit items can co-exist, we build each in its own build directory.
      6    # 32-bit target data goes in build32, and 64-bit target data goes into build.  So, include/link the
      7    # appropriate data at build time.
      8    if (CMAKE_CL_64)
      9       set (BUILDTGT_DIR build)
     10    else ()
     11       set (BUILDTGT_DIR build32)
     12    endif()
     13 else()
     14     include (FindPkgConfig)
     15     find_package(XCB REQUIRED)
     16 endif()
     17 
     18 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
     19 
     20 if(WIN32)
     21     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES")
     22 
     23     # If MSVC, disable some signed/unsigned mismatch warnings.
     24     if (MSVC)
     25         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267")
     26     endif()
     27 
     28 else()
     29     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare -std=c++11")
     30 endif()
     31 
     32 set (LIBGLM_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/libs)
     33 
     34 set(COMMON_CPP
     35     vkrenderframework.cpp
     36     vktestbinding.cpp
     37     vktestframework.cpp
     38     test_environment.cpp
     39    )
     40 
     41 include_directories(
     42     "${PROJECT_SOURCE_DIR}/tests/gtest-1.7.0/include"
     43     "${PROJECT_SOURCE_DIR}/icd/common"
     44     "${PROJECT_SOURCE_DIR}/layers"
     45     ${GLSLANG_SPIRV_INCLUDE_DIR}
     46     ${LIBGLM_INCLUDE_DIR}
     47     )
     48 
     49 if (NOT WIN32)
     50     # extra setup for out-of-tree builds
     51     if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
     52         add_custom_target(binary-dir-symlinks ALL
     53             COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh
     54             COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/vkvalidatelayerdoc.sh
     55             VERBATIM
     56             )
     57     endif()
     58 else()
     59     if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
     60         FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_run_all_tests.ps1 RUN_ALL)
     61         add_custom_target(binary-dir-symlinks ALL
     62             COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL} _run_all_tests.ps1
     63             COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL} _vkvalidatelayerdoc.ps1
     64             VERBATIM
     65             )
     66     endif()
     67 endif()
     68 
     69 if(WIN32)
     70    set (LIBVK "vulkan-${MAJOR}")
     71 elseif(UNIX)
     72    set (LIBVK "vulkan")
     73 else()
     74 endif()
     75 
     76 add_executable(vk_layer_validation_tests layer_validation_tests.cpp ${COMMON_CPP})
     77 set_target_properties(vk_layer_validation_tests
     78    PROPERTIES
     79    COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
     80 target_link_libraries(vk_layer_validation_tests ${LIBVK} gtest gtest_main layer_utils ${GLSLANG_LIBRARIES})
     81 
     82 add_subdirectory(gtest-1.7.0)
     83