Notes |
|
(0022889)
|
Steve King
|
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
|
2010-11-05 08:11
|
|
|
|
(0022906)
|
Steve King
|
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
|
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
|
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. |
|