blob: 77bcd694c79c6b2d8ffcccce4f98832b2c38a9b5 [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)
18 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES /wd4267")
Tony Barbour500194c2015-05-21 11:07:47 -060019else()
Cody Northrop07d25af2015-06-04 09:21:03 -060020 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES -Wno-sign-compare -std=c++11")
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 Goeltzenleuchtera43bbd82014-10-03 15:34:53 -060032# Expect libraries to be in either the build (release build) or dbuild (debug) directories
33if(EXISTS ${GLSLANG_PREFIX}/build/install/lib)
34 set(GLSLANG_BUILD ${GLSLANG_PREFIX}/build)
35elseif(EXISTS ${GLSLANG_PREFIX}/dbuild/install/lib)
36 set(GLSLANG_BUILD ${GLSLANG_PREFIX}/dbuild)
37else()
38 message(FATAL_ERROR "Necessary glslang libraries cannot be found: " ${GLSLANG_PREFIX})
39endif()
40
Courtney Goeltzenleuchter9818f782014-10-03 09:53:32 -060041link_directories(
Courtney Goeltzenleuchtera43bbd82014-10-03 15:34:53 -060042 "${GLSLANG_BUILD}/install/lib"
Courtney Goeltzenleuchter9818f782014-10-03 09:53:32 -060043 )
44
Courtney Goeltzenleuchter9818f782014-10-03 09:53:32 -060045set(TEST_LIBRARIES
Tony Barbour500194c2015-05-21 11:07:47 -060046 glslang
47 OGLCompiler
48 OSDependent
49 SPIRV
50 ${XCB_LIBRARIES}
51 ${ImageMagick_LIBRARIES}
52 )
Courtney Goeltzenleuchter9818f782014-10-03 09:53:32 -060053
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -060054include_directories(
55 "${PROJECT_SOURCE_DIR}/tests/gtest-1.7.0/include"
56 "${PROJECT_SOURCE_DIR}/icd/common"
Mark Lobodzinski159ffe02015-05-14 14:30:48 -050057 "${PROJECT_SOURCE_DIR}/layers"
Cody Northrop5a95b472015-06-03 13:01:54 -060058 ${GLSLANG_PREFIX}
Tony Barbour96db8822015-02-25 12:28:39 -070059 ${XCB_INCLUDE_DIRS}
Tony Barbour500194c2015-05-21 11:07:47 -060060 ${LIBGLM_INCLUDE_DIR}
Chia-I Wuec664fa2014-12-02 11:54:24 +080061 ${ImageMagick_INCLUDE_DIRS}
Courtney Goeltzenleuchter6863ff42014-08-19 13:34:28 -060062 )
Courtney Goeltzenleuchter24cec9b2014-08-11 13:15:04 -060063
Tony Barbour7ea6aa22015-05-22 09:44:58 -060064if (NOT WIN32)
65 # extra setup for out-of-tree builds
66 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
67 add_custom_target(binary-dir-symlinks ALL
68 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/golden
69 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh
70 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests_with_layers.sh
71 COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/layer_test_suite.py
72 VERBATIM
73 )
74 endif()
Tony Barbour856aba32015-06-08 16:11:29 -060075else()
76 if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
77 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/golden GOLDEN)
78 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.ps1 RUN_ALL)
79 FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests_with_layers.ps1 RUN_ALL_WITH_LAYERS)
80 add_custom_target(binary-dir-symlinks ALL
81 COMMAND copy ${RUN_ALL} run_all_tests.ps1
82 COMMAND copy ${RUN_ALL_WITH_LAYERS} run_all_tests_with_layers.ps1
83 COMMAND mklink /J golden ${GOLDEN}
84 VERBATIM
85 )
86 endif()
Chia-I Wu05c71812014-12-06 10:22:40 +080087endif()
88
Courtney Goeltzenleuchterd365eeb2015-04-08 21:19:57 -060089add_executable(vkbase init.cpp ${COMMON_CPP})
90set_target_properties(vkbase
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -060091 PROPERTIES
92 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -060093target_link_libraries(vkbase vulkan gtest gtest_main ${TEST_LIBRARIES})
Courtney Goeltzenleuchter447ed582014-08-11 18:19:35 -060094
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060095add_executable(vk_image_tests image_tests.cpp ${COMMON_CPP})
96set_target_properties(vk_image_tests
Courtney Goeltzenleuchter80ea59a2014-08-14 17:41:57 -060097 PROPERTIES
98 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -060099target_link_libraries(vk_image_tests vulkan gtest gtest_main ${TEST_LIBRARIES})
Courtney Goeltzenleuchter80ea59a2014-08-14 17:41:57 -0600100
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600101add_executable(vk_render_tests render_tests.cpp ${COMMON_CPP})
102set_target_properties(vk_render_tests
Courtney Goeltzenleuchtercc5eb3a2014-08-19 18:35:50 -0600103 PROPERTIES
104 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -0600105target_link_libraries(vk_render_tests vulkan gtest gtest_main ${TEST_LIBRARIES})
Courtney Goeltzenleuchtercc5eb3a2014-08-19 18:35:50 -0600106
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600107add_executable(vk_blit_tests blit_tests.cpp ${COMMON_CPP})
108set_target_properties(vk_blit_tests
Chia-I Wud7414b02014-10-21 11:06:26 +0800109 PROPERTIES
110 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
Courtney Goeltzenleuchterf53c3cb2015-04-14 14:55:44 -0600111target_link_libraries(vk_blit_tests vulkan gtest gtest_main ${TEST_LIBRARIES})
Chia-I Wud7414b02014-10-21 11:06:26 +0800112
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600113add_executable(vk_layer_validation_tests layer_validation_tests.cpp ${COMMON_CPP})
114set_target_properties(vk_layer_validation_tests
Tony Barbour300a6082015-04-07 13:44:53 -0600115 PROPERTIES
116 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
Mark Lobodzinski159ffe02015-05-14 14:30:48 -0500117target_link_libraries(vk_layer_validation_tests vulkan gtest gtest_main layer_utils ${TEST_LIBRARIES})
Tony Barbour300a6082015-04-07 13:44:53 -0600118
Courtney Goeltzenleuchter24cec9b2014-08-11 13:15:04 -0600119add_subdirectory(gtest-1.7.0)