Add Separate CMake Target for C++20 Modules#4685
Conversation
9b4e055 to
8c91cc2
Compare
vitaut
left a comment
There was a problem hiding this comment.
Adding a module target is a good idea but there are too many unrelated refactors in this PR. Please keep add_module_library and avoid unrelated changes (you can submit separate PR(s) for those).
- Fixed the gramatical error in the documents changed in the pull request. - Fix formatting, particularly on the newly added code
834161d to
b09d295
Compare
|
I have tried to make the requested changes. I have restored the Removed functions to the CMakeLists.txt file. However, I marked the Kindly advise if the change is agreeable. |
b09d295 to
57f7b58
Compare
57f7b58 to
779d3ff
Compare
bash-5.3$ cmake -G Ninja -S . -B build --fresh -D CMAKE_CXX_STANDARD=17
-- CMake version: 4.2.1
-- The CXX compiler identification is AppleClang 16.0.0.16000026
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Ninja Version: 1.13.0.git.kitware.jobserver-pipe-1
-- Using CXX Modules by Default with Ninja <<<<<<<<<<<<<< he?
-- {fmt} version: 12.1.1
-- Build type: Release
-- Performing Test HAS_NULLPTR_WARNING
-- Performing Test HAS_NULLPTR_WARNING - Success
-- Target 'doc' disabled because mkdocs not found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- FMT_PEDANTIC: OFF
-- The C compiler identification is AppleClang 16.0.0.16000026
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (2.7s)
CMake Error in CMakeLists.txt:
The target named "fmt-module" has C++ sources that may use modules, but the
compiler does not provide a way to discover the import graph dependencies.
See the cmake-cxxmodules(7) manual for details. Use the
CMAKE_CXX_SCAN_FOR_MODULES variable to enable or disable scanning.
-- Generating done (0.0s)
CMake Generate step failed. Build files cannot be regenerated correctly.
bash-5.3$ |
|
you may have a look at ClausKlein#1 |
23fb90f to
eda54d5
Compare
@ClausKlein I have just seen this and noted the changes needed in the |
I was wondering, I could not open a PR against your repo? |
eda54d5 to
3bdec83
Compare
I don't know why this didn't work, but I have incorporated the commit in the workflow. the tests for FMT_MODULE are still excluded, but the ordinary tests should now work. This can be solved in another pull request and issue. |
In the same vein as there is the `fmt::fmt-header-only`, `fmt::fmt` and `fmt::fmt_c` targets, I propose the addition of a new target `fmt::fmt-module` which will be for the compilation of the FMT_MODULE library option. The new target will have the properties requried for Compiling, Installing and using the C++20 functionality in CMake The `add_module_library` function is marked as deprecated as its functionality is superseded. Updated the logic for setting the FMT_USE_CMAKE_MODULE flag to check the versions for Ninja and MSVC according the CMAKE Documents and setting the FMT_MODULE flag based on this
3bdec83 to
8e0a7d9
Compare
In the same vein as there is the `fmt::fmt-header-only`, `fmt::fmt` and `fmt::fmt_c` targets, I propose the addition of a new target `fmt::fmt-module` which will be for the compilation of the FMT_MODULE library option. The new target will have the properties requried for Compiling, Installing and using the C++20 functionality in CMake Updated the logic for setting the FMT_USE_CMAKE_MODULE flag to check the versions for Ninja and MSVC according the CMAKE Documents and setting the FMT_MODULE flag based on this Fixed the test/CMakeLists.txt file which used the FMT_MODULE flag to separate the module and non-module library testing, in particular disableing the module version. The module testing still needs to be fixed, but the expected behavior of testing the non-modular version is working.
8e0a7d9 to
c217d48
Compare
The CMakeFiles are still unreadable, the control flow is not clear, and the supported version range historic!@MathewBensonCode I Ask to respect the cmake format style if possible. It is not clean yet, but mostly indented by 2 spaces and space after controls: if, else, endif, ... This Files should be formatted with
|
9> ### Since 3.28 there are lot of fixes and improvements for CXX_MODULE handling in CMake
@ClausKlein, thank you for the time you have taken to provide your reviews and comments. I will try and ensure that the code I write has better formatting. It is not a battle, it is usually a lower priority as I want to focus on correctness more. On this matter of the version range, I believe that you are wrong. kindly refer to the documentation for the cmake_minimum_required for the use of the maximum policy. We don't just write the latest version in the command and call it a day. It is meant to be a guarantee of the code we have written. This means we would have to write all the CMake code in this repo to that standard, test it everywhere and only after all that make that statement about the policies that our code supports. That is a big undertaking that will require many other issues and pull requests. The scope and goal of this pull request is simply to add a "modern" target but also to ensure that it doesn't break any expected behavior. This repo is used in many varied environments, modern and legacy, so a lot of care is needed when making changes. I have had to revert several good and modern ideas in this pull request to keep to the scope. I intend to bring those in separate issues and pull requests later. So I appreciate and understand your desire to see modernization, I am pursuing the same goals and I'm certain @vitaut is too. |
|
Merged, thank you! |
|
@ClausKlein please stop spamming the repo or you will be blocked. Improvements to CMake configs are fine but they should be split into independent PRs that tackle one thing at a time. |
In the same vein as there is the
fmt::fmt-header-only,fmt::fmtandfmt::fmt_ctargets, I propose the addition of a new targetfmt::fmt-modulewhich will be for the compilation of the FMT_MODULE library option.The new target will have the properties requried for Compiling, Installing and using the C++20 functionality
The
add_module_libraryCMake function is factored out in favour of simply specifying the targets specifically in a cleaner and simpler CMake syntax.The FMT_MODULE option is defaulted to true for versions of CMake newer than 3.28.
Closes #4684