From 668bafa375b5ca795f33097dcbc7ca973d23de7c Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Thu, 2 May 2024 10:42:56 -0500 Subject: [PATCH] Fix tests framework_config.h to work all the time When using multi-config build systems such as MSVC, it was possible for the framework_config.h to not be updated properly, resulting in the wrong binaries being used during testing. By ditching the common header file and directly specifying the header file to use through a compiler definition, the code is now shorter and more reliable. --- tests/framework/CMakeLists.txt | 16 +++------------- tests/framework/test_util.h | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/tests/framework/CMakeLists.txt b/tests/framework/CMakeLists.txt index e61825ce..7412b65f 100644 --- a/tests/framework/CMakeLists.txt +++ b/tests/framework/CMakeLists.txt @@ -74,21 +74,11 @@ add_subdirectory(layer) #setup framework_config_temp.h.in in the current binary directory configure_file("${CMAKE_CURRENT_SOURCE_DIR}/framework_config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/framework_config_temp.h.in") -# setup framework_config.h.in using framework_config_temp.h.in as a source +# setup framework_config_$ using framework_config_temp.h.in as a source file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/framework_config_$.h" INPUT "${CMAKE_CURRENT_BINARY_DIR}/framework_config_temp.h.in") -# copy framework_config_$ to the loader build directory -add_custom_command( - PRE_BUILD - COMMAND ${CMAKE_COMMAND} "-E" "copy_if_different" "${CMAKE_CURRENT_BINARY_DIR}/framework_config_$.h" "${CMAKE_CURRENT_BINARY_DIR}/framework_config.h" - VERBATIM - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/framework_config_$.h" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/framework_config.h" - COMMENT "creating framework_config.h file ({event: PRE_BUILD}, {filename: framework_config.h })" - ) -add_custom_target (generate_framework_config DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/framework_config.h") -add_dependencies (generate_framework_config vulkan) -add_dependencies (testing_framework_util generate_framework_config) +# Add a compiler definition for the path to framework_config.h with the correct config +target_compile_definitions(testing_framework_util PUBLIC FRAMEWORK_CONFIG_HEADER="framework_config_$.h") add_library(testing_dependencies STATIC test_environment.cpp test_environment.h) target_link_libraries(testing_dependencies diff --git a/tests/framework/test_util.h b/tests/framework/test_util.h index 0a3ac629..a89c0d70 100644 --- a/tests/framework/test_util.h +++ b/tests/framework/test_util.h @@ -90,7 +90,7 @@ #include #include -#include "framework_config.h" +#include FRAMEWORK_CONFIG_HEADER #if defined(__GNUC__) && __GNUC__ >= 4 #define FRAMEWORK_EXPORT __attribute__((visibility("default"))) -- 2.34.1