[CMake] source generator not run because target not marked for build in VS2013 solution configuration

Dirk Steenpass dirk.steenpass at gmail.com
Wed May 28 05:42:28 EDT 2014


Not sure whether the behavior I describe in the following is a bug. To my
limited view it appears as one.

Running CMake with Visual Studio 2013 generator.

Consider a build tree like:

    build/
        top.sln

        alib/
            alib.sln
            alib.vxproj

        aexe/
            aexe.sln
            aexe.vcxproj

The source directs CMake with something like:

    source/alib/CMakeLists.txt

        add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated.c
            COMMAND ${GENERATOR}
            DEPENDS generate.in)

        add_custom_target(run_generator
            DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/generated.c)

        add_library(alib ${SRC})

        add_dependencies(alib run_generator)

    source/aexe/CMakeLists.txt

        add_exe(aexe ${SRC})
        target_link_libraries(aexe alib)


A closer look at the resulting configuration of top.sln and aexe.sln shows:

    top.sln  : 'run_generator' is marked for build
    aexe.sln: 'run_generator' is not marked for build

This means that building aexe.sln will never the generator although the
dependency
    aexe <-- alib <-- run_generator <-- generated.c
is recorded correctly.

On the other hand, when building either top.sln or aexe.vcxproj the
generator will be run when necessary.

I would expect 'run_generator' to be marked for build in aexe.sln (as it is
in top.sln). Right???

All the best, Dirk

-- 
Dirk Steenpass
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140528/0d8fbd08/attachment.html>


More information about the CMake mailing list