From 8788164dd7647d5f4413aa795078dbdcb57d6543 Mon Sep 17 00:00:00 2001 From: Gabor Gyimesi Date: Tue, 17 Mar 2026 17:34:27 +0100 Subject: [PATCH] MINIFICPP-2750 Fix Windows build with CMake 4 CMake 4 is not compatible with CMake features in versions older than CMake 3.5. We need to specify at least version 3.5 for minimum requirements to make configuration succeed. Fortunately winflexbison does not use any older CMake features so changing the required version solves the issue. --- cmake/ExpressionLanguage.cmake | 14 +++++++ .../winflexbison/minimum_cmake_version.patch | 40 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 thirdparty/winflexbison/minimum_cmake_version.patch diff --git a/cmake/ExpressionLanguage.cmake b/cmake/ExpressionLanguage.cmake index 0626637095..3a06ce3999 100644 --- a/cmake/ExpressionLanguage.cmake +++ b/cmake/ExpressionLanguage.cmake @@ -20,10 +20,16 @@ if(WIN32) set(BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") + set(PATCH_FILE "${CMAKE_SOURCE_DIR}/thirdparty/winflexbison/minimum_cmake_version.patch") + + set(PC ${Bash_EXECUTABLE} -c "set -x &&\ + (\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE}\\\")") + FetchContent_Declare( winflexbison URL "https://github.com/lexxmark/winflexbison/archive/refs/tags/v2.5.25.tar.gz" URL_HASH "SHA256=8e1b71e037b524ba3f576babb0cf59182061df1f19cd86112f085a882560f60b" + PATCH_COMMAND "${PC}" SYSTEM ) FetchContent_GetProperties("winflexbison") @@ -38,6 +44,10 @@ if(WIN32) ERROR_VARIABLE bisonbuildE ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "configuration failed for winflexbison:\n${bisonbuildE}") + endif() + execute_process( COMMAND ${CMAKE_COMMAND} --build . --config RelWithDebInfo WORKING_DIRECTORY ${winflexbison_SOURCE_DIR} @@ -46,6 +56,10 @@ if(WIN32) ERROR_VARIABLE bisonbuildE ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "winflexbison build failed:\n${bisonbuildE}") + endif() + file(COPY ${winflexbison_SOURCE_DIR}/bison/Data DESTINATION ${winflexbison_SOURCE_DIR}/bison/RelWithDebInfo/) endif() diff --git a/thirdparty/winflexbison/minimum_cmake_version.patch b/thirdparty/winflexbison/minimum_cmake_version.patch new file mode 100644 index 0000000000..d7de8d4cc2 --- /dev/null +++ b/thirdparty/winflexbison/minimum_cmake_version.patch @@ -0,0 +1,40 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index cf657a6..8757b14 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) ++cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + + project (winflexbison) + +diff --git a/bison/CMakeLists.txt b/bison/CMakeLists.txt +index 55de8a1..24bbdcd 100644 +--- a/bison/CMakeLists.txt ++++ b/bison/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) ++cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + + set(PROJECT_NAME win_bison) + +diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt +index 4b57c62..6a292fa 100644 +--- a/common/CMakeLists.txt ++++ b/common/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) ++cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + + set(PROJECT_NAME winflexbison_common) + +diff --git a/flex/CMakeLists.txt b/flex/CMakeLists.txt +index f634f81..02ba17a 100644 +--- a/flex/CMakeLists.txt ++++ b/flex/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) ++cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + + set(PROJECT_NAME win_flex) +