Cross Compiling GTest without Emulator fails
I am cross compiling a WINCE800 project that uses
include(GoogleTest)
gtest_discover_tests(${PROJECT_NAME}
TEST_PREFIX
${exportname}.
TEST_LIST
${PROJECT_NAME}_targets
)
or
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})
This works fine if I am not cross compiling or have an target emulator, and just run the test executable on the host system. However, the build would fail if I cross compile for a platform that I do not have a emulator for. The reason for this is that
GoogleTest.cmake and GoogleTestAddTests.cmake modules tries so validate/enumerate the added tests by calling --gtest_list_tests
and check for the return value of the process.
If the process cannot be run on the host system, execute_process
will fail, triggering a FATAL_ERROR
.
I understand the behavior but I think this is a flaw in the logic. Clients can cross compile but not always run the executable.
Because these scripts operate in "script mode", they do not have access to the configuration variables CMAKE_CROSSCOMPILING
and CMAKE_CROSSCOMPILING_EMULATOR
. However, should the CROSSCOMPILING
option be ON
, the CROSSCOMPILING_EMULATOR
will be prefixed to the TEST_EXECUTOR
variable.
The minimum change I could think of was to introduce a NO_EMULATOR
value to omit the execute_process call and there for generate a successful build.
The reason there needs to be a an value to the CROSSCOMPILING_EMULATOR
variable is that it would not change existing behavior should any client rely on it.
Thanks!
Related pull request: !2861 (closed)