MantisBT - CMake
View Issue Details
0010437CMakeCMakepublic2010-03-18 07:412011-05-02 14:46
Lysius 
David Cole 
normalminoralways
closedwon't fix 
CMake-2-8 
CMake 2.8.4 
0010437: support "install(TARGETS ... OPTIONAL)" with "add_executable(... EXCLUDE_FROM_ALL ...)"
Using the combination

add_executable(test EXCLUDE_FROM_ALL test.cpp)
install(TARGETS test DESTINATION test OPTIONAL)

results in the warning message
WARNING: Target "test" has EXCLUDE_FROM_ALL set and will not be built by default but an install rule has been provided for it. CMake does not define behavior for this case.

It does though what I expect:
when I run "make install" without "make test" first, nothing is installed, when I do run "make test" first, the executable is installed.

So I think the warning should be silenced when the install command has OPTIONAL set.

I tested with 2.6.4 and 2.8.1, both show the same behavior.
No tags attached.
gz testcase.tar.gz (338) 2010-03-18 07:41
https://public.kitware.com/Bug/file/2981/testcase.tar.gz
Issue History
2010-03-18 07:41LysiusNew Issue
2010-03-18 07:41LysiusFile Added: testcase.tar.gz
2011-01-17 15:00David ColeAssigned To => David Cole
2011-01-17 15:00David ColeStatusnew => assigned
2011-01-17 15:03David ColeNote Added: 0024798
2011-01-17 15:03David ColeStatusassigned => resolved
2011-01-17 15:03David ColeFixed in Version => CMake 2.8.4
2011-01-17 15:03David ColeResolutionopen => won't fix
2011-05-02 14:46David ColeNote Added: 0026348
2011-05-02 14:46David ColeStatusresolved => closed

Notes
(0024798)
David Cole   
2011-01-17 15:03   
If you are using "EXCLUDE_FROM_ALL" then you should not be installing the thing that's built by that add_executable command.

If you want to install it, do not use EXCLUDE_FROM_ALL.

If you want something to be optional, then use logic, variables and IF commands in your CMakeLists files to make it optional. Then, it it's on, it gets built and installed, and if it's off, you avoid both build and install. Optional, but controlled by your configure-time logic, rather than the build-time whims of what targets a developer chooses to build in what order.

We are not going to add an OPTIONAL keyword to the install command. If it's not built, leave it out, if it is built, do what you like.

Please re-open this issue and convince me, if you feel strongly about it.
(0026348)
David Cole   
2011-05-02 14:46   
Closing resolved issues that have not been updated in more than 3 months.