From e424a934afdc26589432f9102c3435e98d58ab67 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Mon, 13 Jul 2026 23:41:32 +0200 Subject: [PATCH] Fix for find-package-test and C++20 link issues --- .github/workflows/linux.yml | 4 ++-- CMakeLists.txt | 6 ++++++ GNUmakefile | 6 +++--- test/CMakeLists.txt | 2 ++ test/find-package-test/CMakeLists.txt | 3 --- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 36a50306..8dec8b1b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -15,7 +15,7 @@ jobs: runs-on: ${{ matrix.os || 'ubuntu-22.04' }} strategy: matrix: - cxx: [g++-4.9, g++-11, clang++-3.6, clang++-11] + cxx: [g++-4.9, g++-11, clang++-11] build_type: [Debug, Release] std: [11] shared: [""] @@ -42,7 +42,7 @@ jobs: std: 23 os: ubuntu-24.04 gen: Ninja - - cxx: clang++-3.6 + # - cxx: clang++-3.6 - cxx: clang++-11 build_type: Debug std: 17 diff --git a/CMakeLists.txt b/CMakeLists.txt index 682bfc7c..e2a52e8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -416,6 +416,12 @@ endfunction () if (FMT_MODULE) add_module_library(fmt-module src/fmt.cc USE_CMAKE_MODULES ${FMT_USE_CMAKE_MODULES}) + # Add implementation sources as separate compilation units + # This ensures symbols are available for linking even in C++20 + target_sources(fmt-module PRIVATE src/format.cc) + if (FMT_OS) + target_sources(fmt-module PRIVATE src/os.cc) + endif () setup_target(fmt-module PUBLIC) endif () diff --git a/GNUmakefile b/GNUmakefile index 2657ce53..158a0973 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -18,18 +18,18 @@ build: GNUmakefile CMakeLists.txt cmake --version # NOTE: v4.4 expected! CK cmake -G Ninja -S . -B build --fresh \ -D CMAKE_SKIP_TEST_ALL_DEPENDENCY=NO \ - -D FMT_MODULE=1 -D FMT_IMPORT_STD=1 -D CMAKE_CXX_STANDARD=23 \ + -D FMT_PEDANTIC=YES \ + -D FMT_MODULE=1 -D FMT_IMPORT_STD=0 -D CMAKE_CXX_STANDARD=20 \ -D CMAKE_EXPERIMENTAL_CXX_IMPORT_STD=f35a9ac6-8463-4d38-8eec-5d6008153e7d ln -fs build/compile_commands.json . find-package-test: install cmake -G Ninja -S test/find-package-test -B build/find-package-build --fresh \ - -D FMT_MODULE=1 -D FMT_IMPORT_STD=1 -D CMAKE_CXX_STANDARD=23 \ + -D FMT_MODULE=1 -D FMT_IMPORT_STD=0 -D CMAKE_CXX_STANDARD=20 \ -D CMAKE_EXPERIMENTAL_CXX_IMPORT_STD=f35a9ac6-8463-4d38-8eec-5d6008153e7d ninja -C build/find-package-build -v ninja -C build/find-package-build -t deps CMakeFiles/module-test.dir/main.cc.o ./build/find-package-build/module-test build/find-package-build/*-test - clean: rm -rf build .cache compile_commands.json diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 28d143d4..4e05da80 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -184,6 +184,8 @@ if (FMT_PEDANTIC "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}" "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" + "-DFMT_IMPORT_STD=${FMT_IMPORT_STD}" + "-DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=${CMAKE_EXPERIMENTAL_CXX_IMPORT_STD}" "-DFMT_DIR=${PROJECT_BINARY_DIR}" "-DPEDANTIC_COMPILE_FLAGS=${PEDANTIC_COMPILE_FLAGS}" "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") diff --git a/test/find-package-test/CMakeLists.txt b/test/find-package-test/CMakeLists.txt index 27171c72..1372c8c1 100644 --- a/test/find-package-test/CMakeLists.txt +++ b/test/find-package-test/CMakeLists.txt @@ -9,13 +9,11 @@ set(PEDANTIC_COMPILE_FLAGS) add_executable(library-test main.cc) target_link_libraries(library-test fmt::fmt) target_compile_options(library-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) -target_include_directories(library-test PUBLIC SYSTEM .) if (TARGET fmt::fmt-header-only) add_executable(header-only-test main.cc) target_link_libraries(header-only-test fmt::fmt-header-only) target_compile_options(header-only-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) - target_include_directories(header-only-test PUBLIC SYSTEM .) endif () if (TARGET fmt::fmt-module) @@ -26,5 +24,4 @@ if (TARGET fmt::fmt-module) target_compile_features(module-test PRIVATE cxx_std_23) set_target_properties(module-test PROPERTIES CXX_MODULE_STD 1) endif () - target_include_directories(module-test PUBLIC SYSTEM .) endif ()