[cmake-developers] [CMake 0014021]: Generated .sln files for MS Visual Studio 2008 do not apply Automoc to the top-level dependencies of a sub-folder (library)

Mantis Bug Tracker mantis at public.kitware.com
Mon Mar 18 07:39:05 EDT 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=14021 
====================================================================== 
Reported By:                Piotr Pietraszkiewicz
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14021
Category:                   CMake
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-03-18 07:39 EDT
Last Modified:              2013-03-18 07:39 EDT
====================================================================== 
Summary:                    Generated .sln files for MS Visual Studio 2008 do
not apply Automoc to the top-level dependencies of a sub-folder (library)
Description: 
In a subdirectory of my project I build a library (sub) which depends on
another library found in the top level directory (mainwindow).

My subfolder's sub/CMakeLists.txt:
~~~~
project ( sub )

include_directories("${CMAKE_SOURCE_DIR}")
add_library(sub SubWindow.h)
target_link_libraries(sub ${Qt4_LIBRARIES} mainlib mainwindow)
~~~~

My top level CMakeLists.txt:
~~~~
[..]
set(CMAKE_AUTOMOC TRUE)

[..]
ADD_SUBDIRECTORY(sub)

include_directories(. sub)

add_library(mainwindow MainWindow.h)
target_link_libraries(mainwindow ${Qt4_LIBRARIES})
~~~~

Both SubWindow.h and MainWindow.h are tagged with Q_OBJECT and thus need to be
processed by automoc. SubWindow.h depends on MainWindow.h.

Configuring the project on Cygwin/Linux environments and invoking "make" in the
"sub" sub-folder yields:
~~~~
~/src/caamtest/cygwin_build/sub: 
$ make
Scanning dependencies of target mainwindow_automoc
[ 14%] Automoc for target mainwindow
Generating moc_MainWindow.cpp
[ 14%] Built target mainwindow_automoc
Scanning dependencies of target mainwindow
[ 28%] Building CXX object CMakeFiles/mainwindow.dir/mainwindow_automoc.cpp.o
Linking CXX static library libmainwindow.a
[ 28%] Built target mainwindow
Scanning dependencies of target sub_automoc
[ 42%] Automoc for target sub
Generating moc_SubWindow.cpp
[ 42%] Built target sub_automoc
Scanning dependencies of target mainlib_automoc
[ 57%] Automoc for target mainlib
[ 57%] Built target mainlib_automoc
Scanning dependencies of target mainlib
[ 71%] Building CXX object CMakeFiles/mainlib.dir/mainlib.cpp.o
[ 85%] Building CXX object CMakeFiles/mainlib.dir/mainlib_automoc.cpp.o
Linking CXX static library libmainlib.a
[ 85%] Built target mainlib
Scanning dependencies of target sub
[100%] Building CXX object sub/CMakeFiles/sub.dir/sub_automoc.cpp.o
Linking CXX static library libsub.a
[100%] Built target sub
~~~~

All fine, note that Automoc was started for both "mainwindow" and "sub".

In contrast, configuring the project on Windows environment (for MS VS 2008) and
building "sub" with devenv yields:
~~~~
D:\[..]\src\caamtest\windows_build\sub>devenv sub.sln /build

Microsoft (R) Visual Studio Version 9.0.30729.1.
Copyright (C) Microsoft Corp. Alle Rechte vorbehalten.
1>------ Erstellen übersprungen: Projekt: mainwindow_automoc, Konfiguration:
Debug Win32 ------
1>Für diese Projektmappenkonfiguration wurde kein zu erstellendes Projekt
ausgewählt.
2>------ Erstellen übersprungen: Projekt: mainlib_automoc, Konfiguration: Debug
Win32 ------
2>Für diese Projektmappenkonfiguration wurde kein zu erstellendes Projekt
ausgewählt.
3>------ Erstellen gestartet: Projekt: sub_automoc, Konfiguration: Debug Win32
------
3>Automoc for target sub
[..]
~~~~

"Erstellen übersprungen" means "Building skipped". The automoc for
"mainwindow" is not started.

Inspecting the configuration of the sub.sln with:
  devenv sub.sln -> right click on "Project map" (Projektmappe "sub") ->
   Configuration 
reveals that "mainlib_automoc" target is present but disabled (see screen-shot:
subsln_config.png). 

I attach my sample project that helps to reproduce the problem.

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-03-18 07:39 Piotr PietraszkiewiczNew Issue                                 
  
2013-03-18 07:39 Piotr PietraszkiewiczFile Added: caamtest.tgz                  
  
======================================================================




More information about the cmake-developers mailing list