I'd like to write assert in C++23 with CMake and multiple build modes as mentioned in https://learnmoderncpp.com/2020/02/10/writing-assert-in-cpp/ to use modules, meaning without preprocessor.
Do you have practical examples for that? Searching for "C++ extern constexpr" turned up no meaningful results.
#Practical examples to use 'extern constexpr bool' from CMake?
22 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
if you want to pass information from cmake to your code, defining macros is still the most straightforward way
you can still do that with modules
the only other way I could think of is using cmake to generate the source code defining your ReleaseBuild constants or whatever
yes, you could do that, but why would you
and with modules, you can keep them private
nobody will be exposed to the macros just because they import your assert stuff
sorta 😛
sometimes 😛
Since C++ named modules left the experimental state in CMake (see import CMake; the Experiment is Over!), CMake development has continued to add more support for modules. The most recent development is the experimental support of import std;. C++23 introduced support for APIs to be available via the named module std. This means that import […]
still experimental support in cmake, only works on some compiler + stdlib + os combos
maybe @sacred magnet likes living on the bleeding edge
I'd expect apps or libs to offer a reasonable named default module for configuring hardening etc.
However, I guess you are saying that because there is so far no standard cli for reproducing module interaction,
so using macros is simpler?!
"reasonably named default module"?
"reproducing module interaction"??
that is what I was expecting would be simple to do nowadays?
it is not difficult, see the links by Arni above, but why would you tie your library to code generation done by cmake
when there are easier ways to affect the compilation... using compiler flags
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
Interesting article with a different take on build time options:
https://vector-of-bool.github.io/2020/10/04/lib-configuration.html
though it does rely on headers
In which I present a novel, portable, and nonintrustive approach to build-time configuration