blob: 914d56fb8eab423f173b7656e7eb8df5e87847a4 [file] [log] [blame]
Tony Barbour500194c2015-05-21 11:07:47 -06001cmake_minimum_required(VERSION 2.8.11)
Courtney Goeltzenleuchterf21d32d2014-09-01 13:57:15 -06002
Mark Young93ecb1d2016-01-13 13:47:16 -07003# 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.
Mark Youngecf45822016-01-18 15:48:20 -07006 # 32-bit target data goes in build32, and 64-bit target data goes into build. So, include/link the
Mark Young93ecb1d2016-01-13 13:47:16 -07007 # appropriate data at build time.
8 if (CMAKE_CL_64)
Mark Youngecf45822016-01-18 15:48:20 -07009 set (BUILDTGT_DIR build)
Mark Young93ecb1d2016-01-13 13:47:16 -070010 else ()
11 set (BUILDTGT_DIR build32)
12 endif()
13else()
Tony Barbour89dc91c2015-12-16 14:57:33 -070014 include (FindPkgConfig)
Tony Barbour96db8822015-02-25 12:28:39 -070015 find_package(XCB REQUIRED)
16endif()
17
Mark Young93ecb1d2016-01-13 13:47:16 -070018set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
19
Tony Barbour7ea6aa22015-05-22 09:44:58 -060020if(WIN32)
Tony Barbour7b60e492016-02-02 14:43:55 -070021 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES")
Mark Young44c90ba2016-01-25 16:49:47 -070022
23 # If MSVC, disable some signed/unsigned mismatch warnings.
24 if (MSVC)
25 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267")
26 endif()
27
Tony Barbour500194c2015-05-21 11:07:47 -060028else()
Tony Barbour7b60e492016-02-02 14:43:55 -070029 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare -std=c++11")
Tony Barbour500194c2015-05-21 11:07:47 -060030endif()
Mark Lobodzinski391bb6d2015-01-09 15:12:03 -060031
Tony Barbour500194c2015-05-21 11:07:47 -060032set (LIBGLM_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/libs)
33
34set(COMMON_CPP
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -060035 vkrenderframework.cpp
36 vktestbinding.cpp
37 vktestframework.cpp
Tony Barbour92400bb2015-03-02 16:38:52 -070038 test_environment.cpp
Courtney Goeltzenleuchter24cec9b2014-08-11 13:15:04 -060039 )
40
Courtney Goeltzenleuchter9818f782014-10-03 09:53:32 -060041set(TEST_LIBRARIES
Tony Barbour500194c2015-05-21 11:07:47 -060042 glslang
43 OGLCompiler
44 OSDependent
45 SPIRV
Tony Barbour500194c2015-05-21 11:07:47 -060046 )
Courtney Goeltzenleuchter9818f782014-10-03 09:53:32 -060047
Tony Barbourbcf05fd2015-07-13 12:32:00 -060048add_library(glslang STATIC IMPORTED)
49add_library(OGLCompiler STATIC IMPORTED)
50add_library(OSDependent STATIC IMPORTED)
51add_library(SPIRV STATIC IMPORTED)
52
53# On Windows, we must pair Debug and Release appropriately
54if (WIN32)
Mark Young93ecb1d2016-01-13 13:47:16 -070055
Tony Barbourbcf05fd2015-07-13 12:32:00 -060056 set_target_properties(glslang PROPERTIES
Mark Young93ecb1d2016-01-13 13:47:16 -070057 IMPORTED_LOCATION "${GLSLANG_PREFIX}/${BUILDTGT_DIR}/glslang/Release/glslang.lib"
58 IMPORTED_LOCATION_DEBUG "${GLSLANG_PREFIX}/${BUILDTGT_DIR}/glslang/Debug/glslang.lib")
Tony Barbourbcf05fd2015-07-13 12:32:00 -060059 set_target_properties(OGLCompiler PROPERTIES
Mark Young93ecb1d2016-01-13 13:47:16 -070060 IMPORTED_LOCATION "${GLSLANG_PREFIX}/${BUILDTGT_DIR}/OGLCompilersDLL/Release/OGLCompiler.lib"
61 IMPORTED_LOCATION_DEBUG "${GLSLANG_PREFIX}/${BUILDTGT_DIR}/OGLCompilersDLL/Debug/OGLCompiler.lib")
Tony Barbourbcf05fd2015-07-13 12:32:00 -060062 set_target_properties(OSDependent PROPERTIES
Mark Young93ecb1d2016-01-13 13:47:16 -070063 IMPORTED_LOCATION "${GLSLANG_PREFIX}/${BUILDTGT_DIR}/glslang/OSDependent/Windows/Release/OSDependent.lib"
64 IMPORTED_LOCATION_DEBUG "${GLSLANG_PREFIX}/${BUILDTGT_DIR}/glslang/OSDependent/Windows/Debug/OSDependent.lib")
Tony Barbourbcf05fd2015-07-13 12:32:00 -060065 set_target_properties(SPIRV PROPERTIES
Mark Young93ecb1d2016-01-13 13:47:16 -070066 IMPORTED_LOCATION "${GLSLANG_PREFIX}/${BUILDTGT_DIR}/SPIRV/Release/SPIRV.lib"
67 IMPORTED_LOCATION_DEBUG "${GLSLANG_PREFIX}/${BUILDTGT_DIR}/SPIRV/Debug/SPIRV.lib")
David Pinedoa08771e2015-06-09 16:04:36 -060068else ()
Tony Barbourbcf05fd2015-07-13 12:32:00 -060069 set_target_properties(glslang PROPERTIES
70 IMPORTED_LOCATION "${GLSLANG_PREFIX}/build/install/lib/libglslang.a")
71 set_target_properties(OGLCompiler PROPERTIES
David Pinedoa08771e2015-06-09 16:04:36 -060072 IMPORTED_LOCATION "${GLSLANG_PREFIX}/build/install/lib/libOGLCompiler.a")
Tony Barbourbcf05fd2015-07-13 12:32:00 -060073 set_target_properties(OSDependent PROPERTIES
David Pinedoa08771e2015-06-09 16:04:36 -060074 IMPORTED_LOCATION "${GLSLANG_PREFIX}/build/install/lib/libOSDependent.a")
Tony Barbourbcf05fd2015-07-13 12:32:00 -060075 set_target_properties(SPIRV PROPERTIES
David Pinedoa08771e2015-06-09 16:04:36 -060076 IMPORTED_LOCATION "${GLSLANG_PREFIX}/build/install/lib/libSPIRV.a")
77endif()
78
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -060079include_directories(
80 "${PROJECT_SOURCE_DIR}/tests/gtest-1.7.0/include"
81 "${PROJECT_SOURCE_DIR}/icd/common"
Mark Lobodzinski159ffe02015-05-14 14:30:48 -050082 "${PROJECT_SOURCE_DIR}/layers"
Cody Northrop5a95b472015-06-03 13:01:54 -060083 ${GLSLANG_PREFIX}
Tony Barbour500194c2015-05-21 11:07:47 -060084 ${LIBGLM_INCLUDE_DIR}
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -060085 )
Courtney Goeltzenleuchter24cec9b2014-08-11 13:15:04 -060086
Tony Barbour7ea6aa22015-05-22 09:44:58 -060087if (NOT WIN32)
88 # extra setup for out-of-tree builds
89 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
90 add_custom_target(binary-dir-symlinks ALL
Tony Barbour7ea6aa22015-05-22 09:44:58 -060091 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh
Tobin Ehlis12d4c6a2015-08-31 12:42:38 -060092 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/vkvalidatelayerdoc.sh
Tony Barbour7ea6aa22015-05-22 09:44:58 -060093 VERBATIM
94 )
95 endif()
Tony Barbour856aba32015-06-08 16:11:29 -060096else()
97 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
Cody Northrop95cb6892015-08-14 10:55:56 -060098 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_run_all_tests.ps1 RUN_ALL)
Tony Barbour856aba32015-06-08 16:11:29 -060099 add_custom_target(binary-dir-symlinks ALL
Mark Younge1b8da12016-02-03 10:05:50 -0700100 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL} _run_all_tests.ps1
101 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL} _vkvalidatelayerdoc.ps1
Tony Barbour856aba32015-06-08 16:11:29 -0600102 VERBATIM
103 )
104 endif()
Chia-I Wu05c71812014-12-06 10:22:40 +0800105endif()
106
Jeremy Hayes22641442016-02-08 12:14:51 -0700107if(WIN32)
108 set (LIBVK "vulkan-${MAJOR}")
109elseif(UNIX)
110 set (LIBVK "vulkan")
111else()
112endif()
Tony Barbourbcf05fd2015-07-13 12:32:00 -0600113
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600114add_executable(vk_layer_validation_tests layer_validation_tests.cpp ${COMMON_CPP})
115set_target_properties(vk_layer_validation_tests
Tony Barbour300a6082015-04-07 13:44:53 -0600116 PROPERTIES
117 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
Tony Barbourbcf05fd2015-07-13 12:32:00 -0600118target_link_libraries(vk_layer_validation_tests ${LIBVK} gtest gtest_main layer_utils ${TEST_LIBRARIES})
Tony Barbour300a6082015-04-07 13:44:53 -0600119
Courtney Goeltzenleuchter24cec9b2014-08-11 13:15:04 -0600120add_subdirectory(gtest-1.7.0)