[CMake] qt+cmake != qt+qmake on mac os x

Evgeniy Dushistov dushistov at gmail.com
Sun May 8 10:33:27 EDT 2016


Hi,

I created simple hello world with qt5 (5.6) using  cmake 3.5.2:

set(test_app_UIS mainwin.ui)
set(test_app_MOC_HDRS mainwin.hpp)
qt5_wrap_ui(test_app_UIS_H ${test_app_UIS})
qt5_wrap_cpp(test_app_MOC_SRCS ${test_app_MOC_HDRS})
add_executable(test_app ${test_app_UIS_H} ${test_app_MOC_SRCS}
${test_app_MOC_HDRS} mainwin.cpp main.cpp)
target_link_libraries(test_app Qt5::Widgets)

it builds and I  can run it, but there is strange bug:

after start I can not access menu, but if I give focus to another application,
and then return back to test_app it is possible to open menu.

I build the same application with qmake and bug disappear.

the difference was how qmake and cmake place executables inside build directory:

qmake put binary inside test_app.app directory, with content like:
Info.plist MacOS PkgInfo Resources

cmake put binary in the same way as on linux - just binary test_app

So, to work with cmake + qt on mac I have write some special cmake
with pre_build hook to generate suitable structure? Or there is more
convenient way to resolve this problem?


More information about the CMake mailing list