MantisBT - CMake
View Issue Details
0014921CMakeCMakepublic2014-05-19 04:472016-06-10 14:21
Nick Lewis 
 
normalfeaturealways
closedfixed 
AllAllAll
CMake 2.8.12.2 
CMake 3.6CMake 3.6 
0014921: No way to exclude a component install() from a full installation
There is currently no way to exclude a component install() from a full installation. Current workarounds using OPTIONAL do not work reliably because they depend on previous builds and on the order execution of the build and install commands for the components and the default target
make
make tests
make install
DESTDIR=/testpkgs make install-tests

This results in test components in the default installation as well as the testpkg

Judging by questions on the mail list, users typically try to overcome this problem by adding the unsupported EXCLUDE_FROM_ALL keyword to the install command
patch attached that adds support for EXCLUDE_FROM_ALL to the install() command.
No tags attached.
patch cmake_install_exclude.patch (24,130) 2014-05-19 04:47
https://public.kitware.com/Bug/file/5147/cmake_install_exclude.patch
patch cmake_3_2_2_install_exclude.patch (23,369) 2015-07-16 12:20
https://public.kitware.com/Bug/file/5488/cmake_3_2_2_install_exclude.patch
patch cmake_3_4_2_install_exclude.patch (23,369) 2016-01-29 03:29
https://public.kitware.com/Bug/file/5618/cmake_3_4_2_install_exclude.patch
patch correction_cmake_3_4_2_install_exclude.patch (23,369) 2016-01-29 03:34
https://public.kitware.com/Bug/file/5619/correction_cmake_3_4_2_install_exclude.patch
patch correction2_cmake_3_4_2_install_exclude.patch (22,995) 2016-01-29 03:42
https://public.kitware.com/Bug/file/5620/correction2_cmake_3_4_2_install_exclude.patch
Issue History
2014-05-19 04:47Nick LewisNew Issue
2014-05-19 04:47Nick LewisFile Added: cmake_install_exclude.patch
2014-05-19 09:29Brad KingNote Added: 0035899
2015-07-16 12:20Nick LewisFile Added: cmake_3_2_2_install_exclude.patch
2015-07-16 12:22Nick LewisNote Added: 0039154
2015-07-17 09:49Brad KingNote Added: 0039156
2016-01-29 03:29Nick LewisFile Added: cmake_3_4_2_install_exclude.patch
2016-01-29 03:34Nick LewisFile Added: correction_cmake_3_4_2_install_exclude.patch
2016-01-29 03:42Nick LewisFile Added: correction2_cmake_3_4_2_install_exclude.patch
2016-01-29 03:46Nick LewisNote Added: 0040353
2016-01-29 08:44Brad KingNote Added: 0040356
2016-01-29 09:46Nick LewisNote Added: 0040359
2016-01-29 09:55Brad KingNote Added: 0040360
2016-01-29 09:57Brad KingNote Added: 0040361
2016-02-03 14:32Brad KingNote Added: 0040435
2016-02-10 11:23Brad KingNote Added: 0040463
2016-02-10 11:24Brad KingStatusnew => resolved
2016-02-10 11:24Brad KingResolutionopen => fixed
2016-02-10 11:24Brad KingFixed in Version => CMake 3.6
2016-02-10 11:24Brad KingTarget Version => CMake 3.6
2016-06-10 14:21Kitware RobotNote Added: 0041258
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0035899)
Brad King   
2014-05-19 09:29   
Interesting proposal. I think a change along these lines could also improve a case mentioned in the install() command documentation:

 http://www.cmake.org/cmake/help/v3.0/command/install.html [^]
 "Installing a target with the EXCLUDE_FROM_ALL target property set to TRUE has undefined behavior."

That refers to the use case when a target build is EXCLUDE_FROM_ALL and so is not created by "make" and may then be missing when "make install" is issued. This looks intended to support the same use case by making the install rule excluded from the default installation too. Perhaps install(TARGETS) should activate ExcludeFromAll when the corresponding property is set on the target.
(0039154)
Nick Lewis   
2015-07-16 12:22   
Rebased patch on 3.2.2. Still no automatic setting of install(EXCLUDE_FROM_ALL) based on the setting of add_executable(EXCLUDE_FROM_ALL) though
(0039156)
Brad King   
2015-07-17 09:49   
Thanks for working on this. I think it will be better discussed on the cmake-developers mailing list:

 http://www.cmake.org/mailman/listinfo/cmake-developers [^]

