On Mon, May 10, 2010 at 17:28, Tyler Roscoe <ty...@cryptio.net> wrote:
> Let's keep this on the list in case it helps someone else.
>
> On Fri, May 07, 2010 at 10:27:16PM +0100, Magnus Therning wrote:
>> On 07/05/10 17:24, Tyler Roscoe wrote:
>> > On Fri, May 07, 2010 at 04:41:23PM +0100, Magnus Therning wrote:
>> >>>        add_custom_command (TARGET ${PROJECT_NAME}
>> >>>            POST_BUILD
>> >>>            # Call the runner script directly. By doing it this way, all 
>> >>> the
>> >>>            # unit tests in the executable run at once. If we call CTest
>> >>>            # here (like we do for the _runtest target), the script (and
>> >>>            # thus the python interpreter) is invoked once for each test 
>> >>> in
>> >>>            # the executable, which is slower than calling the script 
>> >>> once.
>> >>>            COMMAND ${PYTHON_EXECUTABLE} ${${PROJECT_NAME}_TESTRUNNER} 
>> >>> ${CMAKE_CFG_INTDIR} --gtest_print_time
>> >>>        )
>> >>
>> >> One thing though, it seems the command is run *always* irrespective of
>> >> whether the target is built or not.  That doesn't seem to square up
>> >> with the text in the man page:
>> >
>> > Works For Me. I only see unit test runs if the library in question is
>> > recompiled or relinked. What version of CMake are you using?
>>
>> 2.8
>>
>> What kind of target is ${PROJECT_NAME}?
>>
>> I used a target created with add_custom_target, so maybe that's the cause of 
>> it.
>
> I think all the targets in our project which use this post-build step
> are libraries or executables.
>
> If your target is a custom_target that always runs (which, as noted in
> the docs, custom_targets sometimes do) then of course the post-build
> step will also always run.

I'm still having problems with this.

I put together this:

    project( test-post-build NONE )
    cmake_minimum_required( VERSION 2.8 )

    set( output ${CMAKE_CURRENT_BINARY_DIR}/foo )
    add_custom_command( OUTPUT ${output}
        COMMAND touch ${output}
        COMMENT "Touching foo"
        )
    add_custom_target( foo.build ALL DEPENDS ${output} )

    add_custom_command( TARGET ${output}
        POST_BUILD
        COMMAND echo "POST_BUILD ${output}"
        )

    add_custom_command( TARGET foo.build
        POST_BUILD
        COMMAND echo "POST_BUILD foo.build"
        )

Based on your description above I expected this behaviour:

    % cmake ..
    -- Configuring done
    -- Generating done
    -- Build files have been written to:
/home/magnus/Play/test/cmake/post_build/_build
    % make
    Scanning dependencies of target foo.build
    [  0%] Touching foo
    POST_BUILD /home/magnus/Play/test/cmake/post_build/_build/foo
    POST_BUILD foo.build
    [100%] Built target foo.build
    % make
    POST_BUILD foo.build
    [100%] Built target foo.build

However, that's not the case.  I only ever see the 'POST_BUILD foo.build'
printed.  So, what target can I use to get the desired behaviour of the
POST_BUILD only being run after an actual build?

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to