CMAKE_CROSSCOMPILING_EMULATOR breaks add_custom_command on imported targets
Importing an external executable via
add_executable(test_gen IMPORTED)
set_property(TARGET test_gen PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/build/test_gen")
And using it on a custom command with:
add_custom_command(OUTPUT test.c COMMAND test_gen)
And invoking cmake with -DCMAKE_TOOLCHAIN_FILE=/path/to/w64-mingw32-toolchain.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/path/to/wine/or/anything
causes the name of the executable to be added as an additional argument (at least with Makefile and Ninja generators):
test.c:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold --progress-dir=/home/ennio/cmake_test/test/build-mingw/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Generating test.c"
../build/test_gen test_gen
Notice test_gen
appended after ../build/test_gen
.
Here is an SSCCE.
Using
get_target_property(somevar test_gen IMPORTED_LOCATION)
add_custom_command(OUTPUT test.c COMMAND ${somevar})
instead, or removing the DCMAKE_CROSSCOMPILING_EMULATOR
directive works as expected. Notice that the cross-compiling emulator is not actually used in this context. CMake version is 3.6.1.
Background:
I am trying to cross-compile the Kf5 framework on archlinux using mingw. uic
, lconvert
and possibly other Qt-related commands fail due to this issue.