add_subdirectory namespaces

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

add_subdirectory namespaces

Jason Beach
I've been reorganizing / updating our software cmake build. It currently uses a mixture of Externa Projects and normal target definitions that depend on the external projects (which has you probably know causes much sorrow and grief).  One of my goals in the reorganization was to replace all the ExternalProjectAdd statements with FetchContent, however I soon discovered that some of the external projects declare targets with the same name (i.e. an uninstall target).  These external projects are third party libraries that are not under our control.  

It appears there's been a suggestion to add namespaces to the add_subdirectory command:

Is that going anywhere?  It seems like that would address FetchContent's main limitation. I guess for the time being I'll use ExternalProject for thirdparty libraries not under our control and FetchContent for libraries that are and do a true super build instead of the muddled sort of arrangement we have now.

One other kind of not-so-random question-the documentation on the Project statement is fine if it's in the toplevel CMakeLists.txt (in which case it defines some project level variables, etc.) but it's silent about what happens if it's not in the top level CMakeLists.txt.  i.e. if I add a library via add_subdirectory or FetchContent and that library's toplevel CMakeLists.txt has the project statement, what happens when it's executed?  Is it silently ignored? 

Thanks,
Jason      

--

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: add_subdirectory namespaces

Robert Maynard
Subsequent calls to project() from sub-directories is supported. For
calls to project from sub-directories it does everything but set
CMAKE_PROJECT_NAME.

On Wed, Jul 24, 2019 at 7:29 AM Jason Beach <[hidden email]> wrote:

>
> I've been reorganizing / updating our software cmake build. It currently uses a mixture of Externa Projects and normal target definitions that depend on the external projects (which has you probably know causes much sorrow and grief).  One of my goals in the reorganization was to replace all the ExternalProjectAdd statements with FetchContent, however I soon discovered that some of the external projects declare targets with the same name (i.e. an uninstall target).  These external projects are third party libraries that are not under our control.
>
> It appears there's been a suggestion to add namespaces to the add_subdirectory command:
> https://gitlab.kitware.com/cmake/cmake/issues/16414
>
> Is that going anywhere?  It seems like that would address FetchContent's main limitation. I guess for the time being I'll use ExternalProject for thirdparty libraries not under our control and FetchContent for libraries that are and do a true super build instead of the muddled sort of arrangement we have now.
>
> One other kind of not-so-random question-the documentation on the Project statement is fine if it's in the toplevel CMakeLists.txt (in which case it defines some project level variables, etc.) but it's silent about what happens if it's not in the top level CMakeLists.txt.  i.e. if I add a library via add_subdirectory or FetchContent and that library's toplevel CMakeLists.txt has the project statement, what happens when it's executed?  Is it silently ignored?
>
> Thanks,
> Jason
> --
>
> 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