Skip to content

Draft: Support cmake ExternalProjects

Cristian Le requested to merge LecrisUT/libxc:cmake/external-project into master

This will improve the compatibility with cmake ExternalProjects, i.e. the developer can now use:

FetchContent_Declare(
        Libxc
        GIT_REPOSITORY https://gitlab.com/libxc/libxc.git
        GIT_TAG        6.2.0 
        OVERRIDE_FIND_PACKAGE)
find_package(Libxc)

To fetch a specific version of Libxc and include it in the project. This works with git submodules as well. Thus the user can change the compilation flags of Libxc, e.g. Libxc_DISABLE_LXC=OFF.

Notice that good practices in cmake is to use namespace options for compatibility with ExternalProject so that the configuration of the parent project are not propagated to the included subproject. For example Libxc_SHARED_LIBS should only be OFF when Libxc is bundled such as with ExternalProjects so that the developer has control of the compilation flags. Otherwise, it should be set ON for packaged libraries etc. If the parent project wants to build its libraries as shared libraries, but bundle statically linked Libxc libraries, it is difficult without namespaced options.

Closes #444

Merge request reports