MantisBT - CMake
View Issue Details
0013499CMakeCMakepublic2012-08-30 12:552012-08-31 17:51
Stephen Kelly 
Alex Neundorf 
normalminoralways
closedno change required 
CMake 2.8.9 
CMake 2.8.6 
0013499: CMake AUTOMOC creates empty .moc files.
With 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})
No tags attached.
Issue History
2012-08-30 12:55Stephen KellyNew Issue
2012-08-30 12:55Stephen KellyStatusnew => assigned
2012-08-30 12:55Stephen KellyAssigned To => Alex Neundorf
2012-08-30 16:57Alex NeundorfNote Added: 0030799
2012-08-31 04:15Stephen KellyNote Added: 0030804
2012-08-31 04:17Stephen KellyStatusassigned => resolved
2012-08-31 04:17Stephen KellyFixed in Version => CMake 2.8.6
2012-08-31 04:17Stephen KellyResolutionopen => fixed
2012-08-31 17:50Alex NeundorfNote Added: 0030816
2012-08-31 17:50Alex NeundorfStatusresolved => assigned
2012-08-31 17:51Alex NeundorfNote Added: 0030817
2012-08-31 17:51Alex NeundorfStatusassigned => closed
2012-08-31 17:51Alex NeundorfResolutionfixed => no change required

Notes
(0030799)
Alex Neundorf   
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   
2012-08-31 04:15   
Oops, you're right. Sorry for the noise.
(0030816)
Alex Neundorf   
2012-08-31 17:50   
..just for changing resolution to "No change required" ...
(0030817)
Alex Neundorf   
2012-08-31 17:51   
Everything's ok, no change required.