Skip to content

Commit b8a1d46

Browse files
committed
tests: Add support of testing on static Qt6 builds
CMakeLists.txt: - Remove USE_STATIC_RT_VKCONFIG option - Use set_property to set MSVC_RUNTIME_LIBRARY property layersvt/test/CMakeLists.txt vkconfig_core/test/CMakeLists.txt - Use set_property to set MSVC_RUNTIME_LIBRARY property vkconfig_cmd/CMakeLists.txt - Remove use of USE_STATIC_RT_VKCONFIG vkconfig_core/CMakeLists.txt - Remove use of USE_STATIC_RT_VKCONFIG vkconfig_core/test/CMakeLists.txt - Remove use of USE_STATIC_RT_VKCONFIG - Cleanup and formatting
1 parent e180cbf commit b8a1d46

8 files changed

Lines changed: 30 additions & 49 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
version: '5.15.*'
7777
- run: cmake -S . -B build -D UPDATE_DEPS=ON -D BUILD_TESTS=ON -D RUN_ON_GITHUB=ON -D CMAKE_BUILD_TYPE=Debug -G Ninja
7878
- run: cmake --build build
79-
- run: ctest --output-on-failure --test-dir build
79+
- run: ctest --output-on-failure --test-dir build --timeout 10
8080
- run: cmake --install build --prefix build/install
8181

8282
windows:
@@ -91,7 +91,7 @@ jobs:
9191
version: '6.8.2'
9292
- run: cmake -S . -B build -D UPDATE_DEPS=ON -D BUILD_TESTS=ON -D RUN_ON_GITHUB=ON -D CMAKE_BUILD_TYPE=Debug -G Ninja
9393
- run: cmake --build build
94-
- run: ctest --output-on-failure --test-dir build
94+
- run: ctest --output-on-failure --test-dir build --timeout 10
9595
- run: cmake --install build --prefix build/install
9696

9797
android:

CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ find_package(VulkanUtilityLibraries REQUIRED CONFIG)
4242
find_package(valijson REQUIRED CONFIG)
4343
find_package(Qt6 COMPONENTS Core Gui Widgets Network QUIET)
4444
find_package(Qt5 COMPONENTS Core Gui Widgets Network QUIET)
45+
if(Qt6_FOUND)
46+
get_target_property(QT_TARGET_TYPE Qt6::Core TYPE)
47+
elseif(Qt5_FOUND)
48+
get_target_property(QT_TARGET_TYPE Qt5::Core TYPE)
49+
endif()
4550

4651
option(BUILD_TESTS "Build tests")
4752
option(RUN_ON_GITHUB "Build only tests that can run on Github" OFF)
48-
option(USE_STATIC_RT_VKCONFIG "Use static C runtime for VkConfig when linking against static Qt libraires")
4953

5054
if(BUILD_TESTS)
5155
enable_testing()
@@ -130,5 +134,11 @@ if(BUILD_LAYERMGR)
130134
add_subdirectory(vkconfig_core)
131135
add_subdirectory(vkconfig_cmd)
132136
add_subdirectory(vkconfig_gui)
137+
138+
if(WIN32 AND BUILD_TESTS AND (QT_TARGET_TYPE STREQUAL STATIC_LIBRARY))
139+
set_property(TARGET vkconfig-gui vkconfig-cmd vkconfig-core PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
140+
message(STATUS "vkconfig will link against static runtime")
141+
endif()
142+
133143
endif()
134144
endif()

layersvt/test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ function(LayerTest NAME)
4141
)
4242

