Skip to content

Please Substitute CMAKE_{SOURCE,BINARY}_DIR with CMAKE_CURRENT_{SOURCE,BINARY}_DIR #1509

@ghost

Description

If you directly include netcdf-c in another CMake project, it fails to configure properly as it looks for several things in CMAKE_SOURCE_DIR which will be the parent CMake project's source directory, not the netcdf-c's source directory. This can be simply fixed by replacing it with CMAKE_CURRENT_SOURCE_DIR. The same applies for CMAKE_BINARY_DIR.

In order to quickly reproduce this issue, create a simple CMake project and add the following lines:

include(FetchContent)

FetchContent_Declare(
        netcdf
        GIT_REPOSITORY https://github.com/Unidata/netcdf-c.git
        GIT_TAG        v4.7.2
)

FetchContent_MakeAvailable(netcdf)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions