[CMake] errors with add_custom_command and add_custom_target

Petr Kmoch petr.kmoch at gmail.com
Tue Jan 26 03:43:49 EST 2016


Hi, Vania.

You should remove this line:

set_property(SOURCE ${GEN_SOURCES} PROPERTY GENERATED )

CMake will mark the files as generated automatically.

What your line is actually doing is setting them as *not* generated,
because you didn't pass any argument to set the property to, so it's
implicitly unset. What you probably wanted would have been this:

set_property(SOURCE ${GEN_SOURCES} PROPERTY GENERATED TRUE)

But again, remove the line altogether, it's unnecessary.

You should also remove the quotes from your `add_library` call. The way you
have it would look for a single file named "A.cc;B.cc;C.cc X.cc;Y.cc;Z.cc".

Petr

On Tue, Jan 26, 2016 at 9:36 AM, Vania Joloboff <vania.joloboff at inria.fr>
wrote:

> Hi
>
> I have a generator that generates some, but not all of the source files.
> My understanding was that I should use add_custom_command for that
>
> When I do
> set(EXIST_SOURCES A.cc B.cc C.cc)
> set(GEN_SOURCES X.cc Y.cc Z.cc)
> add_custom_command(OUTPUT ${GEN_SOURCES}
>                        COMMAND generator
>                        MAIN_DEPENDENCY gendir/generator   )
> set_property(SOURCE ${GEN_SOURCES} PROPERTY GENERATED )
> add_library(mylib OBJECT "${EXIST_SOURCES} ${GEN_SOURCES}" )
>
> I get error "Cannot find source file : X.cc"
>
> So, I tried
>
> set(EXIST_SOURCES A.cc B.cc C.cc)
> set(GEN_SOURCES X.cc Y.cc Z.cc)
> add_custom_target(generate
>               COMMAND generator
>               COMMENT "Generate"
>               DEPENDS gendir/generator   )
> set_property(SOURCE ${GEN_SOURCES} PROPERTY GENERATED )
> add_library(mylib OBJECT "${EXIST_SOURCES} ${GEN_SOURCES}" )
> add_dependencies(mylib generate)
>
> I get same error "Cannot find source file : X.cc"
>
> I just don't get it...
>
> Vania
>
> --
>
> 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/20160126/f30557c9/attachment.html>


More information about the CMake mailing list