View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0011407CMakeCMakepublic2010-11-04 19:542011-01-12 07:44
ReporterSteve King 
Assigned ToBrad King 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake-2-8 
Target VersionCMake 2.8.4Fixed in VersionCMake 2.8.4 
Summary0011407: Allow output from add_custom_target() to support external makefiles
DescriptionThere seems to be no satisfactory way to use cmake to drive external Makefiles as a step in a larger build process. This is due to:
1) External makefiles must always run to process their own dependencies which are invisible to CMake.
2) add_custom_target() is a natural choice to drive the external makefile. However, add_custom_target() cannot specify an output.
3) add_custom_command() can specify an output, but does not always run since it cannot see the external dependencies known only to the Makefile.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0022889)
Steve King (reporter)
2010-11-05 01:12

add_custom_command() can be used to drive external makefiles so long as no DEPENDS statement is used. Would be nice if the documentation could explicitly state that removing DEPENDS will cause add_custom_command to always run, mentioning makefiles specifically.
(0022893)
Brad King (manager)
2010-11-05 08:11

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=80edcc6a [^]
(0022906)
Steve King (reporter)
2010-11-05 13:49

My previous comment was wrong. Add_custom_command() does not always run when no DEPENDS statement is specified. So this issue remains open and add_custom_command is not able to drive an external makefile that produces an output.

The follow simple test case demonstrates this problem. For simplicity, this is an in-source build.

> 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 <=== ERROR: DOES NOT BUILD BAR!!
> rm bar
> make
[ 0%] Running external makefile <=== Builds bar only after delete
[100%] Built target external_target
  

This behavior matches Brad's new (and useful) documentation, but does not solve the original problem.
(0022908)
Brad King (manager)
2010-11-05 13:59

I included a statement in the documentation that describes how to make it always build. Just don't create the file listed in the custom command OUTPUT as part of the rule. In your example the "touch bar" breaks it.
(0022925)
Steve King (reporter)
2010-11-05 16:17

Yes, thanks Brad. The solution with the faux output works and sorry for all the gyrations on this. IMHO, the documentation covering this topic is still quite thin, but the key ingredients are at least there.

 Issue History
Date Modified Username Field Change
2010-11-04 19:54 Steve King New Issue
2010-11-05 01:12 Steve King Note Added: 0022889
2010-11-05 08:10 Brad King Status new => assigned
2010-11-05 08:10 Brad King Assigned To => Brad King
2010-11-05 08:11 Brad King Note Added: 0022893
2010-11-05 08:11 Brad King Status assigned => closed
2010-11-05 08:11 Brad King Resolution open => fixed
2010-11-05 13:49 Steve King Note Added: 0022906
2010-11-05 13:49 Steve King Status closed => feedback
2010-11-05 13:49 Steve King Resolution fixed => reopened
2010-11-05 13:59 Brad King Note Added: 0022908
2010-11-05 16:17 Steve King Note Added: 0022925
2010-11-05 16:48 Brad King Status feedback => closed
2010-11-05 16:48 Brad King Resolution reopened => fixed
2011-01-12 07:44 David Cole Fixed in Version => CMake 2.8.4
2011-01-12 07:44 David Cole Target Version => CMake 2.8.4


Copyright © 2000 - 2018 MantisBT Team