View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013499CMakeCMakepublic2012-08-30 12:552012-08-31 17:51
ReporterStephen Kelly 
Assigned ToAlex Neundorf 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product VersionCMake 2.8.9 
Target VersionFixed in VersionCMake 2.8.6 
Summary0013499: CMake AUTOMOC creates empty .moc files.
DescriptionWith a simple hello world application automoc is generating empty .moc files:


stephen@hal:~/dev/src/playground/cmake/native{master}$ make
makeobj[0]: Entering directory `/home/stephen/dev/src/playground/cmake/native'
Scanning dependencies of target helloworld_automoc
[ 25%] Automoc for target helloworld
Generating mainwindow.moc
/home/stephen/dev/src/playground/cmake/mainwindow.cpp:8: Note: No relevant classes found. No output generated.
Generating moc_mainwindow.cpp
[ 25%] Built target helloworld_automoc
Scanning dependencies of target helloworld
[ 50%] [ 75%] [100%] Building CXX object CMakeFiles/helloworld.dir/main.cpp.o
Building CXX object CMakeFiles/helloworld.dir/mainwindow.cpp.o
Building CXX object CMakeFiles/helloworld.dir/helloworld_automoc.cpp.o
Linking CXX executable helloworld
[100%] Built target helloworld
makeobj[0]: Leaving directory `/home/stephen/dev/src/playground/cmake/native'
stephen@hal:~/dev/src/playground/cmake/native{master}$ l
CMakeCache.txt CMakeFiles/ cmake_install.cmake helloworld* helloworld_automoc.cpp mainwindow.moc Makefile moc_mainwindow.cpp
stephen@hal:~/dev/src/playground/cmake/native{master}$ wc mainwindow.moc moc_mainwindow.cpp
   0 0 0 mainwindow.moc
  81 242 2351 moc_mainwindow.cpp
  81 242 2351 total

 
stephen@hal:~/dev/src/playground/cmake/native{master}$ cat ../main.cpp

#include <QApplication>
#include "mainwindow.h"

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    MainWindow mw;
    mw.show();

    return app.exec();
}

stephen@hal:~/dev/src/playground/cmake/native{master}$ cat ../mainwindow.cpp


#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
{

}

#include "mainwindow.moc"

stephen@hal:~/dev/src/playground/cmake/native{master}$ cat ../mainwindow.h

#include <QWidget>

class MainWindow : public QWidget
{
    Q_OBJECT
public:
    MainWindow(QWidget *parent = 0);
};

stephen@hal:~/dev/src/playground/cmake/native{master}$ cat ../CMakeLists.txt

cmake_minimum_required(VERSION 2.8)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

find_package(Qt4 REQUIRED)

include_directories(${QT_INCLUDES})

add_executable(helloworld
    main.cpp
    mainwindow.cpp
)
target_link_libraries(helloworld ${QT_QTGUI_LIBRARIES} ${QT_QTCORE_LIBRARIES})
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0030799)
Alex Neundorf (developer)
2012-08-30 16:57

Hmm, what is the problem with this ?
IMO it behaves as it should, and as it is documented.
You include mainwindow.moc, so this file is generated from the cpp file, and empty (since there is nothing to moc in mainwindow.cpp).
Additionally it also checks mainwindow.h, finds the Q_OBJECT, and runs moc on it.
(0030804)
Stephen Kelly (developer)
2012-08-31 04:15

Oops, you're right. Sorry for the noise.
(0030816)
Alex Neundorf (developer)
2012-08-31 17:50

..just for changing resolution to "No change required" ...
(0030817)
Alex Neundorf (developer)
2012-08-31 17:51

Everything's ok, no change required.

 Issue History
Date Modified Username Field Change
2012-08-30 12:55 Stephen Kelly New Issue
2012-08-30 12:55 Stephen Kelly Status new => assigned
2012-08-30 12:55 Stephen Kelly Assigned To => Alex Neundorf
2012-08-30 16:57 Alex Neundorf Note Added: 0030799
2012-08-31 04:15 Stephen Kelly Note Added: 0030804
2012-08-31 04:17 Stephen Kelly Status assigned => resolved
2012-08-31 04:17 Stephen Kelly Fixed in Version => CMake 2.8.6
2012-08-31 04:17 Stephen Kelly Resolution open => fixed
2012-08-31 17:50 Alex Neundorf Note Added: 0030816
2012-08-31 17:50 Alex Neundorf Status resolved => assigned
2012-08-31 17:51 Alex Neundorf Note Added: 0030817
2012-08-31 17:51 Alex Neundorf Status assigned => closed
2012-08-31 17:51 Alex Neundorf Resolution fixed => no change required


Copyright © 2000 - 2018 MantisBT Team