Re: [CMake] DEPENDS parameter of add_custom_target

2019-10-07 Thread Craig Scott
On Mon, Oct 7, 2019 at 11:21 PM Setzer Sebastian (CM-CI2/ECS2) <
sebastian.set...@de.bosch.com> wrote:

> Hi Craig,
>
> On Mon, 7. Oct 2019 12:56 Craig Scott wrote:
> > As it happens, I just updated the docs for these in the last day or so.
>
> You mean you updated the docs of the two commands, but you did not update
> the docs of the DEPENDS parameter, right?
>

Yes, sorry if that was only partially related to your original query.
Fred's follow-up makes it clearer that the wording of a few sections for
these two commands probably need some improvement (that will be separate to
the merge request I linked to).



> > There is a difference between the two, but it's subtle and specific to
> the sort of scenario I mentioned in that issue comment.
>
> So the manual for the DEPENDS parameter of add_custom_target is outdated,
> but fixing it is not as easy as copying it from add_custom_command.
>

I'll defer a response on whether it is outdated or not, but I would expect
different text to be required for the two commands because they do have
different behaviours.



From: Craig Scott 
> Sent: Montag, 7. Oktober 2019 12:56
> To: Setzer Sebastian (CM-CI2/ECS2) 
> Cc: cmake@cmake.org
> Subject: Re: [CMake] DEPENDS parameter of add_custom_target
>
>
>
> On Mon, Oct 7, 2019 at 9:32 PM Setzer Sebastian (CM-CI2/ECS2) via CMake
> <mailto:cmake@cmake.org> wrote:
> Dear list,
> The manual says:
> https://cmake.org/cmake/help/latest/command/add_custom_target.html
> Reference files and outputs of custom commands created with
> add_custom_command() command calls in the same directory (CMakeLists.txt
> file). They will be brought up to date when the target is built.
> Use the add_dependencies() command to add dependencies on other targets.
>
> This is different from what the manual of add_custom_command says, and
> would be surprising for all users who only read the manual of
> add_custom_command and then think they know what the parameter means for
> add_custom_target.
>
> But on the other hand, when I test with this:
> --
> cmake_minimum_required (VERSION 3.14)
> project(dependency_test LANGUAGES)
>
> add_custom_target(T1
>   COMMAND echo T1
>   )
> add_custom_target(T2
>   COMMAND echo T2
>   DEPENDS T1
>   )
>
> # cmake -GNinja -B build .
> # ninja T2
> --
> Then T1 and T2 are built, so contrary to what the manual says, it seems to
> work.
>
> Is the manual just outdated (Maybe behavior has changed and only manual
> for add_custom_command has been updated)?
> Should it be the same as for add_custom_command, or are there really some
> differences?
>
> As it happens, I just updated the docs for these in the last day or so.
> You can find it in the not-yet-merged merge request here:
>
> https://gitlab.kitware.com/cmake/cmake/merge_requests/3891
>
> I wrote an explanation of the specific behavior of the dependencies in the
> associated issue here:
>
> https://gitlab.kitware.com/cmake/cmake/issues/19771#note_635547
>
> There is a difference between the two, but it's subtle and specific to the
> sort of scenario I mentioned in that issue comment.
>

-- 
Craig Scott
Melbourne, Australia
https://crascit.com

Get the hand-book for every CMake user: Professional CMake: A Practical
Guide <https://crascit.com/professional-cmake/>
Consulting services (CMake, C++, build/release processes):
https://crascit.com/services
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

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


Re: [CMake] DEPENDS parameter of add_custom_target

2019-10-07 Thread Setzer Sebastian (CM-CI2/ECS2) via CMake
Hi Craig,

On Mon, 7. Oct 2019 12:56 Craig Scott wrote:
> As it happens, I just updated the docs for these in the last day or so.

You mean you updated the docs of the two commands, but you did not update the 
docs of the DEPENDS parameter, right?

> There is a difference between the two, but it's subtle and specific to the 
> sort of scenario I mentioned in that issue comment.

So the manual for the DEPENDS parameter of add_custom_target is outdated, but 
fixing it is not as easy as copying it from add_custom_command.

Regards,
Sebastian
 