4343
set_target_properties(${TEST_NAME} PROPERTIES FOLDER "VkLayer_${NAME}/Test")
44+
45+
if(WIN32 AND (QT_TARGET_TYPE STREQUAL STATIC_LIBRARY))
46+
set_property(TARGET ${TEST_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
47+
endif()
4448
endfunction()
4549

4650
set(LAYER_TEST_FILES api_dump monitor screenshot)

scripts/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ if (UPDATE_DEPS)
6060
list(APPEND update_dep_command "--skip-existing-install")
6161
endif()
6262

63+
if(WIN32 AND BUILD_TESTS AND (QT_TARGET_TYPE STREQUAL STATIC_LIBRARY))
64+
list(APPEND update_dep_command "--gtest-force-shared-crt=OFF")
65+
endif()
66+
6367
list(APPEND cmake_vars "CMAKE_TOOLCHAIN_FILE")
6468
list(APPEND cmake_vars "CMAKE_SYSTEM_PROCESSOR")
6569

vkconfig_cmd/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ source_group("Docs Files" FILES ${FILES_DOCS})
2828

2929
set(FILES_ALL ${FILES_UI} ${FILES_SOURCE} ${FILES_HEADER} ${FILES_DOCS})
3030

31-
if(WIN32)
32-
# Use the static runtime library? This is for special builds of Vulkan Configurator only
33-
if(USE_STATIC_RT_VKCONFIG)
34-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
35-
message(STATUS "vkconfig-cmd will link against static runtime")
36-
endif()
37-
endif()
38-
3931
if(NOT APPLE)
4032
if (NOT DEFINED CMAKE_INSTALL_BINDIR)
4133
include(GNUInstallDirs)

vkconfig_core/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ set(FILES_RESOURCES
3232

3333
set(FILES_ALL ${FILES_SOURCE} ${FILES_HEADER} ${FILES_RESOURCES})
3434

35-
if(WIN32)
36-
# Use the static runtime library? This is for special builds of Vulkan Configurator only
37-
if(USE_STATIC_RT_VKCONFIG)
38-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
39-
message(STATUS "vkconfig-core will link against static runtime")
40-
endif()
41-
endif()
42-
4335
add_library(vkconfig-core STATIC ${FILES_ALL})
4436
target_compile_options(vkconfig-core PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/MP>)
4537
target_compile_definitions(vkconfig-core PRIVATE QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT)

vkconfig_core/test/CMakeLists.txt

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ if (NOT DEFINED CMAKE_INSTALL_BINDIR)
2020
include(GNUInstallDirs)
2121
endif()
2222

23-
if(WIN32)
24-
# Use the static runtime library? This is for special builds of Vulkan Configurator only
25-
if(USE_STATIC_RT_VKCONFIG)
26-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
27-
message(STATUS "vkconfig-core will link against static runtime")
28-
endif()
29-
endif()
30-
3123
function(vkConfigTest NAME)
3224
set(TEST_FILE ./${NAME}.cpp)
3325
set(TEST_NAME vkconfig_${NAME})
@@ -39,25 +31,20 @@ function(vkConfigTest NAME)
3931

4032
add_executable(${TEST_NAME} ${TEST_FILE} ${FILES_JSON} ${FILES_TEXT} resources.qrc)
4133
set_target_properties(${TEST_NAME} PROPERTIES FOLDER "vkconfig/tests")
42-
if(Qt6_FOUND)
43-
target_link_libraries(${TEST_NAME} vkconfig-core Vulkan::LayerSettings GTest::gtest GTest::gtest_main Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Network)
44-
elseif(Qt5_FOUND)
45-
target_link_libraries(${TEST_NAME} vkconfig-core Vulkan::LayerSettings GTest::gtest GTest::gtest_main Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Network)
46-
endif()
47-
48-
if(WIN32)
49-
# Use the static runtime library?
50-
if(USE_STATIC_CRT_VKFG)
51-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
52-
message(STATUS "vkconfig tests will link against static runtime")
53-
endif()
54-
55-
target_link_libraries(${TEST_NAME} Cfgmgr32)
34+
if(Qt6_FOUND)
35+
target_link_libraries(${TEST_NAME} vkconfig-core Vulkan::LayerSettings GTest::gtest GTest::gtest_main Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Network)
36+
elseif(Qt5_FOUND)
37+
target_link_libraries(${TEST_NAME} vkconfig-core Vulkan::LayerSettings GTest::gtest GTest::gtest_main Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Network)
5638
endif()
39+
5740
if (RUN_ON_GITHUB)
5841
target_compile_definitions(${TEST_NAME} PRIVATE RUN_ON_GITHUB)
5942
endif()
6043

44+
if(WIN32 AND (QT_TARGET_TYPE STREQUAL STATIC_LIBRARY))
45+
set_property(TARGET ${TEST_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
46+
endif()
47+
6148
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
6249
endfunction()
6350

vkconfig_gui/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ source_group("Docs Files" FILES ${FILES_DOCS})
1616

1717
set(FILES_ALL ${FILES_UI} ${FILES_SOURCE} ${FILES_HEADER} ${FILES_DOCS} resources.qrc)
1818

19-
if(WIN32)
20-
# Use the static runtime library? This is for special builds of Vulkan Configurator only
21-
if(USE_STATIC_RT_VKCONFIG)
22-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
23-
message(STATUS "vkconfig-gui will link against static runtime")
24-
endif()
25-
endif()
26-
2719
if(NOT APPLE)
2820
if (NOT DEFINED CMAKE_INSTALL_BINDIR)
2921
include(GNUInstallDirs)

0 commit comments

Comments
 (0)