blob: 236973571be5d5569634be53367f166281f68779 [file] [log] [blame]
Tony Barbour500194c2015-05-21 11:07:47 -06001cmake_minimum_required(VERSION 2.8.11)
Courtney Goeltzenleuchterf21d32d2014-09-01 13:57:15 -06002include (FindPkgConfig)
3
Tony Barbour96db8822015-02-25 12:28:39 -07004if(NOT WIN32)
5 find_package(XCB REQUIRED)
6endif()
7
Chia-I Wuec664fa2014-12-02 11:54:24 +08008find_package(ImageMagick COMPONENTS MagickWand)
Chia-I Wuec664fa2014-12-02 11:54:24 +08009if(NOT ImageMagick_FOUND)
Tony Barbour76411ba2015-06-10 16:53:00 -060010 if(NOT WIN32)
11 message(FATAL_ERROR "Missing ImageMagick library: sudo apt-get install libmagickwand-dev")
12 else()
13 message(FATAL_ERROR "Missing ImageMagick library: Get from http://www.imagemagick.org/script/binary-releases.php. Be sure to check box to 'Install development headers and libraries'")
14 endif()
Chia-I Wuec664fa2014-12-02 11:54:24 +080015endif()
16
Tony Barbour7ea6aa22015-05-22 09:44:58 -060017if(WIN32)
Mike Stroyan00a5d362015-08-10 16:47:15 -060018 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES /wd4267 -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16")
Tony Barbour500194c2015-05-21 11:07:47 -060019else()
Mike Stroyan00a5d362015-08-10 16:47:15 -060020 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES -Wno-sign-compare -std=c++11 -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16")
Tony Barbour500194c2015-05-21 11:07:47 -060021endif()
Mark Lobodzinski391bb6d2015-01-09 15:12:03 -060022
Tony Barbour500194c2015-05-21 11:07:47 -060023set (LIBGLM_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/libs)
24
25set(COMMON_CPP
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -060026 vkrenderframework.cpp
27 vktestbinding.cpp
28 vktestframework.cpp
Tony Barbour92400bb2015-03-02 16:38:52 -070029 test_environment.cpp
Courtney Goeltzenleuchter24cec9b2014-08-11 13:15:04 -060030 )
31
Courtney Goeltzenleuchter9818f782014-10-03 09:53:32 -060032set(TEST_LIBRARIES
Tony Barbour500194c2015-05-21 11:07:47 -060033 glslang
34 OGLCompiler
35 OSDependent
36 SPIRV
37 ${XCB_LIBRARIES}
38 ${ImageMagick_LIBRARIES}
39 )
Courtney Goeltzenleuchter9818f782014-10-03 09:53:32 -060040
Tony Barbourbcf05fd2015-07-13 12:32:00 -060041add_library(glslang STATIC IMPORTED)
42add_library(OGLCompiler STATIC IMPORTED)
43add_library(OSDependent STATIC IMPORTED)
44add_library(SPIRV STATIC IMPORTED)
45
46# On Windows, we must pair Debug and Release appropriately
47if (WIN32)
48 set_target_properties(glslang PROPERTIES
49 IMPORTED_LOCATION "${GLSLANG_PREFIX}/build/glslang/Release/glslang.lib"
50 IMPORTED_LOCATION_DEBUG "${GLSLANG_PREFIX}/build/glslang/Debug/glslang.lib")
51 set_target_properties(OGLCompiler PROPERTIES
52 IMPORTED_LOCATION "${GLSLANG_PREFIX}/build/OGLCompilersDLL/Release/OGLCompiler.lib"
David Pinedoa08771e2015-06-09 16:04:36 -060053 IMPORTED_LOCATION_DEBUG "${GLSLANG_PREFIX}/build/OGLCompilersDLL/Debug/OGLCompiler.lib")
Tony Barbourbcf05fd2015-07-13 12:32:00 -060054 set_target_properties(OSDependent PROPERTIES
55 IMPORTED_LOCATION "${GLSLANG_PREFIX}/build/glslang/OSDependent/Windows/Release/OSDependent.lib"
David Pinedoa08771e2015-06-09 16:04:36 -060056 IMPORTED_LOCATION_DEBUG "${GLSLANG_PREFIX}/build/glslang/OSDependent/Windows/Debug/OSDependent.lib")
Tony Barbourbcf05fd2015-07-13 12:32:00 -060057 set_target_properties(SPIRV PROPERTIES
58 IMPORTED_LOCATION "${GLSLANG_PREFIX}/build/SPIRV/Release/SPIRV.lib"
David Pinedoa08771e2015-06-09 16:04:36 -060059 IMPORTED_LOCATION_DEBUG "${GLSLANG_PREFIX}/build/SPIRV/Debug/SPIRV.lib")
60else ()
Tony Barbourbcf05fd2015-07-13 12:32:00 -060061 set_target_properties(glslang PROPERTIES
62 IMPORTED_LOCATION "${GLSLANG_PREFIX}/build/install/lib/libglslang.a")
63 set_target_properties(OGLCompiler PROPERTIES
David Pinedoa08771e2015-06-09 16:04:36 -060064 IMPORTED_LOCATION "${GLSLANG_PREFIX}/build/install/lib/libOGLCompiler.a")
Tony Barbourbcf05fd2015-07-13 12:32:00 -060065 set_target_properties(OSDependent PROPERTIES
David Pinedoa08771e2015-06-09 16:04:36 -060066 IMPORTED_LOCATION "${GLSLANG_PREFIX}/build/install/lib/libOSDependent.a")
Tony Barbourbcf05fd2015-07-13 12:32:00 -060067 set_target_properties(SPIRV PROPERTIES
David Pinedoa08771e2015-06-09 16:04:36 -060068 IMPORTED_LOCATION "${GLSLANG_PREFIX}/build/install/lib/libSPIRV.a")
69endif()
70
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -060071include_directories(
72 "${PROJECT_SOURCE_DIR}/tests/gtest-1.7.0/include"
73 "${PROJECT_SOURCE_DIR}/icd/common"
Mark Lobodzinski159ffe02015-05-14 14:30:48 -050074 "${PROJECT_SOURCE_DIR}/layers"
Cody Northrop5a95b472015-06-03 13:01:54 -060075 ${GLSLANG_PREFIX}
Tony Barbour96db8822015-02-25 12:28:39 -070076 ${XCB_INCLUDE_DIRS}
Tony Barbour500194c2015-05-21 11:07:47 -060077 ${LIBGLM_INCLUDE_DIR}
Chia-I Wuec664fa2014-12-02 11:54:24 +080078 ${ImageMagick_INCLUDE_DIRS}
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -060079 )
Courtney Goeltzenleuchter24cec9b2014-08-11 13:15:04 -060080
Tony Barbour7ea6aa22015-05-22 09:44:58 -060081if (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
85 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/golden
86 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh
87 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests_with_layers.sh
88 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/layer_test_suite.py
Mark Lobodzinski3a77cbc2015-08-14 14:24:50 -060089 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/vktracereplay.sh
Tobin Ehlis12d4c6a2015-08-31 12:42:38 -060090 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/vkvalidatelayerdoc.sh
Tony Barbour7ea6aa22015-05-22 09:44:58 -060091 VERBATIM
92 )
93 endif()
Tony Barbour856aba32015-06-08 16:11:29 -060094else()
95 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
96 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/golden GOLDEN)
Cody Northrop95cb6892015-08-14 10:55:56 -060097 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_run_all_tests.ps1 RUN_ALL)
98 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_run_all_tests_with_layers.ps1 RUN_ALL_WITH_LAYERS)
Mark Lobodzinski28b8f022015-08-27 15:30:29 -060099 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_vktracereplay.ps1 VKTRACEREPLAY)
Tobin Ehlis12d4c6a2015-08-31 12:42:38 -0600100 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/_vkvalidatelayerdoc.ps1 VKVALIDATELAYERDOC)
Tony Barbour856aba32015-06-08 16:11:29 -0600101 add_custom_target(binary-dir-symlinks ALL
Tony Barbour6fb266c2015-07-01 12:33:07 -0600102 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL} run_all_tests.ps1
103 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RUN_ALL_WITH_LAYERS} run_all_tests_with_layers.ps1
Mark Lobodzinski28b8f022015-08-27 15:30:29 -0600104 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VKTRACEREPLAY} vktracereplay.ps1
Tobin Ehlis12d4c6a2015-08-31 12:42:38 -0600105 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VKVALIDATELAYERDOC} vkvalidatelayerdoc.ps1
Tony Barbour6fb266c2015-07-01 12:33:07 -0600106 COMMAND IF NOT EXIST golden mklink /J golden ${GOLDEN}
Tony Barbour856aba32015-06-08 16:11:29 -0600107 VERBATIM
108 )
109 endif()
Chia-I Wu05c71812014-12-06 10:22:40 +0800110endif()
111
Tony Barbourbcf05fd2015-07-13 12:32:00 -0600112if (WIN32)
David Pinedo4bb0d302015-09-08 11:07:46 -0600113 set (LIBVK "vulkan-${MAJOR}")
Tony Barbourbcf05fd2015-07-13 12:32:00 -0600114else ()
115 set (LIBVK "vulkan")
116endif()
117
Courtney Goeltzenleuchterd365eeb2015-04-08 21:19:57 -0600118add_executable(vkbase init.cpp ${COMMON_CPP})
119set_target_properties(vkbase
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -0600120 PROPERTIES
121 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
Tony Barbourbcf05fd2015-07-13 12:32:00 -0600122target_link_libraries(vkbase ${LIBVK} gtest gtest_main ${TEST_LIBRARIES})
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -0600123
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600124add_executable(vk_image_tests image_tests.cpp ${COMMON_CPP})
125set_target_properties(vk_image_tests
Courtney Goeltzenleuchter80ea59a2014-08-14 17:41:57 -0600126 PROPERTIES
127 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
Tony Barbourbcf05fd2015-07-13 12:32:00 -0600128target_link_libraries(vk_image_tests ${LIBVK} gtest gtest_main ${TEST_LIBRARIES})
Courtney Goeltzenleuchter80ea59a2014-08-14 17:41:57 -0600129
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600130add_executable(vk_render_tests render_tests.cpp ${COMMON_CPP})
131set_target_properties(vk_render_tests
Courtney Goeltzenleuchtercc5eb3a2014-08-19 18:35:50 -0600132 PROPERTIES
133 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
Tony Barbourbcf05fd2015-07-13 12:32:00 -0600134target_link_libraries(vk_render_tests ${LIBVK} gtest gtest_main ${TEST_LIBRARIES})
Courtney Goeltzenleuchtercc5eb3a2014-08-19 18:35:50 -0600135
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600136add_executable(vk_blit_tests blit_tests.cpp ${COMMON_CPP})
137set_target_properties(vk_blit_tests
Chia-I Wud7414b02014-10-21 11:06:26 +0800138 PROPERTIES
139 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
Tony Barbourbcf05fd2015-07-13 12:32:00 -0600140target_link_libraries(vk_blit_tests ${LIBVK} gtest gtest_main ${TEST_LIBRARIES})
Chia-I Wud7414b02014-10-21 11:06:26 +0800141
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600142add_executable(vk_layer_validation_tests layer_validation_tests.cpp ${COMMON_CPP})
143set_target_properties(vk_layer_validation_tests
Tony Barbour300a6082015-04-07 13:44:53 -0600144 PROPERTIES
145 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
Tony Barbourbcf05fd2015-07-13 12:32:00 -0600146target_link_libraries(vk_layer_validation_tests ${LIBVK} gtest gtest_main layer_utils ${TEST_LIBRARIES})
Tony Barbour300a6082015-04-07 13:44:53 -0600147
Courtney Goeltzenleuchter24cec9b2014-08-11 13:15:04 -0600148add_subdirectory(gtest-1.7.0)