1cmake_minimum_required(VERSION 2.8.11) 2 3# On Windows, we must pair Debug and Release appropriately 4if (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() 13else() 14 include (FindPkgConfig) 15 if (BUILD_WSI_XCB_SUPPORT) 16 find_package(XCB REQUIRED) 17 endif() 18endif() 19 20set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") 21 22if(WIN32) 23 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES") 24 25 # If MSVC, disable some signed/unsigned mismatch warnings. 26 if (MSVC) 27 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") 28 endif() 29 30else() 31 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 32endif() 33 34set (LIBGLM_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/libs) 35 36set(COMMON_CPP 37 vkrenderframework.cpp 38 vktestbinding.cpp 39 vktestframework.cpp 40 test_environment.cpp 41 ) 42 43include_directories( 44 "${PROJECT_SOURCE_DIR}/tests/gtest-1.7.0/include" 45 "${PROJECT_SOURCE_DIR}/icd/common" 46 "${PROJECT_SOURCE_DIR}/layers" 47 ${GLSLANG_SPIRV_INCLUDE_DIR} 48 ${LIBGLM_INCLUDE_DIR} 49 ) 50 51if (NOT WIN32) 52 # extra setup for out-of-tree builds 53 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) 54 add_custom_target(binary-dir-symlinks ALL 55 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh 56 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_wrap_objects_tests.sh 57 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_loader_tests.sh 58 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_extra_loader_tests.sh 59 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/vkvalidatelayerdoc.sh 60 VERBATIM 61 ) 62 endif() 63else() 64 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) 65 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_run_all_tests.ps1 RUN_ALL) 66 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_vkvalidatelayerdoc.ps1 VALIDATE_DOC) 67 add_custom_target(binary-dir-symlinks ALL 68 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL} run_all_tests.ps1 69 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VALIDATE_DOC} vkvalidatelayerdoc.ps1 70 VERBATIM 71 ) 72 endif() 73endif() 74 75if(WIN32) 76 set (LIBVK "vulkan-${MAJOR}") 77elseif(UNIX) 78 set (LIBVK "vulkan") 79else() 80endif() 81 82add_executable(vk_layer_validation_tests layer_validation_tests.cpp ${COMMON_CPP}) 83set_target_properties(vk_layer_validation_tests 84 PROPERTIES 85 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") 86if(NOT WIN32) 87 if (BUILD_WSI_XCB_SUPPORT AND BUILD_WSI_XLIB_SUPPORT) 88 target_link_libraries(vk_layer_validation_tests ${LIBVK} ${XCB_LIBRARIES} ${X11_LIBRARIES} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) 89 else() 90 target_link_libraries(vk_layer_validation_tests ${LIBVK} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) 91 endif() 92endif() 93if(WIN32) 94 target_link_libraries(vk_layer_validation_tests ${LIBVK} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) 95endif() 96 97add_executable(vk_loader_validation_tests loader_validation_tests.cpp ${COMMON_CPP}) 98set_target_properties(vk_loader_validation_tests 99 PROPERTIES 100 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") 101target_link_libraries(vk_loader_validation_tests ${LIBVK} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) 102 103add_subdirectory(gtest-1.7.0) 104add_subdirectory(layers) 105