[CMake] call already made makefile

SK sk at metrokings.com
Fri Nov 5 14:00:35 EDT 2010


On Thu, Nov 4, 2010 at 9:23 PM, SK <sk at metrokings.com> wrote:
> On Thu, Nov 4, 2010 at 6:09 PM, Alan W. Irwin <irwin at beluga.phys.uvic.ca> wrote:
>> then the custom make command
>> should always be run (since it has no DEPENDS option),
>
> Alan, you are absolutely right!!

No, sorry.  Only if the add_custom_command output does not exist as
other have mentioned too.  My build is so ridiculously complex I'm
fooling myself right and left.  Here's a small test case to show this.
 Hopefully other suggestions on this thread will work.

> cat external_makefile
bar : foo
        touch bar

> cat CMakeLists.txt

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT( makefile_test )

ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/bar
        COMMAND make -f ${CMAKE_CURRENT_SOURCE_DIR}/external_makefile
        COMMENT "Running external makefile"
        )

ADD_CUSTOM_TARGET( external_target ALL
        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bar
        )


After running cmake, we see
> make
[ 0%] Running external makefile <=== Builds bar fine first time
[100%] Built target external_target
> touch foo
> make
[100%] Built target external_target <=== DOES NOT BUILD BAR!!
> rm bar
> make
[ 0%] Running external makefile <=== Builds bar only after delete
[100%] Built target external_target


More information about the CMake mailing list