That allows for design discussion with a broader audience than the issue tracker.
(0040353)
Nick Lewis   
2016-01-29 03:46   
correction2_cmake_3_4_2_install_exclude.patch is the correct patch for cmake 3.4.2 - please ignore cmake_3_4_2_install_exclude.patch and correction_cmake_3_4_2_install_exclude.patch (or delete them)
(0040356)
Brad King   
2016-01-29 08:44   
Re 0014921:0040353: Thanks for updating the patch again, but please see 0014921:0039156. Also, the test suite will need to be updated to cover the feature.
(0040359)
Nick Lewis   
2016-01-29 09:46   
Re 0014921:0039156 - The proposal was put on the cmake-developers mailing list as follows:

MIME-Version: 1.0
Received: by 10.140.102.239 with HTTP; Mon, 20 Jul 2015 00:36:10 -0700 (PDT)
In-Reply-To: <moe4e0$oh2$1@ger.gmane.org>
References: <CAKtwun52wXV5Gc65vqk7wDtBH06+5F3HLsERT+dD3u5pi=UaiQ@mail.gmail.com>
    <moe4e0$oh2$1@ger.gmane.org>
Date: Mon, 20 Jul 2015 08:36:10 +0100
Delivered-To: nick.lewis@usa.g4s.com
Message-ID: <CAKtwun6jhOH_6Wy=CeDgoEjZCXCkFnmedjgtWsAU6-hNAmNQnQ@mail.gmail.com>
Subject: Re: [cmake-developers] install(EXCLUDE_FROM_ALL) new feature -
 request for comment
From: Nick Lewis <nick.lewis@usa.g4s.com>
To: Stephen Kelly <steveire@gmail.com>
Content-Type: multipart/alternative; boundary=94eb2c05fdb0725fbb051b49970f

--94eb2c05fdb0725fbb051b49970f
Content-Type: text/plain; charset=UTF-8

There is currently no way to exclude a component install() from a full
installation. Current workarounds using OPTIONAL do not work reliably
because
they depend on previous builds and on the order of the execution of the
build and
install commands for the components and the default target

Let us take an example of a project that has some tests in a component that
need to be installed into a dedicated test package. The user expectation is
that the result could be achieved by typing the following:

make
make tests
make install
DESTDIR=/testpkgs make install-tests

However this results in test components in the default installation as well
as the testpkg

Judging by questions on the mail list, users typically try to overcome this
problem by adding the
EXCLUDE_FROM_ALL keyword to the install() command but this is currently
unsupported. The patch uploaded to the issue tracker provides support for
it.

Brad has further suggested that the install(EXCLUDE_FROM_ALL) should be
implicitly set when installing components built with
add_executable/library(EXCLUDE_FROM_ALL)

I welcome your views on these ideas

Best Regards
Nick
(0040360)
Brad King   
2016-01-29 09:55   
Yes, sorry, I see it in the archives:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/13700 [^]
(0040361)
Brad King   
2016-01-29 09:57   
Re 0014921:0040360: Actually, your message posted in 0014921:0040359 was addressed privately to Stephen Kelly and never made it to the list.

Anyway, I think the patch is a good start. Please revise it to update the test suite to cover the feature and then start a new thread on the list with the proposal text and patch together. Thanks!
(0040435)
Brad King   
2016-02-03 14:32   
Thanks for starting the new thread. For reference, it is here:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/15634 [^]
(0040463)
Brad King   
2016-02-10 11:23   
Changes from the thread linked in 0014921:0040435 are now in 'master':

 install: Add EXCLUDE_FROM_ALL option
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=18ce97c4 [^]

 Tests: Add cases for install() command EXCLUDE_FROM_ALL option
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d321c196 [^]

 Help: Add notes for topic 'install-EXCLUDE_FROM_ALL'
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=586e56d0 [^]
(0041258)
Kitware Robot   
2016-06-10 14:21   
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.