diff --git a/.CMakeUserPresets.json b/.CMakeUserPresets.json index 9367089..48969d8 100644 --- a/.CMakeUserPresets.json +++ b/.CMakeUserPresets.json @@ -1,8 +1,8 @@ { - "version": 6, + "version": 9, "cmakeMinimumRequired": { "major": 3, - "minor": 25, + "minor": 30, "patch": 0 }, "configurePresets": [ @@ -32,7 +32,10 @@ "inherits": [ "dev-common", "ci-Darwin" - ] + ], + "cacheVariables": { + "CMAKE_CXX_STDLIB_MODULES_JSON": "$env{CMAKE_CXX_STDLIB_MODULES_JSON}" + } }, { "name": "dev-Windows", @@ -51,6 +54,18 @@ "binaryDir": "${sourceDir}/build/dev", "inherits": "dev-" }, + { + "name": "dev-trace", + "inherits": "dev", + "trace": { + "mode": "expand", + "source": [ + "CMakeDetermineCompilerSupport.cmake", + "CMakeDetermineCompilerId.cmake", + "Clang-CXX-CXXImportStd.cmake" + ] + } + }, { "name": "dev-coverage", "binaryDir": "${sourceDir}/build/coverage", diff --git a/.TODO.txt b/.TODO.txt index dd45b06..6f7c201 100644 --- a/.TODO.txt +++ b/.TODO.txt @@ -1,139 +1,109 @@ -C:\Users\KLEIN_CL\Workspace\cpp\fmt-module>cmake --workflow dev --fresh -Executing workflow step 1 of 4: configure preset "dev" - -Preset CMake variables: - - CMAKE_BUILD_TYPE="Release" - CMAKE_CXX_COMPILER="cl" - CMAKE_CXX_EXTENSIONS:BOOL="TRUE" - CMAKE_CXX_STANDARD="23" - CMAKE_CXX_STANDARD_REQUIRED:BOOL="TRUE" - CMAKE_EXPORT_COMPILE_COMMANDS="ON" - CMAKE_INSTALL_PREFIX:PATH="C:/Users/KLEIN_CL/Workspace/cpp/fmt-module/stagedir" - CMAKE_PREFIX_PATH:STRING="C:/Users/KLEIN_CL/Workspace/cpp/fmt-module/stagedir" - FMT_DEVELOPER_MODE:BOOL="TRUE" - -Preset environment variables: - - EnforceProcessCountAcrossBuilds="true" - UseMultiToolTask="true" - --- use ccache --- The CXX compiler identification is MSVC 19.41.34123.0 --- Detecting CXX compiler ABI info --- Detecting CXX compiler ABI info - done --- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.41.34120/bin/Hostx86/x86/cl.exe - skipped --- Detecting CXX compile features --- Detecting CXX compile features - done --- CMAKE_CXX_COMPILER_IMPORT_STD= --- CPPdefinitions=FMT_USE_FCNTL=0;FMT_MODULE --- CPM: Adding package fmt@11.1.1 (11.1.1) --- Populating fmt --- Configuring done (0.2s) --- Generating done (0.5s) --- Build files have been written to: C:/Users/KLEIN_CL/Workspace/cpp/fmt-module/build/dev/_deps/fmt-subbuild -[0/7] Performing update step for 'fmt-populate' --- Already at requested tag: 11.1.1 -[1/7] No patch step for 'fmt-populate' -[3/7] No configure step for 'fmt-populate' -[4/7] No build step for 'fmt-populate' -[5/7] No install step for 'fmt-populate' -[6/7] No test step for 'fmt-populate' -[7/7] Completed 'fmt-populate' --- Configuring done (36.7s) --- Generating done (0.1s) --- Build files have been written to: C:/Users/KLEIN_CL/Workspace/cpp/fmt-module/build/dev - -Executing workflow step 2 of 4: build preset "dev" - -Change Dir: 'C:/Users/KLEIN_CL/Workspace/cpp/fmt-module/build/dev' - -Run Build Command(s): C:/Strawberry/c/bin/ninja.exe -v -j 1 install - -[1/8] -C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\MSVC\1441~1.341\bin\Hostx86\x86\cl.exe --DFMT_MODULE -DFMT_USE_FCNTL=0 --IC:\Users\KLEIN_CL\Workspace\cpp\fmt-module\build\dev\_deps\fmt-src\include -/DWIN32 /D_WINDOWS /EHsc /O2 /Ob2 /DNDEBUG -std:c++latest -MD /utf-8 -C:\Users\KLEIN_CL\Workspace\cpp\fmt-module\module\fmt.cppm -nologo -TP --showIncludes -scanDependencies CMakeFiles\fmt.dir\module\fmt.cppm.obj.ddi --FoCMakeFiles\fmt.dir\module\fmt.cppm.obj fmt.cppm - -[2/8] C:\RsPython\3.12\Lib\site-packages\cmake\data\bin\cmake.exe -E -cmake_ninja_dyndep --tdi=CMakeFiles\fmt.dir\CXXDependInfo.json --lang=CXX ---modmapfmt=msvc --dd=CMakeFiles\fmt.dir\CXX.dd @CMakeFiles\fmt.dir\CXX.dd.rsp - -[3/8] C:\ProgramData\chocolatey\bin\ccache.exe -C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\MSVC\1441~1.341\bin\Hostx86\x86\cl.exe -/nologo /TP -DFMT_MODULE -DFMT_USE_FCNTL=0 --IC:\Users\KLEIN_CL\Workspace\cpp\fmt-module\build\dev\_deps\fmt-src\include -/DWIN32 /D_WINDOWS /EHsc /O2 /Ob2 /DNDEBUG -std:c++latest -MD /utf-8 -/showIncludes @CMakeFiles\fmt.dir\module\fmt.cppm.obj.modmap -/FoCMakeFiles\fmt.dir\module\fmt.cppm.obj /FdCMakeFiles\fmt.dir\fmt.pdb /FS -c -C:\Users\KLEIN_CL\Workspace\cpp\fmt-module\module\fmt.cppm fmt.cppm - -C:\Program Files (x86)\Windows -Kits\10\\include\10.0.22621.0\\um\winnt.h(1005): note: sorry: 'inline' -function definition for 'ULONGLONG Int64ShllMod32(ULONGLONG,DWORD)' could not -be written to module due to unrecognized expression or statement at -'C:\Program Files (x86)\Windows -Kits\10\\include\10.0.22621.0\\um\winnt.h(1010)'. - -If possible please provide a repro here: https://developercommunity.visualstudio.com - -C:\Program Files (x86)\Windows -Kits\10\\include\10.0.22621.0\\um\winnt.h(1021): note: sorry: 'inline' -function definition for 'LONGLONG Int64ShraMod32(LONGLONG,DWORD)' could not be -written to module due to unrecognized expression or statement at 'C:\Program -Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\winnt.h(1026)'. - -If possible please provide a repro here: https://developercommunity.visualstudio.com - -C:\Program Files (x86)\Windows -Kits\10\\include\10.0.22621.0\\um\winnt.h(1037): note: sorry: 'inline' -function definition for 'ULONGLONG Int64ShrlMod32(ULONGLONG,DWORD)' could not -be written to module due to unrecognized expression or statement at -'C:\Program Files (x86)\Windows -Kits\10\\include\10.0.22621.0\\um\winnt.h(1042)'. - -If possible please provide a repro here: https://developercommunity.visualstudio.com - -[4/8] C:\RsPython\3.12\Lib\site-packages\cmake\data\bin\cmake.exe -E -cmake_ninja_dyndep ---tdi=tests\CMakeFiles\header-only-test.dir\CXXDependInfo.json --lang=CXX ---modmapfmt=msvc --dd=tests\CMakeFiles\header-only-test.dir\CXX.dd -@tests\CMakeFiles\header-only-test.dir\CXX.dd.rsp - -[5/8] C:\Windows\system32\cmd.exe /C "cd . && -C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\MSVC\1441~1.341\bin\Hostx86\x86\lib.exe -/nologo /machine:X86 /out:fmt.lib CMakeFiles\fmt.dir\module\fmt.cppm.obj && cd -." - -[6/8] C:\ProgramData\chocolatey\bin\ccache.exe -C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\MSVC\1441~1.341\bin\Hostx86\x86\cl.exe -/nologo /TP -DFMT_MODULE -DFMT_USE_FCNTL=0 --IC:\Users\KLEIN_CL\Workspace\cpp\fmt-module\build\dev\_deps\fmt-src\include -/DWIN32 /D_WINDOWS /EHsc /O2 /Ob2 /DNDEBUG -std:c++latest -MD /utf-8 -/showIncludes -@tests\CMakeFiles\header-only-test.dir\header-only-test.cc.obj.modmap -/Fotests\CMakeFiles\header-only-test.dir\header-only-test.cc.obj -/Fdtests\CMakeFiles\header-only-test.dir\ /FS -c -C:\Users\KLEIN_CL\Workspace\cpp\fmt-module\tests\header-only-test.cc +UpdateCTestConfiguration from :/Users/clausklein/Workspace/cpp/cxx20/fmt-module/build/dev/DartConfiguration.tcl +Test project /Users/clausklein/Workspace/cpp/cxx20/fmt-module/build/dev +Constructing a list of tests +Done constructing a list of tests +Updating test list for fixtures +Added 0 tests to meet fixture requirements +Checking test dependency graph... +Checking test dependency graph end +test 1 + Start 1: find-package-test + +1: Test command: /Users/clausklein/.local/bin/ctest "-C" "Release" "--build-and-test" "/Users/clausklein/Workspace/cpp/cxx20/fmt-module/module/tests" "/Users/clausklein/Workspace/cpp/cxx20/fmt-module/build/dev/tests/find-package-test" "--build-generator" "Ninja" "--build-makeprogram" "/Users/clausklein/.local/bin/ninja" "--build-options" "-D CMAKE_CXX_COMPILER=/usr/local/bin/g++-15" "-D CMAKE_CXX_STANDARD=23" "-D CMAKE_CXX_EXTENSIONS=ON" "-D CMAKE_CXX_STANDARD_REQUIRED=ON" "-D CMAKE_BUILD_TYPE=Release" "-D CMAKE_PREFIX_PATH=/Users/clausklein/Workspace/cpp/cxx20/fmt-module/stagedir" "-D ADD_STDLIB_MODULES=" "-D LLVM_LIBC_SOURCE=" "-D LLVM_DIR=" "-D CMAKE_CXX_MODULE_STD=ON" "-D CMAKE_EXPERIMENTAL_CXX_IMPORT_STD=d0edc3af-4c50-42ea-a356-e2862fe7a444" +1: Working Directory: /Users/clausklein/Workspace/cpp/cxx20/fmt-module/build/dev/tests +1: Test timeout computed to be: 10000000 +1: Internal cmake changing into directory: /Users/clausklein/Workspace/cpp/cxx20/fmt-module/build/dev/tests/find-package-test +1: ======== CMake output ====== +1: CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=/usr/local/Cellar/gcc/15.2.0/include/c++/15;/usr/local/Cellar/gcc/15.2.0/include/c++/15/x86_64-apple-darwin23;/usr/local/Cellar/gcc/15.2.0/include/c++/15/backward;/usr/local/Cellar/gcc/15.2.0/lib/gcc/current/gcc/x86_64-apple-darwin23/15/include;/usr/local/Cellar/gcc/15.2.0/lib/gcc/current/gcc/x86_64-apple-darwin23/15/include-fixed;/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include;/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks +1: Module tests to be built: header-only-test +1: Configuring done (0.1s) +1: CMake Warning (dev) in CMakeLists.txt: +1: CMake's support for `import std;` in C++23 and newer is experimental. It +1: is meant only for experimentation and feedback to CMake developers. +1: This warning is for project developers. Use -Wno-dev to suppress it. +1: +1: Generating done (0.0s) +1: Build files have been written to: /Users/clausklein/Workspace/cpp/cxx20/fmt-module/build/dev/tests/find-package-test +1: ======== End CMake output ====== +1: Change Dir: '/Users/clausklein/Workspace/cpp/cxx20/fmt-module/build/dev/tests/find-package-test' +1: +1: Run Clean Command: /Users/clausklein/.local/bin/ninja clean +1: [1/1] Cleaning all built files... +1: Cleaning... 22 files. +1: +1: Run Build Command(s): /Users/clausklein/.local/bin/ninja +1: [1/12] Scanning /usr/local/Cellar/gcc/15.2.0/include/c++/15/bits/std.compat.cc for CXX dependencies +1: [2/12] Scanning /usr/local/Cellar/gcc/15.2.0/include/c++/15/bits/std.cc for CXX dependencies +1: [3/12] Generating CXX dyndep file 'CMakeFiles/__CMAKE__CXX23@synth_439f33eb51e5.dir/CXX.dd' +1: [4/12] Scanning /Users/clausklein/Workspace/cpp/cxx20/fmt-module/stagedir/lib/cmake/fmt/module/fmt.cppm for CXX dependencies +1: [5/12] Generating CXX dyndep file 'CMakeFiles/fmt__fmt@synth_439f33eb51e5.dir/CXX.dd' +1: [6/12] Scanning /Users/clausklein/Workspace/cpp/cxx20/fmt-module/tests/header-only-test.cc for CXX dependencies +1: [7/12] Generating CXX dyndep file CMakeFiles/module_header-only-test.dir/CXX.dd +1: [8/12] Building CXX object 'CMakeFiles/__CMAKE__CXX23@synth_439f33eb51e5.dir/67f69854274c.bmi' +1: [9/12] Building CXX object 'CMakeFiles/__CMAKE__CXX23@synth_439f33eb51e5.dir/1ccb32d972a2.bmi' +1: [10/12] Building CXX object 'CMakeFiles/fmt__fmt@synth_439f33eb51e5.dir/f6569b67b774.bmi' +1: [11/12] Building CXX object CMakeFiles/module_header-only-test.dir/Users/clausklein/Workspace/cpp/cxx20/fmt-module/tests/header-only-test.cc.o +1: [12/12] Linking CXX executable module_header-only-test +1: FAILED: [code=1] module_header-only-test +1: : && /usr/local/bin/g++-15 -stdlib=libstdc++ -O3 -DNDEBUG -Wl,-search_paths_first -Wl,-headerpad_max_install_names -stdlib=libstdc++ CMakeFiles/module_header-only-test.dir/Users/clausklein/Workspace/cpp/cxx20/fmt-module/tests/header-only-test.cc.o -o module_header-only-test /Users/clausklein/Workspace/cpp/cxx20/fmt-module/stagedir/lib/libfmt.a && : +1: Undefined symbols for architecture x86_64: +1: "initializer for module std", referenced from: +1: initializer for module fmt in libfmt.a[2](fmt.cppm.o) +1: "initializer for module std.compat", referenced from: +1: __GLOBAL__sub_I_header_only_test.cc in header-only-test.cc.o +1: ld: symbol(s) not found for architecture x86_64 +1: collect2: error: ld returned 1 exit status +1: ninja: build stopped: subcommand failed. +1: +1/1 Test #1: find-package-test ................***Failed 9.90 sec +Internal cmake changing into directory: /Users/clausklein/Workspace/cpp/cxx20/fmt-module/build/dev/tests/find-package-test +======== CMake output ====== +CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=/usr/local/Cellar/gcc/15.2.0/include/c++/15;/usr/local/Cellar/gcc/15.2.0/include/c++/15/x86_64-apple-darwin23;/usr/local/Cellar/gcc/15.2.0/include/c++/15/backward;/usr/local/Cellar/gcc/15.2.0/lib/gcc/current/gcc/x86_64-apple-darwin23/15/include;/usr/local/Cellar/gcc/15.2.0/lib/gcc/current/gcc/x86_64-apple-darwin23/15/include-fixed;/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include;/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks +Module tests to be built: header-only-test +Configuring done (0.1s) +CMake Warning (dev) in CMakeLists.txt: + CMake's support for `import std;` in C++23 and newer is experimental. It + is meant only for experimentation and feedback to CMake developers. +This warning is for project developers. Use -Wno-dev to suppress it. + +Generating done (0.0s) +Build files have been written to: /Users/clausklein/Workspace/cpp/cxx20/fmt-module/build/dev/tests/find-package-test +======== End CMake output ====== +Change Dir: '/Users/clausklein/Workspace/cpp/cxx20/fmt-module/build/dev/tests/find-package-test' + +Run Clean Command: /Users/clausklein/.local/bin/ninja clean +[1/1] Cleaning all built files... +Cleaning... 22 files. + +Run Build Command(s): /Users/clausklein/.local/bin/ninja +[1/12] Scanning /usr/local/Cellar/gcc/15.2.0/include/c++/15/bits/std.compat.cc for CXX dependencies +[2/12] Scanning /usr/local/Cellar/gcc/15.2.0/include/c++/15/bits/std.cc for CXX dependencies +[3/12] Generating CXX dyndep file 'CMakeFiles/__CMAKE__CXX23@synth_439f33eb51e5.dir/CXX.dd' +[4/12] Scanning /Users/clausklein/Workspace/cpp/cxx20/fmt-module/stagedir/lib/cmake/fmt/module/fmt.cppm for CXX dependencies +[5/12] Generating CXX dyndep file 'CMakeFiles/fmt__fmt@synth_439f33eb51e5.dir/CXX.dd' +[6/12] Scanning /Users/clausklein/Workspace/cpp/cxx20/fmt-module/tests/header-only-test.cc for CXX dependencies +[7/12] Generating CXX dyndep file CMakeFiles/module_header-only-test.dir/CXX.dd +[8/12] Building CXX object 'CMakeFiles/__CMAKE__CXX23@synth_439f33eb51e5.dir/67f69854274c.bmi' +[9/12] Building CXX object 'CMakeFiles/__CMAKE__CXX23@synth_439f33eb51e5.dir/1ccb32d972a2.bmi' +[10/12] Building CXX object 'CMakeFiles/fmt__fmt@synth_439f33eb51e5.dir/f6569b67b774.bmi' +[11/12] Building CXX object CMakeFiles/module_header-only-test.dir/Users/clausklein/Workspace/cpp/cxx20/fmt-module/tests/header-only-test.cc.o +[12/12] Linking CXX executable module_header-only-test +FAILED: [code=1] module_header-only-test +: && /usr/local/bin/g++-15 -stdlib=libstdc++ -O3 -DNDEBUG -Wl,-search_paths_first -Wl,-headerpad_max_install_names -stdlib=libstdc++ CMakeFiles/module_header-only-test.dir/Users/clausklein/Workspace/cpp/cxx20/fmt-module/tests/header-only-test.cc.o -o module_header-only-test /Users/clausklein/Workspace/cpp/cxx20/fmt-module/stagedir/lib/libfmt.a && : +Undefined symbols for architecture x86_64: + "initializer for module std", referenced from: + initializer for module fmt in libfmt.a[2](fmt.cppm.o) + "initializer for module std.compat", referenced from: + __GLOBAL__sub_I_header_only_test.cc in header-only-test.cc.o +ld: symbol(s) not found for architecture x86_64 +collect2: error: ld returned 1 exit status +ninja: build stopped: subcommand failed. -FAILED: tests/CMakeFiles/header-only-test.dir/header-only-test.cc.obj -C:\ProgramData\chocolatey\bin\ccache.exe -C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\MSVC\1441~1.341\bin\Hostx86\x86\cl.exe -/nologo /TP -DFMT_MODULE -DFMT_USE_FCNTL=0 --IC:\Users\KLEIN_CL\Workspace\cpp\fmt-module\build\dev\_deps\fmt-src\include -/DWIN32 /D_WINDOWS /EHsc /O2 /Ob2 /DNDEBUG -std:c++latest -MD /utf-8 -/showIncludes -@tests\CMakeFiles\header-only-test.dir\header-only-test.cc.obj.modmap -/Fotests\CMakeFiles\header-only-test.dir\header-only-test.cc.obj -/Fdtests\CMakeFiles\header-only-test.dir\ /FS -c -C:\Users\KLEIN_CL\Workspace\cpp\fmt-module\tests\header-only-test.cc -ninja: build stopped: subcommand failed. +0% tests passed, 1 tests failed out of 1 +Total Test time (real) = 9.91 sec -C:\Users\KLEIN_CL\Workspace\cpp\fmt-module> +The following tests FAILED: + 1 - find-package-test (Failed) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index c8691e7..7d0c7d0 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -4,35 +4,35 @@ message = Bump version: {current_version} -> {new_version} tag_message = Release v{new_version} tag_name = v{new_version} tag = False -current_version = 11.1.4-rc3 +current_version = 12.1.0-dev1 parse = (?P\d+)\.(?P\d+)\.(?P\d+)([-](?P(dev|rc))+(?P\d+))? -serialize = +serialize = {major}.{minor}.{patch}-{release}{build} {major}.{minor}.{patch} [bumpversion:part:release] first_value = dev optional_value = ga -values = +values = dev rc ga [bumpversion:file:CMakeLists.txt] parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P\d+))? -serialize = +serialize = {major}.{minor}.{patch}.{build} {major}.{minor}.{patch} [bumpversion:file:tests/CMakeLists.txt] parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P\d+))? -serialize = +serialize = {major}.{minor}.{patch}.{build} {major}.{minor}.{patch} [bumpversion:file:module/tests/CMakeLists.txt] parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P\d+))? -serialize = +serialize = {major}.{minor}.{patch}.{build} {major}.{minor}.{patch} diff --git a/.bumpversion.md b/.bumpversion.md index ddcf372..92db590 100644 --- a/.bumpversion.md +++ b/.bumpversion.md @@ -5,7 +5,6 @@ bumpversion flow: 1.0.0 => 1.0.1-dev0 => 1.0.1-dev1 = > 1.0.1-rc0 => 1.0.1-rc1 => 1.0.1 patch build release build release - ## Details Start with an initial release, say `1.0.0`. @@ -34,14 +33,12 @@ Start with an initial release, say `1.0.0`. git tag => v1.0.1-rc1 CMake PROJECT_VERSION => 1.0.1.1 -4. Finally, bump `release` to generate a final release for the current - `major` / `minor` / `patch` version. +5. Finally, bump `release` to generate a final release for the current `major` / `minor` / `patch` version. $ bumpversion release --tag git tag => v1.0.1 CMake PROJECT_VERSION => 1.0.1 - ## Notes * Once the final release has been reached, it is not possible to bump @@ -50,14 +47,12 @@ Start with an initial release, say `1.0.0`. `ValueError: The part has already the maximum value among ['dev', 'rc', 'ga'] and cannot be bumped`. * A whole version string may be set with: - bumpversion --new-version 11.1.4-rc2 --tag release + bumpversion --new-version 12.1.0 release --no-commit --no-tag --allow-dirty -# Reference +## Reference To install bumpversion: - pip install --upgrade bump2version - -https://github.com/c4urself/bump2version#installation -https://cmake.org/cmake/help/latest/variable/PROJECT_VERSION.html#variable:PROJECT_VERSION + pipx install bump2version +[cmke PROJECT_VERSION](https://cmake.org/cmake/help/latest/variable/PROJECT_VERSION.html#variable:PROJECT_VERSION) diff --git a/.cmake-format b/.cmake-format deleted file mode 100644 index 2448418..0000000 --- a/.cmake-format +++ /dev/null @@ -1,30 +0,0 @@ -parse: - additional_commands: - foo: - flags: - - BAR - - BAZ - kwargs: - NAME: '1' - DEPENDS: '*' - HEADERS: '*' - SOURCES: '*' - -format: - dangle_parens: true - keyword_case: upper - line_ending: unix - line_width: 120 - max_lines_hwrap: 3 - max_pargs_hwrap: 8 - max_rows_cmdline: 3 - max_subgroups_hwrap: 4 - min_prefix_chars: 8 - separate_ctrl_name_with_space: false - separate_fn_name_with_space: false - tab_size: 2 - -markup: - bullet_char: '*' - enum_char: . - enable_markup: false diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 841d094..8f050d4 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -22,7 +22,7 @@ jobs: with: {python-version: "3.12"} - name: Install codespell - run: pip3 install codespell + run: pip3 install codespell cmake # - name: Lint # if: always() @@ -46,9 +46,16 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: {python-version: "3.12"} + + - name: Install codespell + run: pip3 install codespell cmake ninja + + - name: Install LCov run: sudo apt-get update -q - && sudo apt-get install ninja-build lcov -q -y + && sudo apt-get install lcov -q -y - name: Configure run: cmake --preset=ci-coverage @@ -78,10 +85,16 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup ninja build toolchain - uses: aminya/setup-cpp@v1 - with: - ninja: true + - uses: actions/setup-python@v5 + with: {python-version: "3.12"} + + - name: Install codespell + run: pip3 install codespell cmake ninja + + # - name: Setup ninja build toolchain + # uses: aminya/setup-cpp@v1 + # with: + # ninja: true - name: Configure run: cmake --preset=ci-sanitize @@ -113,10 +126,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup ninja build toolchain - uses: aminya/setup-cpp@v1 - with: - ninja: true + - uses: actions/setup-python@v5 + with: {python-version: "3.12"} + + - name: Install codespell + run: pip3 install codespell cmake ninja - name: Install static analyzers if: matrix.os == 'ubuntu-24.04' @@ -124,32 +138,28 @@ jobs: # Not used! sudo apt-get install cppcheck -y -q wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 19 all + sudo ./llvm.sh 20 all sudo update-alternatives --install \ /usr/bin/clang-tidy clang-tidy \ - /usr/bin/clang-tidy-19 150 + /usr/bin/clang-tidy-20 150 - - name: Install llvm-19 + - name: Install gcc-15 if: startsWith(matrix.os, 'macos') run: | - brew install llvm@19 - echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> /Users/runner/.envrc - echo 'export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"' >> /Users/runner/.envrc - echo 'export CPPFLAGS="-L/opt/homebrew/opt/llvm/include"' >> /Users/runner/.envrc - - # see https://github.com/mathstuf/cxx-modules-sandbox/blob/master/.github/workflows/cmake.yml - - name: Visual Studio toolchain environment - uses: TheMrMilchmann/setup-msvc-dev@v1 + brew install gcc + echo 'export CXX=g++-15' >> /Users/runner/.envrc + # brew install llvm@21 + # echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> /Users/runner/.envrc + # echo 'export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"' >> /Users/runner/.envrc + # echo 'export CPPFLAGS="-L/opt/homebrew/opt/llvm/include"' >> /Users/runner/.envrc + + # # see https://github.com/marketplace/actions/enable-developer-command-prompt + - uses: ilammy/msvc-dev-cmd@v1 if: matrix.os == 'windows-2022' with: + vsversion: 2022 arch: x64 - # # see https://github.com/marketplace/actions/enable-developer-command-prompt - # - uses: ilammy/msvc-dev-cmd@v1 - # if: matrix.os == 'windows-2022' - # with: - # vsversion: 2022 - - name: Configure windows if: matrix.os == 'windows-2022' run: | @@ -162,13 +172,14 @@ jobs: shell: bash run: | source /Users/runner/.envrc - which clang++ && clang++ --version - CXX=$(brew --prefix llvm@19)/bin/clang++ cmake --preset=ci-macos + cmake --preset=ci-macos + # which clang++ && clang++ --version + # CXX=$(brew --prefix llvm@21)/bin/clang++ cmake --preset=ci-macos - name: Configure ubuntu if: matrix.os == 'ubuntu-24.04' env: - CXX: clang++-19 + CXX: clang++-20 run: cmake --preset=ci-ubuntu - name: Build @@ -209,7 +220,7 @@ jobs: with: {python-version: "3.12"} - name: Install m.css dependencies - run: pip3 install ninja jinja2 Pygments + run: pip3 install ninja jinja2 Pygments cmake - name: Install Doxygen run: sudo apt-get update -q diff --git a/.gitignore b/.gitignore index 7d81070..48b6f7d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,8 @@ test-driver /*.cpp /*.hpp ### cmake-init generated: +compile_commands.json +.cache/ .git .github/ .idea/ diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..21c2849 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,10 @@ +# MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md033.md +# Disable inline html linter is needed for
+MD033: false + +# MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md013.md +# Conforms to .clang-format ColumnLimit +# Update the comment in .clang-format if we no-longer tie these two column limits. +MD013: + line_length: 119 + code_blocks: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3c08dea --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,45 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + exclude: ^fmt\.(patch|diff)$ + - id: end-of-file-fixer + - id: check-yaml + exclude: ^\.clang-(format|tidy)$ + - id: check-added-large-files + + # Clang-format for C++ + # This brings in a portable version of clang-format. + # See also: https://github.com/ssciwr/clang-format-wheel + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v21.1.7 + hooks: + - id: clang-format + types_or: [c++, c, json] + + # CMake linting and formatting + - repo: https://github.com/BlankSpruce/gersemi + rev: 0.23.2 + hooks: + - id: gersemi + name: CMake linting + exclude: ^.*/tests/.*/data/ # Exclude test data directories + + # Markdown linting + # Config file: .markdownlint.yaml + # Commented out to disable this by default. Uncomment to enable markdown linting. + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.46.0 + hooks: + - id: markdownlint + + - repo: https://github.com/codespell-project/codespell + rev: v2.4.1 + hooks: + - id: codespell + args: ["--write"] + +exclude: 'build/' diff --git a/BUILDING.md b/BUILDING.md index 97d4c6b..f880a46 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -33,6 +33,13 @@ variable to provide them to CMake during configuration. CMake supports building on Apple Silicon properly since 3.20.1. Make sure you have the [latest version][1] installed. +```sh +CXX=c++ cmake -S . -B build -G Ninja -D CMAKE_CXX_SCAN_FOR_MODULES=NO -D CMAKE_BUILD_TYPE=Release -D FMT_DEVELOPER_MODE=YES --fresh +ninja -C build all_verify_interface_header_sets +ninja -C build build install +ninja -C build build tests +``` + ## Install This project doesn't require any special command-line flags to install to keep diff --git a/CMakeLists.txt b/CMakeLists.txt index d05287e..2b0ccbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,204 +1,245 @@ # CMake 3.30 is required for C++23 `import std` support; -cmake_minimum_required(VERSION 3.30...4.0) +cmake_minimum_required(VERSION 3.30...4.2) include(cmake/prelude.cmake) +option( + CMAKE_CXX_SCAN_FOR_MODULES + "Whether to scan C++ source files for module dependencies" + ON +) +option(BUILD_SHARED_LIBS "Build using shared libraries" NO) + # Set experimental flag to enable `import std` support from CMake. # This must be enabled before C++ language support. if(CMAKE_CXX_SCAN_FOR_MODULES) - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD 0e5b6991-d74f-4b3d-a41c-cf096e0b2508) + set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD + "d0edc3af-4c50-42ea-a356-e2862fe7a444" + ) endif() -project(fmt - VERSION 11.1.4.3 - DESCRIPTION "A modern formatting library" - HOMEPAGE_URL https://fmt.dev/11.0/ - LANGUAGES CXX +#================================================== +project( + fmt + VERSION 12.1.0.1 + DESCRIPTION "A modern formatting library" + HOMEPAGE_URL https://fmt.dev/12.0/ + LANGUAGES CXX ) +#================================================== include(cmake/variables.cmake) set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_EXTENSIONS ON) -set(CMAKE_CXX_SCAN_FOR_MODULES ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_DEBUG_POSTFIX D) -# to prevent -Winclude-angled-in-module-purview in fmt/os.h -# see /Users/clausklein/.cache/CPM/fmt/297020319ba1d5d14e1599714def59a1788711c5/include/fmt/os.h:33 -set(CPPdefinitions FMT_USE_FCNTL=0) -set(ADD_STDLIB_MODULES) +set(CMAKE_SKIP_TEST_ALL_DEPENDENCY OFF) -option(FMT_SEPARATE_COMPILATION "build fmt lib too" ${CMAKE_CXX_SCAN_FOR_MODULES}) -if(NOT MSVC) - option(FMT_USE_MODULES "Export a CXX_MODULE fmt if possible" ${CMAKE_CXX_SCAN_FOR_MODULES}) - option(FMT_IMPORT_STD "Import the module std" ${FMT_USE_MODULES}) -endif() +# FIXME: to prevent -Winclude-angled-in-module-purview in fmt/os.h +# see /Users/clausklein/.cache/CPM/fmt/6226dc0d560c5dca8bcd81db09f7e2752ccb8cef/include/fmt/os.h:33 +set(CPPdefinitions FMT_USE_FCNTL=0) +option(FMT_SEPARATE_COMPILATION "build fmt lib too" ${PROJECT_IS_TOP_LEVEL}) +option( + FMT_USE_MODULES + "Export a CXX_MODULE fmt if possible" + ${CMAKE_CXX_SCAN_FOR_MODULES} +) +option(FMT_IMPORT_STD "Import the module std" ${FMT_USE_MODULES}) if(CMAKE_GENERATOR STREQUAL "Ninja" AND FMT_USE_MODULES) - list(APPEND CPPdefinitions FMT_MODULE) - # FIXME: NO! list(APPEND CPPdefinitions FMT_ATTACH_TO_GLOBAL_MODULE) - - if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0) - if(APPLE) - execute_process(OUTPUT_VARIABLE LLVM_PREFIX COMMAND brew --prefix llvm@19 COMMAND_ECHO STDOUT) - string(STRIP ${LLVM_PREFIX} LLVM_PREFIX) - elseif(LINUX) - set(LLVM_PREFIX $ENV{LLVM_ROOT}) + list(APPEND CPPdefinitions FMT_MODULE) + # FIXME: NO! list(APPEND CPPdefinitions FMT_ATTACH_TO_GLOBAL_MODULE) + + if( + CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0 + ) + if(APPLE) + execute_process( + OUTPUT_VARIABLE LLVM_PREFIX + COMMAND brew --prefix llvm + COMMAND_ECHO STDOUT + ) + string(STRIP ${LLVM_PREFIX} LLVM_PREFIX) + elseif(LINUX) + set(LLVM_PREFIX $ENV{LLVM_DIR}) + endif() + + # # /usr/local/opt/llvm/share/libc++/v1/std.cppm + # # or /usr/lib/llvm-19/share/libc++/v1/std.cppm + # set(LLVM_LIBC_SOURCE ${LLVM_PREFIX}/share/libc++/v1 CACHE PATH "") + # file(REAL_PATH ${LLVM_PREFIX} LLVM_DIR) + # set(LLVM_DIR ${LLVM_DIR} CACHE PATH "") + # message(STATUS "LLVM_DIR=${LLVM_DIR}") + + # add_compile_options(-fexperimental-library) + # add_link_options(-L${LLVM_DIR}/lib/c++ -lc++experimental) + add_compile_options(-stdlib=libc++) + add_link_options(-stdlib=libc++) + elseif( + CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0 + ) + add_compile_options(-stdlib=libstdc++) + add_link_options(-stdlib=libstdc++) endif() - # /usr/local/opt/llvm/share/libc++/v1/std.cppm - if(LLVM_PREFIX) - message(STATUS "LLVM_PREFIX=${LLVM_PREFIX}") - file(REAL_PATH ${LLVM_PREFIX} LLVM_ROOT) - message(STATUS "LLVM_ROOT=${LLVM_ROOT}") - set(LLVM_ROOT ${LLVM_ROOT} CACHE PATH "") - - set(LLVM_LIBC_SOURCE ${LLVM_ROOT}/share/libc++/v1 CACHE PATH "") - if(EXISTS ${LLVM_LIBC_SOURCE}/std.cppm) - message(STATUS "LLVM_LIBC_SOURCE=${LLVM_LIBC_SOURCE}") - set(ADD_STDLIB_MODULES stdlib) - endif() + # Tell CMake that we explicitly want `import std`. + # This will initialize the property on all targets declared after this to 1 + if(${CMAKE_CXX_STANDARD} IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD) + set(CMAKE_CXX_MODULE_STD ON) endif() - add_compile_options(-fexperimental-library) - add_link_options(-L${LLVM_ROOT}/lib/c++ -lc++experimental) - add_compile_options(-stdlib=libc++) - add_link_options(-stdlib=libc++) - - # Build the stdlib module - function(add_stdlib_module NAME) - add_library(${NAME}) - # cmake-format: off - target_sources(${NAME} PUBLIC - FILE_SET CXX_MODULES - BASE_DIRS ${LLVM_LIBC_SOURCE} - FILES - ${LLVM_LIBC_SOURCE}/std.cppm - ${LLVM_LIBC_SOURCE}/std.compat.cppm - ) - # cmake-format: on - target_compile_features(${NAME} PUBLIC cxx_std_23) - target_compile_definitions(${NAME} PUBLIC _LIBCPP_HAS_NO_LOCALIZATION) - target_compile_options(${NAME} PRIVATE -Wno-reserved-module-identifier) - endfunction() - - endif() - - # Tell CMake that we explicitly want `import std`. - # This will initialize the property on all targets declared after this to 1 - if(CMAKE_CXX_COMPILER_IMPORT_STD) - set(CMAKE_CXX_MODULE_STD ON) - endif() - - if(CMAKE_CXX_MODULE_STD OR ADD_STDLIB_MODULES) - # FIXME: NO! list(APPEND CPPdefinitions FMT_IMPORT_STD) - list(APPEND CPPdefinitions HAS_STDLIB_MODULES) - endif() - - message(STATUS "CMAKE_CXX_COMPILER_IMPORT_STD=${CMAKE_CXX_COMPILER_IMPORT_STD}") - - message(STATUS "CPPdefinitions=${CPPdefinitions}") -else() - set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL}) -endif() + if(CMAKE_CXX_MODULE_STD) + list(APPEND CPPdefinitions FMT_IMPORT_STD) + endif() -if(MSVC) - include(cmake/example.cmake) + message( + STATUS + "CMAKE_CXX_COMPILER_IMPORT_STD=${CMAKE_CXX_COMPILER_IMPORT_STD}" + ) + message(STATUS "CMAKE_CXX_SCAN_FOR_MODULES=${CMAKE_CXX_SCAN_FOR_MODULES}") + message(STATUS "CMAKE_CXX_MODULE_STD=${CMAKE_CXX_MODULE_STD}") + message(STATUS "CPPdefinitions=${CPPdefinitions}") +else() + option(CMAKE_VERIFY_INTERFACE_HEADER_SETS "" ${PROJECT_IS_TOP_LEVEL}) endif() # ---- add dependency libraries ---- include(cmake/CPM.cmake) -# cmake-format: off cpmaddpackage( - NAME fmt - GITHUB_REPOSITORY fmtlib/fmt - GIT_TAG 11.1.4 - VERSION 11.1.4 - DOWNLOAD_ONLY ON + NAME fmt + GITHUB_REPOSITORY fmtlib/fmt + GIT_TAG 12.1.0 + VERSION 12.1.0 + DOWNLOAD_ONLY ON + # NO! PATCH_COMMAND git apply -p 1 ${CMAKE_CURRENT_SOURCE_DIR}/fmt.patch ) -# cmake-format: on -# ---- Declare library ---- +# ----------------------------------------- +# ---- Collect the fmt library sources ---- +# ----------------------------------------- -# TODO: only if needed (compare) and possible! -if(EXISTS ${fmt_SOURCE_DIR}/src/fmt.cc AND NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/module/fmt.cppm) - configure_file(${fmt_SOURCE_DIR}/src/fmt.cc ${CMAKE_CURRENT_SOURCE_DIR}/module/fmt.cppm COPYONLY) +# TODO(CK): manually apply the patch if needed (compare) and possible! +if( + EXISTS ${fmt_SOURCE_DIR}/src/fmt.cc + AND NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/module/fmt.cppm +) + configure_file( + ${fmt_SOURCE_DIR}/src/fmt.cc + ${CMAKE_CURRENT_SOURCE_DIR}/module/fmt.cppm + COPYONLY + ) endif() -configure_file(${fmt_SOURCE_DIR}/src/format.cc ${CMAKE_CURRENT_SOURCE_DIR}/module/format.cc COPYONLY) -configure_file(${fmt_SOURCE_DIR}/src/os.cc ${CMAKE_CURRENT_SOURCE_DIR}/module/os.cc COPYONLY) -file(GLOB_RECURSE _fmt_all_sources "module/*.cc") +configure_file( + ${fmt_SOURCE_DIR}/src/format.cc + ${CMAKE_CURRENT_SOURCE_DIR}/module/format.cc + COPYONLY +) +configure_file( + ${fmt_SOURCE_DIR}/src/os.cc + ${CMAKE_CURRENT_SOURCE_DIR}/module/os.cc + COPYONLY +) + +file( + GLOB_RECURSE _fmt_all_sources + CONFIGURE_DEPENDS + RELATIVE ${CMAKE_CURRENT_LIST_DIR} + module/*.cc +) + +# ----------------------------------------- +# ----------------------------------------- -# fmt interface library +# +# build the fmt interface library +# add_library(fmt-header-only INTERFACE) add_library(fmt::fmt-header-only ALIAS fmt-header-only) -file(GLOB_RECURSE _fmt_public_header "${fmt_SOURCE_DIR}/include/fmt/*.h") +file( + GLOB_RECURSE _fmt_public_header + CONFIGURE_DEPENDS + # NO! RELATIVE ${fmt_SOURCE_DIR}/include + ${fmt_SOURCE_DIR}/include/fmt/*.h +) target_sources( - fmt-header-only INTERFACE FILE_SET HEADERS BASE_DIRS ${fmt_SOURCE_DIR}/include FILES ${_fmt_public_header} + fmt-header-only + INTERFACE + FILE_SET HEADERS + BASE_DIRS ${fmt_SOURCE_DIR}/include + FILES ${_fmt_public_header} ) target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY) -target_compile_features( - fmt-header-only INTERFACE "$<$:cxx_std_23>" - "$<$>:cxx_std_20>" -) +target_compile_features(fmt-header-only INTERFACE cxx_std_23) # Unicode support requires compiling with /utf-8. -target_compile_options(fmt-header-only INTERFACE $<$,$>:/utf-8>) +target_compile_options( + fmt-header-only + INTERFACE $<$,$>:/utf-8> +) +# +# build the fmt library +# if(FMT_SEPARATE_COMPILATION) - # file(GLOB_RECURSE _fmt_all_sources "${fmt_SOURCE_DIR}/src/*.cc") - - add_library(fmt STATIC) - target_sources( - fmt PUBLIC FILE_SET public_headers TYPE HEADERS BASE_DIRS ${fmt_SOURCE_DIR}/include FILES ${_fmt_public_header} - ) - - target_compile_definitions(fmt PUBLIC ${CPPdefinitions}) - target_compile_options(fmt PUBLIC $<$,$>:/utf-8>) - target_compile_features( - fmt INTERFACE "$<$:cxx_std_23>" "$<$>:cxx_std_20>" - ) - - if(FMT_USE_MODULES) - add_library(fmt::fmt_module ALIAS fmt) - # cmake-format: off - target_sources(fmt PUBLIC - FILE_SET public_modules - TYPE CXX_MODULES - BASE_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/module - FILES - ${CMAKE_CURRENT_SOURCE_DIR}/module/fmt.cppm - ) - # cmake-format: on - else() + add_library(fmt) add_library(fmt::fmt ALIAS fmt) - set_target_properties(fmt PROPERTIES CXX_SCAN_FOR_MODULES OFF) - target_sources(fmt PRIVATE ${_fmt_all_sources}) - endif() + target_sources( + fmt + PUBLIC + FILE_SET public_headers + TYPE HEADERS + BASE_DIRS ${fmt_SOURCE_DIR}/include + FILES ${_fmt_public_header} + ) - if(FMT_WARNINGS_AS_ERRORS AND FMT_DEVELOPER_MODE AND UNIX) - target_compile_options(fmt PRIVATE -Werror) - endif() + target_compile_definitions(fmt PUBLIC ${CPPdefinitions}) + target_compile_options( + fmt + PUBLIC $<$,$>:/utf-8> + ) + target_compile_features(fmt INTERFACE cxx_std_23) + + if(FMT_USE_MODULES) + message(STATUS "FMT_USE_MODULES=${FMT_USE_MODULES}") + target_sources( + fmt + PUBLIC + FILE_SET public_modules + TYPE CXX_MODULES + BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/module + FILES ${CMAKE_CURRENT_SOURCE_DIR}/module/fmt.cppm + ) + else() + message(WARNING "Missing or disabled support for CXX_MODULES!") + target_sources(fmt PRIVATE ${_fmt_all_sources}) + endif() + + if(FMT_WARNINGS_AS_ERRORS AND FMT_DEVELOPER_MODE AND UNIX) + target_compile_options(fmt PRIVATE -Werror) + endif() endif() # ---- Install rules ---- if(NOT CMAKE_SKIP_INSTALL_RULES) - include(cmake/install-rules.cmake) + include(cmake/install-rules.cmake) endif() # ---- Developer mode ---- if(NOT FMT_DEVELOPER_MODE) - return() + return() elseif(NOT PROJECT_IS_TOP_LEVEL) - message(AUTHOR_WARNING "Developer mode is intended for developers of fmt") + message(AUTHOR_WARNING "Developer mode is intended for developers of fmt") endif() include(cmake/dev-mode.cmake) diff --git a/CMakePresets.json b/CMakePresets.json index 1793721..eac1b3a 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,8 +1,8 @@ { - "version": 4, + "version": 8, "cmakeMinimumRequired": { "major": 3, - "minor": 23, + "minor": 28, "patch": 0 }, "configurePresets": [ @@ -12,13 +12,13 @@ "warnings": { "dev": true, "deprecated": true, - "uninitialized": false, + "uninitialized": true, "unusedCli": true, "systemVars": false }, "errors": { "dev": false, - "deprecated": true + "deprecated": false } }, { @@ -26,6 +26,9 @@ "hidden": true, "inherits": "cmake-pedantic", "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": true, + "CMAKE_MESSAGE_LOG_LEVEL": "VERBOSE", + "CMAKE_VERIFY_INTERFACE_HEADER_SETS": true, "FMT_DEVELOPER_MODE": true } }, @@ -68,8 +71,8 @@ }, "environment": { "CXX": "clang++", - "LLVM_ROOT": "/usr/lib/llvm-19", - "PATH": "$env{LLVM_ROOT}/bin:$penv{PATH}" + "LLVM_DIR": "/usr/lib/llvm-20", + "PATH": "$env{LLVM_DIR}/bin:$penv{PATH}" }, "condition": { "type": "equals", @@ -95,10 +98,11 @@ "description": "Note that all the flags after /W3 are required for MSVC to conform to the language standard", "hidden": true, - "cacheVariables": { - "CMAKE_CXX_COMPILER": "cl", - "CMAKE_CXX_FLAGS_RELEASE": "/W3 /permissive- /volatile:iso /Zc:inline /Zc:preprocessor /Zc:enumTypes /Zc:lambda /Zc:__cplusplus /Zc:externConstexpr /Zc:throwingNew /EHsc" - }, + "cacheVariables": { + "CMAKE_CXX_COMPILER": "cl", + "CMAKE_CXX_FLAGS_RELEASE": + "/W3 /permissive- /volatile:iso /Zc:inline /Zc:preprocessor /Zc:enumTypes /Zc:lambda /Zc:__cplusplus /Zc:externConstexpr /Zc:throwingNew /EHsc" + }, "condition": { "type": "equals", "lhs": "${hostSystemName}", diff --git a/GNUmakefile b/GNUmakefile index 6e84c68..8fda6db 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,42 +1,54 @@ # Standard stuff .SUFFIXES: -$(VERBOSE).SILENT: -MAKEFLAGS+= --no-builtin-rules -MAKEFLAGS+= --warn-undefined-variables +MAKEFLAGS+= --no-builtin-rules # Disable the built-in implicit rules. +# MAKEFLAGS+= --warn-undefined-variables # Warn when an undefined variable is referenced. +# MAKEFLAGS+= --include-dir=$(CURDIR)/conan # Search DIRECTORY for included makefiles (*.mk). export hostSystemName=$(shell uname) ifeq (${hostSystemName},Darwin) - export LLVM_PREFIX:=$(shell brew --prefix llvm@19) - export LLVM_ROOT:=$(shell realpath ${LLVM_PREFIX}) + export LLVM_PREFIX=$(shell brew --prefix llvm) + export LLVM_DIR=$(shell realpath ${LLVM_PREFIX}) + export PATH:=${LLVM_DIR}/bin:${PATH} - #XXX export LDFLAGS?=-L${LLVM_ROOT}/lib/c++ - export PATH:=${LLVM_ROOT}/bin:${PATH} - export CXX:=clang++ + export CMAKE_CXX_STDLIB_MODULES_JSON=${LLVM_DIR}/lib/c++/libc++.modules.json + export CXX=clang++ + export LDFLAGS=-L$(LLVM_DIR)/lib/c++ -lc++abi -lc++ -lc++experimental + export GCOV="llvm-cov gcov" + + ### TODO: to test g++-15: + export GCC_PREFIX=$(shell brew --prefix gcc) + export GCC_DIR=$(shell realpath ${GCC_PREFIX}) + + # export CMAKE_CXX_STDLIB_MODULES_JSON=${GCC_DIR}/lib/gcc/current/libstdc++.modules.json + # export CXX:=g++-15 + # export CXXFLAGS:=-stdlib=libstdc++ + # export GCOV="gcov" else ifeq (${hostSystemName},Linux) - export LLVM_ROOT:=/usr/lib/llvm-19 - export PATH:=${LLVM_ROOT}/bin:${PATH} - export CXX:=clang++-19 + export LLVM_DIR=/usr/lib/llvm-20 + export PATH:=${LLVM_DIR}/bin:${PATH} + export CXX=clang++-20 endif .PHONY: all check test example format clean distclean all: .init - cmake --workflow --preset dev --fresh + cmake --workflow --preset dev -format: - git ls-files ::*.cmake ::*CMakeLists.txt | xargs cmake-format -i - git clang-format master +format: distclean + codespell -w + git ls-files ::*CMakeLists.txt ::*.cmake ::*.cmake.in | xargs gersemi -i + git ls-files ::*.cxx ::*.cpp ::*.hpp ::*.cppm ::*.json | xargs clang-format -i check: all run-clang-tidy -p build/dev -checks='-*,misc-header-*,misc-include-*' tests -ninja -C build/dev spell-check test: - cmake --preset ci-${hostSystemName} - cmake --build build -- -v -j 1 - cmake --install build --prefix $(CURDIR)/stagedir + # cmake --preset ci-${hostSystemName} --fresh + # cmake --build build + # cmake --install build --prefix $(CURDIR)/stagedir cmake -G Ninja -B build/tests -S tests -D CMAKE_PREFIX_PATH=$(CURDIR)/stagedir cmake --build build/tests -- -v -j 1 ctest --test-dir build/tests @@ -46,9 +58,11 @@ example: cmake --build build/example -- -v ctest --test-dir build/example --verbose -.init: requirements.txt .CMakeUserPresets.json +.init: requirements.txt .CMakeUserPresets.json CMakeLists.txt GNUmakefile perl -p -e 's//${hostSystemName}/;' .CMakeUserPresets.json > CMakeUserPresets.json -pip3 install --user --upgrade -r requirements.txt + cmake --preset dev --fresh --log-level=VERBOSE + ln -sf build/dev/compile_commands.json . touch .init clean: @@ -62,6 +76,5 @@ GNUmakefile :: ; *.json :: ; # Anything we don't know how to build will use this rule. -# The command is a do-nothing command. -# -% :: ; +% :: + ninja -C build/dev $(@) diff --git a/HACKING.md b/HACKING.md index 731de4d..9ae30f7 100644 --- a/HACKING.md +++ b/HACKING.md @@ -6,6 +6,16 @@ potential contributor. If you plan to contribute, please read the [CONTRIBUTING](CONTRIBUTING.md) guide. +## Prerequisites + +### Install pre-commit and update cmake + +```sh +pipx install cmake +pipx install pre-commit +pre-commit install --install-hooks +``` + ## Developer mode Build system targets that are only useful for developers of this project are diff --git a/README.md b/README.md index 35f2131..29b6cce 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,23 @@ # fmt-module -## based on / use https://github.com/fmtlib/fmt +## use [fmtlib/fmt](https://github.com/fmtlib/fmt) -### This is a cmake fmt adapter project to test the fmt c++22 module +### This is a cmake fmt adapter project to test the fmt C++20 Module -- https://www.kitware.com/import-std-in-cmake-3-30/ -- https://crascit.com/2024/04/04/cxx-modules-cmake-shared-libraries -- https://anarthal.github.io/cppblog/modules2 -- [ C++ Modules and cross platform - Daniela Engert - Meeting C++ 2023](https://www.youtube.com/watch?v=iMNML689qlU) +- [import std in CMake 3.30](https://www.kitware.com/import-std-in-cmake-3-30/) +- [C++20 Modules, CMake, And Shared Libraries](https://crascit.com/2024/04/04/cxx-modules-cmake-shared-libraries) +- [C++20 modules and Boost: deep dive](https://anarthal.github.io/cppblog/modules2) +- [C++ Modules and cross platform - Daniela Engert - Meeting C++ 2023](https://www.youtube.com/watch?v=iMNML689qlU) -# Building and installing +## Building and installing See the [BUILDING](BUILDING.md) document. -# Contributing +## Contributing See the [CONTRIBUTING](CONTRIBUTING.md) document. -# Licensing +## Licensing