Skip to content

FetchContent usage fails on current main #72

Description

@swordfatih

Using the FetchContent setup from the docs currently fails with :

CMake Error at build/_deps/sl3-src/CMakeLists.txt:101 (include):
  include could not find requested file:

    lib/find_sqlite


CMake Error at build/_deps/sl3-src/CMakeLists.txt:133 (include):
  include could not find requested file:

    lib/install

Reproducer :

cmake_minimum_required(VERSION 3.31)

project(sl3_consumer LANGUAGES C CXX)

include(FetchContent)

FetchContent_Declare(
    sl3
    GIT_REPOSITORY https://github.com/a4z/libsl3.git
    GIT_TAG main
    OVERRIDE_FIND_PACKAGE
)

set(BUILD_TESTING OFF)
set(sl3_USE_INTERNAL_SQLITE3 ON)
set(sl3_USE_COMMON_COMPILER_WARNINGS OFF)

find_package(sl3 CONFIG REQUIRED)

Looks like CMAKE_MODULE_PATH is only updated inside if(PROJECT_IS_TOP_LEVEL) in cmake/project-setup.cmake

When sl3 is consumed through FetchContent that condition is false, but lib/find_sqlite and lib/install are still included from the main CMakeLists.txt.

Adding ${libsl3_SOURCE_DIR}/cmake to CMAKE_MODULE_PATH fixes the issue locally

It looks like this should be outside the top lvl check

list(PREPEND CMAKE_MODULE_PATH "${libsl3_SOURCE_DIR}/cmake")

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions