[CMake] 'AUTOMOC' feature skips sources of executable targets?
Rolf Eike Beer
eike at sf-mail.de
Tue Apr 30 02:40:06 EDT 2013
Haroogan wrote:
> On 29-Apr-13 23:27, Alexander Neundorf wrote:
> > On Monday 29 April 2013, Haroogan wrote:
> >> Have a look at my post on StackOverflow
> >> <http://stackoverflow.com/questions/16286872/cmake-automoc-feature-skips-> >> so
> >> urces-of-executable-targets> for details.
> >> <http://stackoverflow.com/questions/16286872/cmake-automoc-feature-skips-> >> so
> >> urces-of-executable-targets>
> >
> > can you please create a small testcase and post it here, or create an
> > entry on http://public.kitware.com/Bug and attach it there ?
> >
> > It should work.
> I've found the cause, and I think that's very confusing behavior. I'll
> try to do my best explaining it.
>
> Let's begin with top 'CMakeLists.txt':
>
> ...
>
> set(CMAKE_INCLUDE_CURRENT_DIR ON)
> set(CMAKE_AUTOMOC ON)
>
> ...
>
> # NOTE: Order matters (the most independent ones go first)
> # because some libraries expose variables through cache (see below).
> add_subdirectory(components/B)
> add_subdirectory(components/A)
>
> add_subdirectory(components/Executable)
>
> So imagine that we have the 'FindMyPrecious.cmake' custom CMake module
> to locate 3rd party framework "MyPrecious":
>
> find_package(Qt4
> 4.7.4
> COMPONENTS QtCore
> QtGui
> QtXml
> REQUIRED)
>
> find_path(MyPrecious_INCLUDE_DIR...)
>
> find_library(MyPrecious_LIBRARY_DEBUG...)
>
> find_library(MyPrecious_LIBRARY_RELEASE...)
>
> set(QT_DEFINITIONS ${QT_DEFINITIONS}
> -DQT_CORE_LIB
> -DQT_GUI_LIB
> -DQT_XML_LIB)
>
> if (CMAKE_BUILD_TYPE MATCHES [Dd][Ee][Bb][Uu][Gg])
> set(QT_DEFINITIONS ${QT_DEFINITIONS}
> -DQT_DEBUG)
> else ()
> set(QT_DEFINITIONS ${QT_DEFINITIONS}
> -DQT_NO_DEBUG)
> endif ()
>
> set(MyPrecious_DEFINITIONS ${QT_DEFINITIONS})
>
> set(MyPrecious_INCLUDE_DIRS ${MyPrecious_INCLUDE_DIR}
> ${QT_INCLUDE_DIR}
> ${QT_QTCORE_INCLUDE_DIR}
> ${QT_QTGUI_INCLUDE_DIR}
> ${QT_QTXML_INCLUDE_DIR})
>
> set(MyPrecious_LIBRARY debug ${MyPrecious_LIBRARY_DEBUG}
> optimized ${MyPrecious_LIBRARY_RELEASE})
cmake --help-module SelectLibraryConfigurations
> # -------------------------------
> # ATTENTION: Theoretically, I don't have to add the line below.
> # -------------------------------
> # find_package(MyPrecious REQUIRED)
You have to. If you don't the non-cached variables like QT_VERSION* are not
present in this scope. No Qt, no automoc. And everything else may only work by
pure luck.
Also you should read the warning about file(GLOB) in the documentation.
Eike
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130430/b6627b8c/attachment.pgp>
More information about the CMake
mailing list