View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0014535 | CMake | (No Category) | public | 2013-10-31 14:47 | 2014-06-02 08:37 | ||||
Reporter | Janne Rönkkö | ||||||||
Assigned To | Stephen Kelly | ||||||||
Priority | normal | Severity | major | Reproducibility | have not tried | ||||
Status | closed | Resolution | fixed | ||||||
Platform | Linux | OS | Archlinux | OS Version | |||||
Product Version | CMake 2.8.12 | ||||||||
Target Version | CMake 2.8.12.1 | Fixed in Version | CMake 2.8.12.1 | ||||||
Summary | 0014535: Definitions Not Defined In Qt Automoc | ||||||||
Description | With CMake 2.8.12 (and with tested git version from commit 8a6e82724c42920855c2348e914636f52a0c55d5) automoc does not set definitions for moc properly. With CMake 2.8.11.2 this problem does not exist. I have created example project that demonstrates the issue. With CMake 2.8.12 (or with the git version I tried) the plugin is not created properly because QT5 define is not set while moc runs. | ||||||||
Steps To Reproduce | $ tar xf example.tar.gz $ mkdir example/build $ cd example/build $ cmake --version cmake version 2.8.11.2 $ cmake .. -DUSE_AUTOMOC=false -- The C compiler identification is GNU 4.8.2 -- The CXX compiler identification is GNU 4.8.2 ... -- Found Qt4: /usr/bin/qmake-qt4 (found version "4.8.5") Not using automoc MocSrc /home/janne/tmp/example/build/moc_PluginImpl.cxx -- Configuring done -- Generating done -- Build files have been written to: /home/janne/tmp/example/build $ make $ ./loadplugin libtestplugin.so Loading plugin from "libtestplugin.so" fileName(): "/home/janne/tmp/example/build/libtestplugin.so" isLoaded(): false err: "Unknown error" Success! $ cmake .. -DUSE_AUTOMOC=true -- The C compiler identification is GNU 4.8.2 -- The CXX compiler identification is GNU 4.8.2 ... -- Found Qt4: /usr/bin/qmake-qt4 (found version "4.8.5") Using automoc -- Configuring done -- Generating done -- Build files have been written to: /home/janne/tmp/example/build $ make $ ./loadplugin libtestplugin.so Loading plugin from "libtestplugin.so" fileName(): "/home/janne/tmp/example/build/libtestplugin.so" isLoaded(): false err: "Unknown error" Success! $ cmake --version cmake version 2.8.12 $ cmake .. -DUSE_AUTOMOC=false -- The C compiler identification is GNU 4.8.2 -- The CXX compiler identification is GNU 4.8.2 -- Found Qt4: /usr/bin/qmake-qt4 (found version "4.8.5") Not using automoc MocSrc /home/janne/tmp/example/build/moc_PluginImpl.cxx -- Configuring done -- Generating done -- Build files have been written to: /home/janne/tmp/example/build $ make $ ./loadplugin libtestplugin.so Loading plugin from "libtestplugin.so" fileName(): "/home/janne/tmp/example/build/libtestplugin.so" isLoaded(): false err: "Unknown error" Success! $ cmake .. -DUSE_AUTOMOC=true -- The C compiler identification is GNU 4.8.2 -- The CXX compiler identification is GNU 4.8.2 -- Found Qt4: /usr/bin/qmake-qt4 (found version "4.8.5") Using automoc -- Configuring done -- Generating done -- Build files have been written to: /home/janne/tmp/example/build $ make $ ./loadplugin libtestplugin.so Loading plugin from "libtestplugin.so" fileName(): "/home/janne/tmp/example/build/libtestplugin.so" isLoaded(): false err: "Unknown error" !! No plugin found. | ||||||||
Additional Information | The issue exists with Qt4 and Qt5. | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | example.tar.gz [^] (2,525 bytes) 2013-10-31 14:47 | ||||||||
Relationships | |
Relationships |
Notes | |
(0034311) Stephen Kelly (developer) 2013-11-02 08:59 |
Your description is confusing. Please describe the problem in terms of the moc command line, if that's where the problem is. |
(0034335) Janne Rönkkö (reporter) 2013-11-02 13:32 |
With CMake 2.8.11.2 the automoc command that is run is (in my case): /opt/cmake-2.8.11.2/bin/cmake -E cmake_automoc /home/janne/tmp/cmake-qt-automoc-defines-bug/cmake-2.8.11.2/CMakeFiles/testplugin_automoc.dir/ And with CMake 2.8.12: /usr/bin/cmake -E cmake_automoc /home/janne/tmp/cmake-qt-automoc-defines-bug/cmake-2.8.12/CMakeFiles/testplugin_automoc.dir/ "" In the directory that is given to automoc command (....CMakeFiles/testplugin_automoc.dir) there is a file AutomocInfo.cmake where is the difference causing the issue I'm seeing: In the CMake 2.8.12 build directory the file contains the following line: set(AM_MOC_COMPILE_DEFINITIONS "") And in the CMake 2.8.11.2 build directory the corresponding line is: set(AM_MOC_COMPILE_DEFINITIONS ";QT4;QT4;QT_NO_DEBUG;QT_GUI_LIB;QT_CORE_LIB") So the automoc does not define the defines when using CMake 2.8.12 as it does with the older CMake version. |
(0034338) Stephen Kelly (developer) 2013-11-03 15:48 |
Ok. Your testcase seems to be still bigger than it should be. See http://sscce.org/ [^] . Remove anything which is not part of showing the problem. Here is my testcase: cmake_minimum_required(VERSION 2.8.11) project(foo) find_package(Qt4 REQUIRED) set(CMAKE_AUTOMOC ON) add_library(foo MODULE foo.cpp) target_link_libraries(foo PUBLIC Qt4::QtCore) it passes with 2.8.12. Please post a minimum change to it that shows the problem. |
(0034339) Jason Haslam (reporter) 2013-11-03 21:31 |
I see this too. The issue for me is that definitions (at least those added with add_definitions) are no longer automatically set in the moc invocation. Here is your minimal sample modified to reproduce the issue: CMakeLists.txt: cmake_minimum_required(VERSION 2.8.11) project(foo) find_package(Qt4 REQUIRED) set(CMAKE_AUTOMOC ON) # This definition expected to be set in moc invocation. add_definitions(-DFOO) include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_library(foo MODULE foo.cpp) target_link_libraries(foo PUBLIC Qt4::QtCore) # Uncomment to work around the issue. #set_target_properties(foo PROPERTIES AUTOMOC_MOC_OPTIONS -DFOO) foo.cpp: #include <QObject> class Foo #ifdef FOO : public QObject #endif { Q_OBJECT }; #include "foo.moc" Without the workaround on the last line the moc invocation fails. In cmake 2.8.11.2 the defines were set automatically. |
(0034340) Stephen Kelly (developer) 2013-11-04 05:46 |
Thanks, that's a better problem description. I've pushed the fix-autogen-definitions topic to fix this issue. |
(0034394) Brad King (manager) 2013-11-05 11:20 |
Re 0014535:0034340: That fix is based on refactored post-2.8.12 infrastructure. To fix this regression in a 2.8.12.x release we need a change based on v2.8.12~2. |
(0034395) Brad King (manager) 2013-11-05 11:40 |
For reference, "git bisect" reports the regression was introduced here: Refactor cmTarget::GetCompileDefinitions to use an out-vector, not a string. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=18412153 [^] |
(0034397) Brad King (manager) 2013-11-05 12:07 |
Steve constructed a fix applicable to 2.8.12: Automoc: Add directory-level COMPILE_DEFINITIONS to command line http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a1b9465b [^] It will be included in 2.8.12.1. |
(0036005) Robert Maynard (manager) 2014-06-02 08:37 |
Closing resolved issues that have not been updated in more than 4 months. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2013-10-31 14:47 | Janne Rönkkö | New Issue | |
2013-10-31 14:47 | Janne Rönkkö | File Added: example.tar.gz | |
2013-11-02 08:59 | Stephen Kelly | Assigned To | => Stephen Kelly |
2013-11-02 08:59 | Stephen Kelly | Status | new => assigned |
2013-11-02 08:59 | Stephen Kelly | Note Added: 0034311 | |
2013-11-02 09:00 | Stephen Kelly | Status | assigned => feedback |
2013-11-02 13:32 | Janne Rönkkö | Note Added: 0034335 | |
2013-11-02 13:32 | Janne Rönkkö | Status | feedback => assigned |
2013-11-03 15:48 | Stephen Kelly | Note Added: 0034338 | |
2013-11-03 21:31 | Jason Haslam | Note Added: 0034339 | |
2013-11-04 05:46 | Stephen Kelly | Note Added: 0034340 | |
2013-11-05 11:20 | Brad King | Note Added: 0034394 | |
2013-11-05 11:40 | Brad King | Note Added: 0034395 | |
2013-11-05 11:47 | Brad King | Target Version | => CMake 2.8.12.1 |
2013-11-05 12:07 | Brad King | Note Added: 0034397 | |
2013-11-05 13:36 | Brad King | Status | assigned => resolved |
2013-11-05 13:36 | Brad King | Resolution | open => fixed |
2013-11-05 13:36 | Brad King | Fixed in Version | => CMake 2.8.12.1 |
2014-06-02 08:37 | Robert Maynard | Note Added: 0036005 | |
2014-06-02 08:37 | Robert Maynard | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |