Tony Barbour | b4ab874 | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.8.11) |
Courtney Goeltzenleuchter | 2268d1e | 2014-09-01 13:57:15 -0600 | [diff] [blame] | 2 | |
Tony Barbour | 3808074 | 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) |
| 5 | set(DisplayServer Win32) |
| 6 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 7 | add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR) |
| 8 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 9 | if (BUILD_WSI_XCB_SUPPORT) |
| 10 | add_definitions(-DVK_USE_PLATFORM_XCB_KHR) |
| 11 | endif() |
| 12 | |
| 13 | if (BUILD_WSI_XLIB_SUPPORT) |
| 14 | add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) |
| 15 | endif() |
| 16 | |
| 17 | if (BUILD_WSI_WAYLAND_SUPPORT) |
| 18 | add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR) |
| 19 | endif() |
| 20 | |
| 21 | if (BUILD_WSI_MIR_SUPPORT) |
| 22 | add_definitions(-DVK_USE_PLATFORM_MIR_KHR) |
Tony Barbour | 5c8ad03 | 2016-12-07 10:19:21 -0700 | [diff] [blame] | 23 | include_directories(${MIR_INCLUDE_DIR}) |
Tony Barbour | 3808074 | 2016-12-07 11:18:19 -0700 | [diff] [blame] | 24 | endif() |
| 25 | else() |
| 26 | message(FATAL_ERROR "Unsupported Platform!") |
| 27 | endif() |
| 28 | |
Mark Young | 2acdd15 | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 29 | # On Windows, we must pair Debug and Release appropriately |
| 30 | if (WIN32) |
| 31 | # For Windows, since 32-bit and 64-bit items can co-exist, we build each in its own build directory. |
Mark Young | 48fb978 | 2016-01-18 15:48:20 -0700 | [diff] [blame] | 32 | # 32-bit target data goes in build32, and 64-bit target data goes into build. So, include/link the |
Mark Young | 2acdd15 | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 33 | # appropriate data at build time. |
| 34 | if (CMAKE_CL_64) |
Mark Young | 48fb978 | 2016-01-18 15:48:20 -0700 | [diff] [blame] | 35 | set (BUILDTGT_DIR build) |
Mark Young | 2acdd15 | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 36 | else () |
| 37 | set (BUILDTGT_DIR build32) |
| 38 | endif() |
Tony Barbour | ef20d32 | 2015-02-25 12:28:39 -0700 | [diff] [blame] | 39 | endif() |
| 40 | |
Mark Young | 2acdd15 | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 41 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") |
| 42 | |
Tony Barbour | 8bef8ee | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 43 | if(WIN32) |
Tony Barbour | 55e270b | 2016-02-02 14:43:55 -0700 | [diff] [blame] | 44 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES") |
Mark Young | 6d312ff | 2016-01-25 16:49:47 -0700 | [diff] [blame] | 45 | |
| 46 | # If MSVC, disable some signed/unsigned mismatch warnings. |
| 47 | if (MSVC) |
| 48 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") |
| 49 | endif() |
| 50 | |
Tony Barbour | b4ab874 | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 51 | else() |
Jeremy Hayes | 57a2423 | 2016-06-21 11:05:08 -0600 | [diff] [blame] | 52 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") |
Tony Barbour | b4ab874 | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 53 | endif() |
Mark Lobodzinski | 953a169 | 2015-01-09 15:12:03 -0600 | [diff] [blame] | 54 | |
Tony Barbour | b4ab874 | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 55 | set (LIBGLM_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/libs) |
| 56 | |
| 57 | set(COMMON_CPP |
Courtney Goeltzenleuchter | a8c0628 | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 58 | vkrenderframework.cpp |
| 59 | vktestbinding.cpp |
| 60 | vktestframework.cpp |
Tony Barbour | 34888cf | 2015-03-02 16:38:52 -0700 | [diff] [blame] | 61 | test_environment.cpp |
Courtney Goeltzenleuchter | aa46da2 | 2014-08-11 13:15:04 -0600 | [diff] [blame] | 62 | ) |
| 63 | |
Courtney Goeltzenleuchter | a693ed2 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 64 | include_directories( |
| 65 | "${PROJECT_SOURCE_DIR}/tests/gtest-1.7.0/include" |
| 66 | "${PROJECT_SOURCE_DIR}/icd/common" |
Mark Lobodzinski | a910dc8 | 2015-05-14 14:30:48 -0500 | [diff] [blame] | 67 | "${PROJECT_SOURCE_DIR}/layers" |
Dustin Graves | 7ef139e | 2016-03-15 15:39:08 -0600 | [diff] [blame] | 68 | ${GLSLANG_SPIRV_INCLUDE_DIR} |
Tony Barbour | b4ab874 | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 69 | ${LIBGLM_INCLUDE_DIR} |
Courtney Goeltzenleuchter | a693ed2 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 70 | ) |
Courtney Goeltzenleuchter | aa46da2 | 2014-08-11 13:15:04 -0600 | [diff] [blame] | 71 | |
Tony Barbour | 8bef8ee | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 72 | if (NOT WIN32) |
| 73 | # extra setup for out-of-tree builds |
| 74 | if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) |
| 75 | add_custom_target(binary-dir-symlinks ALL |
Tony Barbour | 8bef8ee | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 76 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh |
Jeremy Hayes | de2b723 | 2016-06-30 10:13:35 -0600 | [diff] [blame] | 77 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_wrap_objects_tests.sh |
| 78 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_loader_tests.sh |
Jeremy Hayes | 251fe80 | 2016-08-15 10:37:24 -0600 | [diff] [blame] | 79 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_extra_loader_tests.sh |
Tobin Ehlis | 236717c | 2015-08-31 12:42:38 -0600 | [diff] [blame] | 80 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/vkvalidatelayerdoc.sh |
Tony Barbour | 8bef8ee | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 81 | VERBATIM |
| 82 | ) |
| 83 | endif() |
Tony Barbour | 5ed1f40 | 2015-06-08 16:11:29 -0600 | [diff] [blame] | 84 | else() |
| 85 | if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) |
Cody Northrop | f9af817 | 2015-08-14 10:55:56 -0600 | [diff] [blame] | 86 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_run_all_tests.ps1 RUN_ALL) |
Dustin Graves | 7af6b6a | 2016-05-06 13:45:34 -0600 | [diff] [blame] | 87 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_vkvalidatelayerdoc.ps1 VALIDATE_DOC) |
Tony Barbour | 5ed1f40 | 2015-06-08 16:11:29 -0600 | [diff] [blame] | 88 | add_custom_target(binary-dir-symlinks ALL |
Dustin Graves | 7af6b6a | 2016-05-06 13:45:34 -0600 | [diff] [blame] | 89 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL} run_all_tests.ps1 |
| 90 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VALIDATE_DOC} vkvalidatelayerdoc.ps1 |
Tony Barbour | 5ed1f40 | 2015-06-08 16:11:29 -0600 | [diff] [blame] | 91 | VERBATIM |
| 92 | ) |
| 93 | endif() |
Chia-I Wu | 08f6f8d | 2014-12-06 10:22:40 +0800 | [diff] [blame] | 94 | endif() |
| 95 | |
Jeremy Hayes | f1782e3 | 2016-02-08 12:14:51 -0700 | [diff] [blame] | 96 | if(WIN32) |
Lenny Komow | a5333ee | 2016-11-07 10:44:23 -0700 | [diff] [blame] | 97 | set (LIBVK "${API_LOWERCASE}-${MAJOR}") |
Jeremy Hayes | f1782e3 | 2016-02-08 12:14:51 -0700 | [diff] [blame] | 98 | elseif(UNIX) |
Lenny Komow | a5333ee | 2016-11-07 10:44:23 -0700 | [diff] [blame] | 99 | set (LIBVK "${API_LOWERCASE}") |
Jeremy Hayes | f1782e3 | 2016-02-08 12:14:51 -0700 | [diff] [blame] | 100 | else() |
| 101 | endif() |
Tony Barbour | 2e65ad9 | 2015-07-13 12:32:00 -0600 | [diff] [blame] | 102 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 103 | add_executable(vk_layer_validation_tests layer_validation_tests.cpp ${COMMON_CPP}) |
| 104 | set_target_properties(vk_layer_validation_tests |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 105 | PROPERTIES |
| 106 | COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") |
Ian Elliott | 652d4f9 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 107 | if(NOT WIN32) |
Tony Barbour | 9c699d0 | 2016-11-14 14:46:33 -0700 | [diff] [blame] | 108 | if (BUILD_WSI_XCB_SUPPORT OR BUILD_WSI_XLIB_SUPPORT) |
Norbert Nopper | 886977f | 2016-09-08 09:31:36 +0200 | [diff] [blame] | 109 | target_link_libraries(vk_layer_validation_tests ${LIBVK} ${XCB_LIBRARIES} ${X11_LIBRARIES} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) |
| 110 | else() |
| 111 | target_link_libraries(vk_layer_validation_tests ${LIBVK} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) |
| 112 | endif() |
Ian Elliott | 652d4f9 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 113 | endif() |
| 114 | if(WIN32) |
| 115 | target_link_libraries(vk_layer_validation_tests ${LIBVK} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) |
| 116 | endif() |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 117 | |
Jeremy Hayes | 4820924 | 2016-04-20 09:00:39 -0600 | [diff] [blame] | 118 | add_executable(vk_loader_validation_tests loader_validation_tests.cpp ${COMMON_CPP}) |
| 119 | set_target_properties(vk_loader_validation_tests |
| 120 | PROPERTIES |
| 121 | COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") |
| 122 | target_link_libraries(vk_loader_validation_tests ${LIBVK} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) |
| 123 | |
Courtney Goeltzenleuchter | aa46da2 | 2014-08-11 13:15:04 -0600 | [diff] [blame] | 124 | add_subdirectory(gtest-1.7.0) |
Jon Ashburn | d45cf27 | 2016-05-11 16:57:26 -0600 | [diff] [blame] | 125 | add_subdirectory(layers) |