[cmake-developers] cmake --help-policy CMP0057 MAIN_DEPENDENCY

Nils Gladitz nilsgladitz at gmail.com
Thu Apr 30 11:42:41 EDT 2015


On 29.04.2015 09:11, Nils Gladitz wrote:
> The policy will likely have to be removed or replaced.

I reverted the MAIN_DEPENDENCY specific CMP0057 commits and replaced the 
policy with an unrelated one that is part of my "if-IN_LIST" topic to 
fill the gap.

This leaves the original issues that prompted the creation of CMP0057 
open for now.

Two related but distinct issues are triggered by the following test 
cases with the Makefile generator:

1) The following causes the given custom command to be emitted for both 
the foo and bar target which can lead to parallel build errors:

   cmake_minimum_required(VERSION 3.2)

   file(WRITE test.in)
   file(WRITE dummy.cpp "int main() {}")

   add_custom_command(
       OUTPUT test.out
       COMMAND ${CMAKE_COMMAND} -E echo Hello World
       MAIN_DEPENDENCY test.in
   )

   add_executable(foo dummy.cpp test.in)
   add_executable(bar dummy.cpp test.in)

2) The following causes the compile step for the dummy.cpp source file 
to fail in presence of the custom command:

   cmake_minimum_required(VERSION 3.2)

   file(WRITE dummy.cpp "int main() {}")

   add_custom_command(
       OUTPUT test.out
       COMMAND ${CMAKE_COMMAND} -E echo Hello World
       MAIN_DEPENDENCY dummy.cpp
   )

   add_executable(foo dummy.cpp)

Nils


More information about the cmake-developers mailing list