Skip to content

CMake build tree not accessible for import #628

@ncrescenzio

Description

@ncrescenzio

As stated in the README.md

json-fortran/README.md

Lines 134 to 137 in a012a4d

using the Intel Fortran Compiler, gfortran 4.9, and NAG Fortran 6.0. It does also work on Windows (but note that the Visual Studio project it generates is not quite the same as the one mentioned above). This CMake based build provides an install target,
and exports from both the install location and the build location so
that building and using JSON-Fortran in another CMake based project is
trivial. To get started with the CMake based build, set the

the CMake build tree should be accessible for importing the JSON-Fortran library into another CMake-based project.

However, this does not seem to work, because the jsonfortran-gnu-targets.cmake file is generated in the ${PROJECT_BINARY_DIR}/packaging directory instead of simply being in ${PROJECT_BINARY_DIR}.

The problem can be solved by replacing lines

#----------------------------------------------
# Make build tree targets accessible for import
#----------------------------------------------
export ( TARGETS ${LIB_NAME} ${LIB_NAME}-static FILE ${PACKAGE_NAME}-targets.cmake )

with

export ( EXPORT ${PACKAGE_NAME}-targets
   NAMESPACE ${PACKAGE_NAME}::
   FILE ${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-targets.cmake )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions