aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Giessen <charles@lunarg.com>2023-06-15 18:20:44 -0600
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2023-06-16 15:06:03 -0600
commit961ec2437fbaac1abd9eb9ee5b7e83f7152ec681 (patch)
tree04c78ff6abaacdd7d09e59a68fdc7f3dd337c525
parent7879c955b9a8705576d975a9d1bbd280ca40ade8 (diff)
downloadusermoji-961ec2437fbaac1abd9eb9ee5b7e83f7152ec681.tar.xz
test: Use build artifacts in tests
-rw-r--r--tests/CMakeLists.txt22
-rw-r--r--tests/binary_locations.h.in20
2 files changed, 38 insertions, 4 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 4367354d..048f0937 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -15,6 +15,21 @@
# limitations under the License.
# ~~~
+# setup binary_locations_$<CONFIG>.h.in using binary_locations.h.in as a source
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/binary_locations_$<CONFIG>.h" INPUT "${CMAKE_CURRENT_SOURCE_DIR}/binary_locations.h.in")
+
+# copy binary_locations_$<CONFIG> to the build directory
+add_custom_command(
+ PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} "-E" "copy_if_different" "${CMAKE_CURRENT_BINARY_DIR}/binary_locations_$<CONFIG>.h" "${CMAKE_CURRENT_BINARY_DIR}/binary_locations.h"
+ VERBATIM
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/binary_locations_$<CONFIG>.h"
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/binary_locations.h"
+ COMMENT "creating binary_locations.h file ({event: PRE_BUILD}, {filename: binary_locations.h })"
+ )
+add_custom_target (generate_binary_locations DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/binary_locations.h")
+add_dependencies (generate_binary_locations vkcube vkcubepp VkICD_mock_icd vulkaninfo)
+
find_package(GTest REQUIRED CONFIG QUIET)
add_executable(vulkan_tools_tests)
@@ -25,10 +40,9 @@ target_sources(vulkan_tools_tests PRIVATE
get_target_property(TEST_SOURCES vulkan_tools_tests SOURCES)
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${TEST_SOURCES})
-# make sure tests are built after all of the following are built
-add_dependencies(vulkan_tools_tests vkcube vkcubepp VkICD_mock_icd vulkaninfo)
-
-target_link_libraries(vulkan_tools_tests GTest::gtest)
+target_include_directories(vulkan_tools_tests PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+target_link_libraries(vulkan_tools_tests GTest::gtest Vulkan::Vulkan)
+add_dependencies(vulkan_tools_tests generate_binary_locations)
include(GoogleTest)
gtest_discover_tests(vulkan_tools_tests DISCOVERY_TIMEOUT 100)
diff --git a/tests/binary_locations.h.in b/tests/binary_locations.h.in
new file mode 100644
index 00000000..acdd9b83
--- /dev/null
+++ b/tests/binary_locations.h.in
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2023 The Khronos Group Inc.
+ * Copyright (c) 2023 Valve Corporation
+ * Copyright (c) 2023 LunarG, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define MOCK_ICD_JSON_MANIFEST_PATH "$<TARGET_FILE_DIR:VkICD_mock_icd>"