From: Craig Scott  
Sent: Montag, 7. Oktober 2019 12:56
To: Setzer Sebastian (CM-CI2/ECS2) 
Cc: cmake@cmake.org
Subject: Re: [CMake] DEPENDS parameter of add_custom_target



On Mon, Oct 7, 2019 at 9:32 PM Setzer Sebastian (CM-CI2/ECS2) via CMake 
<mailto:cmake@cmake.org> wrote:
Dear list,
The manual says:
https://cmake.org/cmake/help/latest/command/add_custom_target.html
Reference files and outputs of custom commands created with 
add_custom_command() command calls in the same directory (CMakeLists.txt file). 
They will be brought up to date when the target is built.
Use the add_dependencies() command to add dependencies on other targets.

This is different from what the manual of add_custom_command says, and would be 
surprising for all users who only read the manual of add_custom_command and 
then think they know what the parameter means for add_custom_target.

But on the other hand, when I test with this:
--
cmake_minimum_required (VERSION 3.14)
project(dependency_test LANGUAGES)

add_custom_target(T1
                  COMMAND echo T1
                  )
add_custom_target(T2
                  COMMAND echo T2
                  DEPENDS T1
                  )

# cmake -GNinja -B build .
# ninja T2
--
Then T1 and T2 are built, so contrary to what the manual says, it seems to work.

Is the manual just outdated (Maybe behavior has changed and only manual for 
add_custom_command has been updated)?
Should it be the same as for add_custom_command, or are there really some 
differences?

As it happens, I just updated the docs for these in the last day or so. You can 
find it in the not-yet-merged merge request here:

https://gitlab.kitware.com/cmake/cmake/merge_requests/3891

I wrote an explanation of the specific behavior of the dependencies in the 
associated issue here:

https://gitlab.kitware.com/cmake/cmake/issues/19771#note_635547

There is a difference between the two, but it's subtle and specific to the sort 
of scenario I mentioned in that issue comment.

-- 
Craig Scott
Melbourne, Australia
https://crascit.com

Get the hand-book for every CMake user: https://crascit.com/professional-cmake/
Consulting services (CMake, C++, build/release processes): 
https://crascit.com/services
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

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


Re: [CMake] DEPENDS parameter of add_custom_target

2019-10-07 Thread Fred Baksik


On Mon, Oct 7, 2019, at 6:55 AM, Craig Scott wrote:
> 
> 
> On Mon, Oct 7, 2019 at 9:32 PM Setzer Sebastian (CM-CI2/ECS2) via CMake 
>  wrote:
>> Dear list,
>>  The manual says:
>> https://cmake.org/cmake/help/latest/command/add_custom_target.html
>>  Reference files and outputs of custom commands created with 
>> add_custom_command() command calls in the same directory (CMakeLists.txt 
>> file). They will be brought up to date when the target is built.
>>  Use the add_dependencies() command to add dependencies on other targets.
>> 
>>  This is different from what the manual of add_custom_command says, and 
>> would be surprising for all users who only read the manual of 
>> add_custom_command and then think they know what the parameter means for 
>> add_custom_target.
>> 
>>  But on the other hand, when I test with this:
>>  --
>>  cmake_minimum_required (VERSION 3.14)
>>  project(dependency_test LANGUAGES)
>> 
>>  add_custom_target(T1
>>  COMMAND echo T1
>>  )
>>  add_custom_target(T2
>>  COMMAND echo T2
>>  DEPENDS T1
>>  )
>> 
>>  # cmake -GNinja -B build .
>>  # ninja T2
>>  --
>>  Then T1 and T2 are built, so contrary to what the manual says, it seems to 
>> work.
>> 
>>  Is the manual just outdated (Maybe behavior has changed and only manual for 
>> add_custom_command has been updated)?
>>  Should it be the same as for add_custom_command, or are there really some 
>> differences?
> 
> As it happens, I just updated the docs for these in the last day or so. You 
> can find it in the not-yet-merged merge request here:
> 
> https://gitlab.kitware.com/cmake/cmake/merge_requests/3891
> 
> I wrote an explanation of the specific behavior of the dependencies in the 
> associated issue here:
> 
> https://gitlab.kitware.com/cmake/cmake/issues/19771#note_635547
> 
> There is a difference between the two, but it's subtle and specific to the 
> sort of scenario I mentioned in that issue comment.
> 
> -- 
> Craig Scott
> Melbourne, Australia
> https://crascit.com
> 
> Get the hand-book for every CMake user: Professional CMake: A Practical Guide 
> 
> Consulting services (CMake, C++, build/release processes): 
> https://crascit.com/services
> -- 
> 
> Powered by www.kitware.com
> 
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Kitware offers various services to support the CMake community. For more 
> information on each offering, please visit:
> 
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
> 
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
> 
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake

