Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.8.11) |
Courtney Goeltzenleuchter | f21d32d | 2014-09-01 13:57:15 -0600 | [diff] [blame] | 2 | |
Tony Barbour | 29cc952 | 2016-12-07 11:18:19 -0700 | [diff] [blame] | 3 | if(CMAKE_SYSTEM_NAME STREQUAL "Windows") |
| 4 | add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN) |
Mike Schuchardt | 860d441 | 2017-12-11 15:46:52 -0700 | [diff] [blame] | 5 | # Workaround for TR1 deprecation in Visual Studio 15.5 until Google Test is updated |
| 6 | add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) |
Tony Barbour | 29cc952 | 2016-12-07 11:18:19 -0700 | [diff] [blame] | 7 | set(DisplayServer Win32) |
| 8 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 9 | add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR) |
| 10 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 11 | if (BUILD_WSI_XCB_SUPPORT) |
| 12 | add_definitions(-DVK_USE_PLATFORM_XCB_KHR) |
| 13 | endif() |
| 14 | |
| 15 | if (BUILD_WSI_XLIB_SUPPORT) |
| 16 | add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) |
| 17 | endif() |
| 18 | |
| 19 | if (BUILD_WSI_WAYLAND_SUPPORT) |
| 20 | add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR) |
| 21 | endif() |
| 22 | |
| 23 | if (BUILD_WSI_MIR_SUPPORT) |
| 24 | add_definitions(-DVK_USE_PLATFORM_MIR_KHR) |
Tony Barbour | c53c727 | 2016-12-07 10:19:21 -0700 | [diff] [blame] | 25 | include_directories(${MIR_INCLUDE_DIR}) |
Tony Barbour | 29cc952 | 2016-12-07 11:18:19 -0700 | [diff] [blame] | 26 | endif() |
Karl Schultz | 2e5ed33 | 2017-12-12 10:33:01 -0500 | [diff] [blame] | 27 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") |
| 28 | add_definitions(-DVK_USE_PLATFORM_MACOS_MVK) |
Tony Barbour | 29cc952 | 2016-12-07 11:18:19 -0700 | [diff] [blame] | 29 | else() |
| 30 | message(FATAL_ERROR "Unsupported Platform!") |
| 31 | endif() |
| 32 | |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 33 | # On Windows, we must pair Debug and Release appropriately |
| 34 | if (WIN32) |
| 35 | # For Windows, since 32-bit and 64-bit items can co-exist, we build each in its own build directory. |
Mark Young | ecf4582 | 2016-01-18 15:48:20 -0700 | [diff] [blame] | 36 | # 32-bit target data goes in build32, and 64-bit target data goes into build. So, include/link the |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 37 | # appropriate data at build time. |
| 38 | if (CMAKE_CL_64) |
Mark Young | ecf4582 | 2016-01-18 15:48:20 -0700 | [diff] [blame] | 39 | set (BUILDTGT_DIR build) |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 40 | else () |
| 41 | set (BUILDTGT_DIR build32) |
| 42 | endif() |
Dave Houlton | 33d58cb | 2017-03-13 12:19:36 -0600 | [diff] [blame] | 43 | file(COPY vk_layer_validation_tests.vcxproj.user DESTINATION ${CMAKE_BINARY_DIR}/tests) |
Tony Barbour | 96db882 | 2015-02-25 12:28:39 -0700 | [diff] [blame] | 44 | endif() |
| 45 | |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 46 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") |
| 47 | |
Tony Barbour | 7ea6aa2 | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 48 | if(WIN32) |
Tony Barbour | 7b60e49 | 2016-02-02 14:43:55 -0700 | [diff] [blame] | 49 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES") |
Mark Young | 44c90ba | 2016-01-25 16:49:47 -0700 | [diff] [blame] | 50 | |
| 51 | # If MSVC, disable some signed/unsigned mismatch warnings. |
| 52 | if (MSVC) |
| 53 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") |
| 54 | endif() |
| 55 | |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 56 | else() |
Jeremy Hayes | 3b2a3a3 | 2016-06-21 11:05:08 -0600 | [diff] [blame] | 57 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 58 | endif() |
Mark Lobodzinski | 391bb6d | 2015-01-09 15:12:03 -0600 | [diff] [blame] | 59 | |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 60 | set (LIBGLM_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/libs) |
| 61 | |
| 62 | set(COMMON_CPP |
Courtney Goeltzenleuchter | f53c3cb | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 63 | vkrenderframework.cpp |
| 64 | vktestbinding.cpp |
| 65 | vktestframework.cpp |
Tony Barbour | 92400bb | 2015-03-02 16:38:52 -0700 | [diff] [blame] | 66 | test_environment.cpp |
Courtney Goeltzenleuchter | 24cec9b | 2014-08-11 13:15:04 -0600 | [diff] [blame] | 67 | ) |
| 68 | |
Courtney Goeltzenleuchter | 6863ff4 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 69 | include_directories( |
Mark Lobodzinski | 900bfa1 | 2018-01-19 12:04:16 -0700 | [diff] [blame] | 70 | ${PROJECT_SOURCE_DIR}/tests |
| 71 | ${PROJECT_SOURCE_DIR}/tests/gtest-1.7.0/include |
| 72 | ${PROJECT_SOURCE_DIR}/icd/common |
| 73 | ${PROJECT_SOURCE_DIR}/layers |
Dustin Graves | 3402bdd | 2016-03-15 15:39:08 -0600 | [diff] [blame] | 74 | ${GLSLANG_SPIRV_INCLUDE_DIR} |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 75 | ${LIBGLM_INCLUDE_DIR} |
Mark Young | 0f183a8 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 76 | ${CMAKE_CURRENT_BINARY_DIR} |
| 77 | ${CMAKE_BINARY_DIR} |
Mark Lobodzinski | 900bfa1 | 2018-01-19 12:04:16 -0700 | [diff] [blame] | 78 | ${PROJECT_BINARY_DIR} |
Courtney Goeltzenleuchter | 6863ff4 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 79 | ) |
Courtney Goeltzenleuchter | 24cec9b | 2014-08-11 13:15:04 -0600 | [diff] [blame] | 80 | |
Tony Barbour | 7ea6aa2 | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 81 | if (NOT WIN32) |
| 82 | # extra setup for out-of-tree builds |
| 83 | if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) |
| 84 | add_custom_target(binary-dir-symlinks ALL |
Tony Barbour | 7ea6aa2 | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 85 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh |
Jeremy Hayes | ab9804d | 2016-06-30 10:13:35 -0600 | [diff] [blame] | 86 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_wrap_objects_tests.sh |
| 87 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_loader_tests.sh |
Jeremy Hayes | 5226180 | 2016-08-15 10:37:24 -0600 | [diff] [blame] | 88 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_extra_loader_tests.sh |
Tobin Ehlis | 12d4c6a | 2015-08-31 12:42:38 -0600 | [diff] [blame] | 89 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/vkvalidatelayerdoc.sh |
Tony Barbour | 7ea6aa2 | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 90 | VERBATIM |
| 91 | ) |
| 92 | endif() |
Tony Barbour | 856aba3 | 2015-06-08 16:11:29 -0600 | [diff] [blame] | 93 | else() |
| 94 | if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) |
Cody Northrop | 95cb689 | 2015-08-14 10:55:56 -0600 | [diff] [blame] | 95 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_run_all_tests.ps1 RUN_ALL) |
Dustin Graves | 66bb7ea | 2016-05-06 13:45:34 -0600 | [diff] [blame] | 96 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_vkvalidatelayerdoc.ps1 VALIDATE_DOC) |
Tony Barbour | 856aba3 | 2015-06-08 16:11:29 -0600 | [diff] [blame] | 97 | add_custom_target(binary-dir-symlinks ALL |
Dustin Graves | 66bb7ea | 2016-05-06 13:45:34 -0600 | [diff] [blame] | 98 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL} run_all_tests.ps1 |
| 99 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VALIDATE_DOC} vkvalidatelayerdoc.ps1 |
Tony Barbour | 856aba3 | 2015-06-08 16:11:29 -0600 | [diff] [blame] | 100 | VERBATIM |
| 101 | ) |
Mark Lobodzinski | 37f236c | 2018-02-01 09:27:03 -0700 | [diff] [blame] | 102 | set_target_properties(binary-dir-symlinks PROPERTIES FOLDER ${LVL_TARGET_FOLDER}) |
Tony Barbour | 856aba3 | 2015-06-08 16:11:29 -0600 | [diff] [blame] | 103 | endif() |
Chia-I Wu | 05c7181 | 2014-12-06 10:22:40 +0800 | [diff] [blame] | 104 | endif() |
| 105 | |
Jeremy Hayes | 2264144 | 2016-02-08 12:14:51 -0700 | [diff] [blame] | 106 | if(WIN32) |
Lenny Komow | 63fc169 | 2016-11-07 10:44:23 -0700 | [diff] [blame] | 107 | set (LIBVK "${API_LOWERCASE}-${MAJOR}") |
Jeremy Hayes | 2264144 | 2016-02-08 12:14:51 -0700 | [diff] [blame] | 108 | elseif(UNIX) |
Lenny Komow | 63fc169 | 2016-11-07 10:44:23 -0700 | [diff] [blame] | 109 | set (LIBVK "${API_LOWERCASE}") |
Jeremy Hayes | 2264144 | 2016-02-08 12:14:51 -0700 | [diff] [blame] | 110 | else() |
| 111 | endif() |
Tony Barbour | bcf05fd | 2015-07-13 12:32:00 -0600 | [diff] [blame] | 112 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 113 | add_executable(vk_layer_validation_tests layer_validation_tests.cpp ${COMMON_CPP}) |
| 114 | set_target_properties(vk_layer_validation_tests |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 115 | PROPERTIES |
| 116 | COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 117 | if(NOT WIN32) |
Tony Barbour | 2e7bd40 | 2016-11-14 14:46:33 -0700 | [diff] [blame] | 118 | if (BUILD_WSI_XCB_SUPPORT OR BUILD_WSI_XLIB_SUPPORT) |
Norbert Nopper | 15a45db | 2016-09-08 09:31:36 +0200 | [diff] [blame] | 119 | target_link_libraries(vk_layer_validation_tests ${LIBVK} ${XCB_LIBRARIES} ${X11_LIBRARIES} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) |
| 120 | else() |
| 121 | target_link_libraries(vk_layer_validation_tests ${LIBVK} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) |
| 122 | endif() |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 123 | endif() |
| 124 | if(WIN32) |
| 125 | target_link_libraries(vk_layer_validation_tests ${LIBVK} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) |
| 126 | endif() |
Cort | e13e0c0 | 2016-12-19 08:07:43 -0800 | [diff] [blame] | 127 | add_dependencies(vk_layer_validation_tests |
| 128 | VkLayer_core_validation |
| 129 | VkLayer_object_tracker |
Cort | e13e0c0 | 2016-12-19 08:07:43 -0800 | [diff] [blame] | 130 | VkLayer_threading |
| 131 | VkLayer_unique_objects |
| 132 | VkLayer_parameter_validation |
| 133 | ) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 134 | |
Mark Lobodzinski | c518aab | 2017-03-13 10:26:19 -0600 | [diff] [blame] | 135 | if (WIN32) |
| 136 | # For Windows, copy necessary gtest DLLs to the right spot for the vk_layer_tests... |
| 137 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/gtest-1.7.0/$<CONFIGURATION>/*.dll SRC_GTEST_DLLS) |
| 138 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION> DST_GTEST_DLLS) |
| 139 | add_custom_command(TARGET vk_layer_validation_tests POST_BUILD |
| 140 | COMMAND xcopy /Y /I ${SRC_GTEST_DLLS} ${DST_GTEST_DLLS}) |
| 141 | endif() |
| 142 | |
Jeremy Hayes | 6650d1f | 2016-04-20 09:00:39 -0600 | [diff] [blame] | 143 | add_executable(vk_loader_validation_tests loader_validation_tests.cpp ${COMMON_CPP}) |
| 144 | set_target_properties(vk_loader_validation_tests |
| 145 | PROPERTIES |
| 146 | COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") |
| 147 | target_link_libraries(vk_loader_validation_tests ${LIBVK} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) |
| 148 | |
Courtney Goeltzenleuchter | 24cec9b | 2014-08-11 13:15:04 -0600 | [diff] [blame] | 149 | add_subdirectory(gtest-1.7.0) |
Jon Ashburn | 55585ed | 2016-05-11 16:57:26 -0600 | [diff] [blame] | 150 | add_subdirectory(layers) |