Skip to content

Wrong path to .VERSION.in when building as a CMake subproject #585

Closed
@mcharlou

Description

@mcharlou

When building json-fortran as a CMake subproject (i.e. json-fortran is not the top-level project), typically with FetchContent, the following error occurs:

CMake Error: File [REDACTED]/.VERSION.in does not exist.
CMake Error at build/_deps/json-fortran-src/CMakeLists.txt:48 (configure_file):
  configure_file Problem configuring file

This error occurs because json-fortran tries to configure the file .VERSION.in located in CMAKE_SOURCE_DIR, however when json-fortran is not the top-level project, CMAKE_SOURCE_DIR is not json-fortran's source directory (and thus .VERSION.in is likely not present).

Replacing CMAKE_SOURCE_DIR with CMAKE_CURRENT_SOURCE_DIR should solve the issue.

Moreover, since the .VERSION file seems to only be used when generating the documentation, adding a conditional statement with JSONFORTRAN_ENABLE_DOC_GENERATION may be a good idea.

I'll propose a PR with the fixed I suggest.

Version: 9.0.3
OS: Debian 12 (bookworm)
CMake version: 3.25.1

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