Skip to content

CMake: use of the include() command with the result of the export() command is deprecated #474

@BaconPancakes

Description

@BaconPancakes

I am running Cmake 3.16 and trying to use the find_package way linking the json-fortran results in:

[cmake] CMake Error at build/json-fortran/jsonfortran-intel-config.cmake:19 (include):
[cmake]   The file
[cmake] 
[cmake]     my-project-dir/build/json-fortran/jsonfortran-intel-targets.cmake
[cmake] 
[cmake]   was generated by the export() command.  It may not be used as the argument
[cmake]   to the include() command.  Use ALIAS targets instead to refer to targets by
[cmake]   alternative names.

Here's what I'm doing:

add_subdirectory(json-fortran)
list(APPEND CMAKE_PREFIX_PATH  "${CMAKE_CURRENT_SOURCE_DIR}/build/json-fortran")
find_package ( jsonfortran-${CMAKE_Fortran_COMPILER_ID} REQUIRED 8.2.0)
include_directories ( "${jsonfortran_INCLUDE_DIRS}" )

The workaround is to add the following to the CMakeLists.txt

cmake_policy(SET CMP0024 OLD)

referencing https://cmake.org/cmake/help/v3.17/policy/CMP0024.html#policy:CMP0024

However, as it warns, this is a deprecated feature.

Activity

jacobwilliams

jacobwilliams commented on Sep 13, 2020

@jacobwilliams
Owner

I'm not a CMake guru. Is there something we can do to avoid relying on depreciated features I wonder?

daydream123

daydream123 commented on Feb 6, 2024

@daydream123

I also have this issue now, and I tried to add cmake_policy(SET CMP0024 OLD), but it still does not work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @daydream123@BaconPancakes@jacobwilliams

        Issue actions

          CMake: use of the include() command with the result of the export() command is deprecated · Issue #474 · jacobwilliams/json-fortran