From a145b9c11a0fe38fd4c921024a7376c99cc34bd2 Mon Sep 17 00:00:00 2001 From: Nadja Yang Date: Tue, 31 Mar 2026 14:00:39 -0400 Subject: [PATCH] chore: use FetchContent for mimalloc source acquisition (#13196) FetchContent provides configure-time source acquisition with `FETCHCONTENT_SOURCE_DIR_MIMALLOC` for sandboxed builds, replacing the empty-command ExternalProject pattern. Closes https://github.com/leanprover/lean4/issues/13176 --------- Co-authored-by: Joscha --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fa41c0cbc..198f5ad8f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,6 @@ cmake_minimum_required(VERSION 3.21) +include(ExternalProject) +include(FetchContent) if(NOT CMAKE_GENERATOR MATCHES "Makefiles") message(FATAL_ERROR "Only makefile generators are supported") @@ -34,7 +36,6 @@ foreach(var ${vars}) endif() endforeach() -include(ExternalProject) project(LEAN CXX C) if(NOT (DEFINED STAGE0_CMAKE_EXECUTABLE_SUFFIX)) @@ -119,17 +120,16 @@ if(NOT CMAKE_SYSTEM_NAME MATCHES "Emscripten") endif() if(USE_MIMALLOC) - ExternalProject_Add( + FetchContent_Declare( mimalloc - PREFIX mimalloc GIT_REPOSITORY https://github.com/microsoft/mimalloc GIT_TAG v2.2.3 - # just download, we compile it as part of each stage as it is small - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" + # Unnecessarily deep directory structure, but it saves us from a complicated + # stage0 update for now. If we ever update the other dependencies like + # cadical, it might be worth reorganizing the directory structure. + SOURCE_DIR "${CMAKE_BINARY_DIR}/mimalloc/src/mimalloc" ) - list(APPEND EXTRA_DEPENDS mimalloc) + FetchContent_MakeAvailable(mimalloc) endif() if(NOT STAGE1_PREV_STAGE)