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) |
| 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 | c53c727 | 2016-12-07 10:19:21 -0700 | [diff] [blame^] | 23 | find_package(Mir REQUIRED) |
| 24 | include_directories(${MIR_INCLUDE_DIR}) |
Tony Barbour | 29cc952 | 2016-12-07 11:18:19 -0700 | [diff] [blame] | 25 | endif() |
| 26 | else() |
| 27 | message(FATAL_ERROR "Unsupported Platform!") |
| 28 | endif() |
| 29 | |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 30 | # On Windows, we must pair Debug and Release appropriately |
| 31 | if (WIN32) |
| 32 | # 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] | 33 | # 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] | 34 | # appropriate data at build time. |
| 35 | if (CMAKE_CL_64) |
Mark Young | ecf4582 | 2016-01-18 15:48:20 -0700 | [diff] [blame] | 36 | set (BUILDTGT_DIR build) |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 37 | else () |
| 38 | set (BUILDTGT_DIR build32) |
| 39 | endif() |
| 40 | else() |
Tony Barbour | 89dc91c | 2015-12-16 14:57:33 -0700 | [diff] [blame] | 41 | include (FindPkgConfig) |
Norbert Nopper | 15a45db | 2016-09-08 09:31:36 +0200 | [diff] [blame] | 42 | if (BUILD_WSI_XCB_SUPPORT) |
| 43 | find_package(XCB REQUIRED) |
| 44 | endif() |
Tony Barbour | 96db882 | 2015-02-25 12:28:39 -0700 | [diff] [blame] | 45 | endif() |
| 46 | |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 47 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") |
| 48 | |
Tony Barbour | 7ea6aa2 | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 49 | if(WIN32) |
Tony Barbour | 7b60e49 | 2016-02-02 14:43:55 -0700 | [diff] [blame] | 50 | 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] | 51 | |
| 52 | # If MSVC, disable some signed/unsigned mismatch warnings. |
| 53 | if (MSVC) |
| 54 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") |
| 55 | endif() |
| 56 | |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 57 | else() |
Jeremy Hayes | 3b2a3a3 | 2016-06-21 11:05:08 -0600 | [diff] [blame] | 58 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 59 | endif() |
Mark Lobodzinski | 391bb6d | 2015-01-09 15:12:03 -0600 | [diff] [blame] | 60 | |
Tony Barbour | 500194c | 2015-05-21 11:07:47 -0600 | [diff] [blame] | 61 | set (LIBGLM_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/libs) |
| 62 | |
| 63 | set(COMMON_CPP |
Courtney Goeltzenleuchter | f53c3cb | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 64 | vkrenderframework.cpp |
| 65 | vktestbinding.cpp |
| 66 | vktestframework.cpp |
Tony Barbour | 92400bb | 2015-03-02 16:38:52 -0700 | [diff] [blame] | 67 | test_environment.cpp |
Courtney Goeltzenleuchter | 24cec9b | 2014-08-11 13:15:04 -0600 | [diff] [blame] | 68 | ) |
| 69 | |
Courtney Goeltzenleuchter | 6863ff4 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 70 | include_directories( |
| 71 | "${PROJECT_SOURCE_DIR}/tests/gtest-1.7.0/include" |
| 72 | "${PROJECT_SOURCE_DIR}/icd/common" |
Mark Lobodzinski | 159ffe0 | 2015-05-14 14:30:48 -0500 | [diff] [blame] | 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} |
Courtney Goeltzenleuchter | 6863ff4 | 2014-08-19 13:34:28 -0600 | [diff] [blame] | 76 | ) |
Courtney Goeltzenleuchter | 24cec9b | 2014-08-11 13:15:04 -0600 | [diff] [blame] | 77 | |
Tony Barbour | 7ea6aa2 | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 78 | if (NOT WIN32) |
| 79 | # extra setup for out-of-tree builds |
| 80 | if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) |
| 81 | add_custom_target(binary-dir-symlinks ALL |
Tony Barbour | 7ea6aa2 | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 82 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh |
Jeremy Hayes | ab9804d | 2016-06-30 10:13:35 -0600 | [diff] [blame] | 83 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_wrap_objects_tests.sh |
| 84 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_loader_tests.sh |
Jeremy Hayes | 5226180 | 2016-08-15 10:37:24 -0600 | [diff] [blame] | 85 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_extra_loader_tests.sh |
Tobin Ehlis | 12d4c6a | 2015-08-31 12:42:38 -0600 | [diff] [blame] | 86 | COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/vkvalidatelayerdoc.sh |
Tony Barbour | 7ea6aa2 | 2015-05-22 09:44:58 -0600 | [diff] [blame] | 87 | VERBATIM |
| 88 | ) |
| 89 | endif() |
Tony Barbour | 856aba3 | 2015-06-08 16:11:29 -0600 | [diff] [blame] | 90 | else() |
| 91 | if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)) |
Cody Northrop | 95cb689 | 2015-08-14 10:55:56 -0600 | [diff] [blame] | 92 | 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] | 93 | FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_vkvalidatelayerdoc.ps1 VALIDATE_DOC) |
Tony Barbour | 856aba3 | 2015-06-08 16:11:29 -0600 | [diff] [blame] | 94 | add_custom_target(binary-dir-symlinks ALL |
Dustin Graves | 66bb7ea | 2016-05-06 13:45:34 -0600 | [diff] [blame] | 95 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL} run_all_tests.ps1 |
| 96 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VALIDATE_DOC} vkvalidatelayerdoc.ps1 |
Tony Barbour | 856aba3 | 2015-06-08 16:11:29 -0600 | [diff] [blame] | 97 | VERBATIM |
| 98 | ) |
| 99 | endif() |
Chia-I Wu | 05c7181 | 2014-12-06 10:22:40 +0800 | [diff] [blame] | 100 | endif() |
| 101 | |
Jeremy Hayes | 2264144 | 2016-02-08 12:14:51 -0700 | [diff] [blame] | 102 | if(WIN32) |
Lenny Komow | 63fc169 | 2016-11-07 10:44:23 -0700 | [diff] [blame] | 103 | set (LIBVK "${API_LOWERCASE}-${MAJOR}") |
Jeremy Hayes | 2264144 | 2016-02-08 12:14:51 -0700 | [diff] [blame] | 104 | elseif(UNIX) |
Lenny Komow | 63fc169 | 2016-11-07 10:44:23 -0700 | [diff] [blame] | 105 | set (LIBVK "${API_LOWERCASE}") |
Jeremy Hayes | 2264144 | 2016-02-08 12:14:51 -0700 | [diff] [blame] | 106 | else() |
| 107 | endif() |
Tony Barbour | bcf05fd | 2015-07-13 12:32:00 -0600 | [diff] [blame] | 108 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 109 | add_executable(vk_layer_validation_tests layer_validation_tests.cpp ${COMMON_CPP}) |
| 110 | set_target_properties(vk_layer_validation_tests |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 111 | PROPERTIES |
| 112 | COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 113 | if(NOT WIN32) |
Tony Barbour | 2e7bd40 | 2016-11-14 14:46:33 -0700 | [diff] [blame] | 114 | if (BUILD_WSI_XCB_SUPPORT OR BUILD_WSI_XLIB_SUPPORT) |
Norbert Nopper | 15a45db | 2016-09-08 09:31:36 +0200 | [diff] [blame] | 115 | target_link_libraries(vk_layer_validation_tests ${LIBVK} ${XCB_LIBRARIES} ${X11_LIBRARIES} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) |
| 116 | else() |
| 117 | target_link_libraries(vk_layer_validation_tests ${LIBVK} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) |
| 118 | endif() |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 119 | endif() |
| 120 | if(WIN32) |
| 121 | target_link_libraries(vk_layer_validation_tests ${LIBVK} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) |
| 122 | endif() |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 123 | |
Jeremy Hayes | 6650d1f | 2016-04-20 09:00:39 -0600 | [diff] [blame] | 124 | add_executable(vk_loader_validation_tests loader_validation_tests.cpp ${COMMON_CPP}) |
| 125 | set_target_properties(vk_loader_validation_tests |
| 126 | PROPERTIES |
| 127 | COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") |
| 128 | target_link_libraries(vk_loader_validation_tests ${LIBVK} gtest gtest_main VkLayer_utils ${GLSLANG_LIBRARIES}) |
| 129 | |
Courtney Goeltzenleuchter | 24cec9b | 2014-08-11 13:15:04 -0600 | [diff] [blame] | 130 | add_subdirectory(gtest-1.7.0) |
Jon Ashburn | 55585ed | 2016-05-11 16:57:26 -0600 | [diff] [blame] | 131 | add_subdirectory(layers) |