Adding a target to 'all' that was previously excluded

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding a target to 'all' that was previously excluded

Andrew White
How do I add an excluded (executable) target to the build.  I know that if I add a library EXCLUDE_FROM_ALL and then create a dependency on that library then that the library will be built anyway.  How do I trigger similar behaviour from an executable target?

Example:

Directory A contains a CMakeLists.txt that builds half a dozen utilities. As part of my project, I want to add a single target from that list.

I can include the build info without auto-adding all targets by going:

        Add_subdirectory(blah EXCLUDE_FROM_ALL)

How do I then add target blah_X to my 'all' build?  Or is there another way to approach this?

Thanks

--
Andrew

--

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
Reply | Threaded
Open this post in threaded view
|

Re: Adding a target to 'all' that was previously excluded

Marc CHEVRIER
You can use a new target, built by all, depending on your initial target:

add_custom_target(build_blah_X ALL)
add_dependencies(build_blah_X blah_X)


Le mer. 4 juil. 2018 à 03:33, Andrew White <[hidden email]> a écrit :
How do I add an excluded (executable) target to the build.  I know that if I add a library EXCLUDE_FROM_ALL and then create a dependency on that library then that the library will be built anyway.  How do I trigger similar behaviour from an executable target?

Example:

Directory A contains a CMakeLists.txt that builds half a dozen utilities. As part of my project, I want to add a single target from that list.

I can include the build info without auto-adding all targets by going:

        Add_subdirectory(blah EXCLUDE_FROM_ALL)

How do I then add target blah_X to my 'all' build?  Or is there another way to approach this?

Thanks

--
Andrew

--

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

--

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
Reply | Threaded
Open this post in threaded view
|

Re: Adding a target to 'all' that was previously excluded

Petr Kmoch
Hi Andrew.

All that the EXCLUDE_FROM_ALL argument of add_executable() does is set that target's property EXCLUDE_FROM_ALL to TRUE. So all you need to do is set that property to false again:

  set_property(TARGET blah PROPERTY EXCLUDE_FROM_ALL FALSE)

Petr

On 4 July 2018 at 08:48, Marc CHEVRIER <[hidden email]> wrote:
You can use a new target, built by all, depending on your initial target:

add_custom_target(build_blah_X ALL)
add_dependencies(build_blah_X blah_X)


Le mer. 4 juil. 2018 à 03:33, Andrew White <[hidden email]> a écrit :
How do I add an excluded (executable) target to the build.  I know that if I add a library EXCLUDE_FROM_ALL and then create a dependency on that library then that the library will be built anyway.  How do I trigger similar behaviour from an executable target?

Example:

Directory A contains a CMakeLists.txt that builds half a dozen utilities. As part of my project, I want to add a single target from that list.

I can include the build info without auto-adding all targets by going:

        Add_subdirectory(blah EXCLUDE_FROM_ALL)

How do I then add target blah_X to my 'all' build?  Or is there another way to approach this?

Thanks

--
Andrew

--

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

--

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



--

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