[CMake] AUTOMOC with files on different folders

Tiago Macarios tiagomacarios at gmail.com
Wed May 11 18:00:12 EDT 2016


Hi Attila,

Thank you for your help. You are right, if I apply the following
modifications it works indeed:

set( proj_HEADER
    include/a.h
)

add_library(proj SHARED ${proj_SOURCE} ${proj_HEADER})

But now I got a second question. Why is adding the header files necessary?
(Sorry the possibly naive question)

I thought that adding the header files to the target was an anti-pattern (
http://voices.canonical.com/jussi.pakkanen/2013/03/26/a-list-of-common-cmake-antipatterns/
). Is it related to moc generating header files during the build? If so why
is it not a problem when everything is on the same folder?

Tiago


On Wed, May 11, 2016 at 12:48 AM, Attila Krasznahorkay <
attila.krasznahorkay at gmail.com> wrote:

> Hi Tiago,
>
> This is one of those cases when you have to declare the header files to
> add_library(...) as well. In that case AUTOMOC should work fine. At least
> it does for us, in a very similar setup.
>
>
> http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/graphics/VP1/VP1Gui/CMakeLists.txt
>
> Cheers,
>             Attila
>
> > On 11 May 2016, at 07:14, Tiago Macarios <tiagomacarios at gmail.com>
> wrote:
> >
> > Hi,
> >
> > I am having trouble using AUTOMOC with a project where header files and
> source files are in different sub-directories. I wrote a detailed stack
> overflow question here:
> >
> http://stackoverflow.com/questions/37151163/cmake-automoc-with-files-on-different-folders
> > and would really appreciate if someone could give me a couple of ideas
> to try out.
> >
> > Thanks,
> > Tiago
> > --
> >
> > Powered by www.kitware.com
> >
> > Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> >
> > Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
> >
> > CMake Support: http://cmake.org/cmake/help/support.html
> > CMake Consulting: http://cmake.org/cmake/help/consulting.html
> > CMake Training Courses: http://cmake.org/cmake/help/training.html
> >
> > Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> >
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/cmake
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160511/3d170e8f/attachment.html>


More information about the CMake mailing list