Skip to content

FetchContent compatibility: Use PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR #58

Description

@michael545

Hi Enrico, thanks for the great library!

I'm integrating Clothoids into a larger CMake project using FetchContent and ran into an issue where the submodule resolution fails during the configure step.

The problem stems from cmake_utils/CMakeLists-utilities.txt:134:
if (EXISTS "${CMAKE_SOURCE_DIR}/submodules/${MODULE_DIR}")

Because CMAKE_SOURCE_DIR always points to the top-level project root, it searches for submodules/ in the parent project rather than inside the Clothoids directory. This causes the build to fail with Neither quarticRootsFlocke nor quarticRootsFlocke exist in submodules when included via FetchContent or add_subdirectory.

Replacing ${CMAKE_SOURCE_DIR} with ${PROJECT_SOURCE_DIR} fixes the issue perfectly, as it correctly resolves to the directory where project(Clothoids) was declared.

I'm currently patching this on the fly using sed in my FetchContent block, but it would be awesome to get this fixed upstream so it's fully compatible with modern CMake dependency management out of the box.

Thanks!

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