apfreelance
apfreelance

Reputation: 34

QT moc.exe failes due to file(COPY externLibrary DESTINATION build/)

I have a C++ CMake MinGW_64 msys2 project for setting up a camera with lumisuite and QT6 for a gui, which resulted in the following error

[cmake] CMake Error: AUTOMOC for target mainwindow: Test run of "moc" executable "C:/msys/mingw64/share/qt6/bin/moc.exe" failed.
[cmake] C:/msys/mingw64/share/qt6/bin/moc.exe -h
[cmake] 
[cmake] Exit code 0xc0000139
[cmake] 
[cmake] CMake Generate step failed.  Build files cannot be regenerated correctly.

i could track down the problem by commenting out codeblocks to:

file(COPY "C:/Program Files/Instrument Systems/LumiSuite SDK/bin/" DESTINATION "C:/GIT_REPOS/LumiCamApp/build")

if i comment out this line, then moc.exe works fine. I guess this is a timeout-thing of AUTOMOC, as copying the lumisuite binaries takes too long or something.

The file(COPY [...]) comes from the lumisuite examples.

Just wanted to share my problems with AUTOMOC and QT as i were searching for the root of this bug for 3 days now, maybe someone using QT and another external library (in my case lumisuite) runs into this, too. :) As the cmake error did not give any hints on why moc failed, this took me a long time to figure out that it has nothing to do with qt but with copying the external library instead.

I guess i have to somehow figure out a way to either tell moc to wait longer (until copying is finished) (note here: it takes some time until moc failes and cmake prints the error message, so i guess it is copying?) or i need to copy later. i don't know. i'm quite a newbie with cmakelists scripts, this is the first time for me setting up a whole real-world-problem c++ project from scratch

Upvotes: 0

Views: 424

Answers (1)

apfreelance
apfreelance

Reputation: 34

add_custom_target(lumisuitdlls)

add_custom_command(
        TARGET lumisuitdlls PRE_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory ${dll_directory} ${destination})

add_dependencies(LumiCamApp lumisuitdlls)

solved it for me. It now copies the dll's to build folder pre_build and does not fail to configure anymore due to AUTOMOC.

Upvotes: 0

Related Questions