I found the wording for add_custom_command and add_custom_target to be 
confusing and had to look at examples (and books) to understand it better.

The DEPENDS field is kind of different for the two commands. 

It may be that add_custom_target "DEPENDS" can accept other custom targets; it 
seems from your example it does (which wouldn't surprise me from what I 
remember from the CMake source code).

For add_custom_target:
The phrase "They will be brought up to date when the target is built." had me 
thinking that this was going to force the custom command to always run.

Its more of a "The commands of add_custom_target() outputs will be run as 
needed before any add_custom_target() commands are run."

If a file listed in DEPENDS does not exist on disk then behavior is defined by 
the build tool and may or may not throw an error. I recall that Make and Ninja 
throws errors and MSBuild will have a warning.

Then there is the SOURCES field which acts like:
Similar to ``DEPENDS`` with the addition that the specified files are checked 
to exist on disk and will be added to IDE project files for convenience in 
editing.

"add_custom_target() sometimes builds SOURCES for Visual Studio generators but 
never for Makefiles"
https://gitlab.kitware.com/cmake/cmake/issues/10360

For add_custom_command it acts like (and this includes the trick that is used 
to make it always run):
If ``DEPENDS`` is not specified the command will run whenever the ``OUTPUT`` is 
missing or it will run whenever a file-level dependency is updated. If the 
command does not create one of the listed ``OUTPUT`` then the rule will always 
run. For example defining an output file called ALL or FORCE that is never 
created.

Then for the add_custom_command signature that is used for build events. You 
don't need to put the event. It defaults to POST_BUILD. This is different from 
the documentation that shows it is a required field.

--
Fred-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 

Re: [CMake] DEPENDS parameter of add_custom_target

2019-10-07 Thread Craig Scott
On Mon, Oct 7, 2019 at 9:32 PM Setzer Sebastian (CM-CI2/ECS2) via CMake <
cmake@cmake.org> wrote:

> Dear list,
> The manual says:
> https://cmake.org/cmake/help/latest/command/add_custom_target.html
> Reference files and outputs of custom commands created with
> add_custom_command() command calls in the same directory (CMakeLists.txt
> file). They will be brought up to date when the target is built.
> Use the add_dependencies() command to add dependencies on other targets.
>
> This is different from what the manual of add_custom_command says, and
> would be surprising for all users who only read the manual of
> add_custom_command and then think they know what the parameter means for
> add_custom_target.
>
> But on the other hand, when I test with this:
> --
> cmake_minimum_required (VERSION 3.14)
> project(dependency_test LANGUAGES)
>
> add_custom_target(T1
>   COMMAND echo T1
>   )
> add_custom_target(T2
>   COMMAND echo T2
>   DEPENDS T1
>   )
>
> # cmake -GNinja -B build .
> # ninja T2
> --
> Then T1 and T2 are built, so contrary to what the manual says, it seems to
> work.
>
> Is the manual just outdated (Maybe behavior has changed and only manual
> for add_custom_command has been updated)?
> Should it be the same as for add_custom_command, or are there really some
> differences?
>

As it happens, I just updated the docs for these in the last day or so. You
can find it in the not-yet-merged merge request here:

https://gitlab.kitware.com/cmake/cmake/merge_requests/3891

I wrote an explanation of the specific behavior of the dependencies in the
associated issue here:

https://gitlab.kitware.com/cmake/cmake/issues/19771#note_635547

There is a difference between the two, but it's subtle and specific to the
sort of scenario I mentioned in that issue comment.

-- 
Craig Scott
Melbourne, Australia
https://crascit.com

Get the hand-book for every CMake user: Professional CMake: A Practical
Guide 
Consulting services (CMake, C++, build/release processes):
https://crascit.com/services
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

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