-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #18687. Fix execution of tests on Windows
Signed-off-by: Ricardo González Moreno <[email protected]>
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
include(GoogleTest) | ||
|
||
function(gtest_discover_tests TARGET) | ||
if (WIN32) | ||
add_custom_command( | ||
TARGET ${TARGET} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E echo "set(_target_runtime_dlls $<TARGET_RUNTIME_DLLS:${TARGET}>)" > "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_runtime_dlls_$<CONFIG>.cmake" | ||
COMMAND ${CMAKE_COMMAND} -DTARGET=${TARGET} -DCONFIG=$<CONFIG> -DFILE_TO_PROCESS="${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_runtime_dlls_$<CONFIG>.cmake" -P ${CMAKE_SOURCE_DIR}/cmake/testing/generate_google_test_win_wrapper.cmake | ||
COMMAND_EXPAND_LISTS | ||
) | ||
|
||
set(CMAKE_COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_win_wrapper_$<CONFIG>.bat") | ||
endif() | ||
_gtest_discover_tests(${TARGET} ${ARGN}) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
if (NOT DEFINED TARGET) | ||
message(FATAL_ERROR "This scrips needs TARGET variable set") | ||
endif() | ||
if (NOT DEFINED CONFIG) | ||
message(FATAL_ERROR "This scrips needs CONFIG variable set") | ||
endif() | ||
if (NOT DEFINED FILE_TO_PROCESS) | ||
message(FATAL_ERROR "This scrips needs FILE_TO_PROCESS variable set") | ||
endif() | ||
|
||
include(${FILE_TO_PROCESS}) | ||
|
||
set(_path "") | ||
foreach(_runtime_dll ${_target_runtime_dlls}) | ||
cmake_path(GET _runtime_dll PARENT_PATH _runtime_dll_path) | ||
cmake_path(NATIVE_PATH _runtime_dll_path _runtime_dll_path_native) | ||
list(APPEND _path "${_runtime_dll_path_native}") | ||
endforeach() | ||
|
||
list(REMOVE_DUPLICATES _path) | ||
|
||
cmake_path(NATIVE_PATH CMAKE_COMMAND _cmake_command) | ||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_win_wrapper_${CONFIG}.bat" " | ||
@ECHO OFF | ||
set \"PATH=${_path};%PATH%\" | ||
\"${_cmake_command}\" %* | ||
") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters