From 1a3e64794fc20d7ab9bfe9eaa980df00ba982353 Mon Sep 17 00:00:00 2001 From: Chris Phlipot Date: Wed, 6 May 2026 14:48:09 -0700 Subject: [PATCH 1/3] Force C11/C++17 compile (Fixes GCC 16 build) Currently the project requests the C11 and C++17 feature sets using target_compile_features, however this only gaurentees us a minimum C++ version of C++17, and allows compile to proceed with C++20 (the GCC 16 default) if it is already set. Building Stable-diffusion.cpp with C++20 results in build failures as std::u8string can no longer be assigned to std::string due to C++20 standards changes. Explictly set the required language standard to C++17 in order to ensure we pass/fail the build consistently across compiler toolchains even if compilers by default try to expose a superset of C++17 features. Tested build succeeds on Fedora 44 with GCC 16. --- CMakeLists.txt | 2 +- examples/cli/CMakeLists.txt | 2 +- examples/server/CMakeLists.txt | 2 +- thirdparty/CMakeLists.txt | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57918d12d..e3adba5e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -270,7 +270,7 @@ add_subdirectory(thirdparty) target_link_libraries(${SD_LIB} PUBLIC ggml zip) target_include_directories(${SD_LIB} PUBLIC . src include) target_include_directories(${SD_LIB} PUBLIC . thirdparty) -target_compile_features(${SD_LIB} PUBLIC c_std_11 cxx_std_17) +set_target_properties(${SD_LIB} PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED ON CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) if (SD_BUILD_EXAMPLES) diff --git a/examples/cli/CMakeLists.txt b/examples/cli/CMakeLists.txt index db1f4ca37..655ab8331 100644 --- a/examples/cli/CMakeLists.txt +++ b/examples/cli/CMakeLists.txt @@ -17,4 +17,4 @@ if(SD_WEBM) target_compile_definitions(${TARGET} PRIVATE SD_USE_WEBM) target_link_libraries(${TARGET} PRIVATE webm) endif() -target_compile_features(${TARGET} PUBLIC c_std_11 cxx_std_17) +set_target_properties(${TARGET} PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED ON CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) diff --git a/examples/server/CMakeLists.txt b/examples/server/CMakeLists.txt index b70b525e5..0a781f408 100644 --- a/examples/server/CMakeLists.txt +++ b/examples/server/CMakeLists.txt @@ -101,4 +101,4 @@ if(WIN32 AND NOT MSVC) target_link_libraries(${TARGET} PRIVATE ws2_32) endif() -target_compile_features(${TARGET} PUBLIC c_std_11 cxx_std_17) +set_target_properties(${TARGET} PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED ON CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 4dfdf0d29..23fe1e28c 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -37,9 +37,9 @@ if(SD_WEBM AND NOT SD_USE_SYSTEM_WEBM) # C++11. Restore the parent flags so the main project keeps its own C++17 # requirements, then pin the libwebm targets to C++17 explicitly. set(CMAKE_CXX_FLAGS "${SD_LIBWEBM_PARENT_CXX_FLAGS}" CACHE STRING "" FORCE) - target_compile_features(mkvmuxer PRIVATE cxx_std_17) - target_compile_features(mkvparser PRIVATE cxx_std_17) - target_compile_features(webm PRIVATE cxx_std_17) + set_target_properties(mkvmuxer PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) + set_target_properties(mkvparser PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) + set_target_properties(webm PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) target_include_directories(webm INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/libwebm) endif() From 9e09cfb0e7e73dc9a32ee027a1f3e47ee86e6026 Mon Sep 17 00:00:00 2001 From: Chris Phlipot Date: Thu, 14 May 2026 11:17:40 -0700 Subject: [PATCH 2/3] Revert "Force C11/C++17 compile (Fixes GCC 16 build)" This reverts commit ee89d25bf946c115ab42e7d21918b9879702b2ea. --- CMakeLists.txt | 2 +- examples/cli/CMakeLists.txt | 2 +- examples/server/CMakeLists.txt | 2 +- thirdparty/CMakeLists.txt | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3adba5e1..57918d12d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -270,7 +270,7 @@ add_subdirectory(thirdparty) target_link_libraries(${SD_LIB} PUBLIC ggml zip) target_include_directories(${SD_LIB} PUBLIC . src include) target_include_directories(${SD_LIB} PUBLIC . thirdparty) -set_target_properties(${SD_LIB} PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED ON CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) +target_compile_features(${SD_LIB} PUBLIC c_std_11 cxx_std_17) if (SD_BUILD_EXAMPLES) diff --git a/examples/cli/CMakeLists.txt b/examples/cli/CMakeLists.txt index 655ab8331..db1f4ca37 100644 --- a/examples/cli/CMakeLists.txt +++ b/examples/cli/CMakeLists.txt @@ -17,4 +17,4 @@ if(SD_WEBM) target_compile_definitions(${TARGET} PRIVATE SD_USE_WEBM) target_link_libraries(${TARGET} PRIVATE webm) endif() -set_target_properties(${TARGET} PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED ON CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) +target_compile_features(${TARGET} PUBLIC c_std_11 cxx_std_17) diff --git a/examples/server/CMakeLists.txt b/examples/server/CMakeLists.txt index 0a781f408..b70b525e5 100644 --- a/examples/server/CMakeLists.txt +++ b/examples/server/CMakeLists.txt @@ -101,4 +101,4 @@ if(WIN32 AND NOT MSVC) target_link_libraries(${TARGET} PRIVATE ws2_32) endif() -set_target_properties(${TARGET} PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED ON CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) +target_compile_features(${TARGET} PUBLIC c_std_11 cxx_std_17) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 23fe1e28c..4dfdf0d29 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -37,9 +37,9 @@ if(SD_WEBM AND NOT SD_USE_SYSTEM_WEBM) # C++11. Restore the parent flags so the main project keeps its own C++17 # requirements, then pin the libwebm targets to C++17 explicitly. set(CMAKE_CXX_FLAGS "${SD_LIBWEBM_PARENT_CXX_FLAGS}" CACHE STRING "" FORCE) - set_target_properties(mkvmuxer PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) - set_target_properties(mkvparser PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) - set_target_properties(webm PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) + target_compile_features(mkvmuxer PRIVATE cxx_std_17) + target_compile_features(mkvparser PRIVATE cxx_std_17) + target_compile_features(webm PRIVATE cxx_std_17) target_include_directories(webm INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/libwebm) endif() From 61b3e597a1c37e3f84bb87486be9762e8960abf6 Mon Sep 17 00:00:00 2001 From: Chris Phlipot Date: Thu, 14 May 2026 11:25:13 -0700 Subject: [PATCH 3/3] enforce C11/C++17 at project instead of target level (copying ggml project approach) --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57918d12d..e0d0eb9b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,12 @@ option(SD_BUILD_SHARED_GGML_LIB "sd: build ggml as a separate shared lib" O option(SD_USE_SYSTEM_GGML "sd: use system-installed GGML library" OFF) #option(SD_BUILD_SERVER "sd: build server example" ON) +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED true) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED true) + if(SD_CUDA) message("-- Use CUDA as backend stable-diffusion") set(GGML_CUDA ON)