-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reorganize CMake code and add feature summary #3762
base: develop
Are you sure you want to change the base?
Reorganize CMake code and add feature summary #3762
Conversation
0c50092
to
e6a3fcd
Compare
# cmake info | ||
############################################################################# | ||
|
||
message(STATUS "[nohmann_json]: CMake ${CMAKE_VERSION}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This style ("[nohmann_json]: ") is used by range-v3. Makes it more clear where the output is coming from when the project is used via add_subdirectory()
, for example.
e6a3fcd
to
9fc6d2b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
9ea2eb7
to
9360a80
Compare
I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not yet checked whether the new structure feels simpler to me, but only checked the CMake output in a terminal.
Some observations:
-
I think it is a bit too noisy in case the library is just integrated into a bigger project:
-- [nohmann_json]: CMake 3.24.2 -- [nohmann_json]: Host system: Darwin-21.5.0 -- [nohmann_json]: C++ compiler: Apple clang version 14.0.0 (clang-1400.0.29.102) -- [nohmann_json]: Feature summary: Build tests? NO Diagnostics enabled? NO Default integer enum serialization enabled? YES Define user-defined string literals globally? YES Implicit conversions enabled? YES Legacy discarded value comparison enabled? NO Use the multi-header code? YES Include directory: /Users/niels/Code/repositories/json/include/ Include as system headers? NO
To my taste, this is too much output.
-
When using ANSI escapes, one should always make sure if the terminal is supporting them in the first place. I was using
ccmake
and got this output: -
I had my reasons to call tools like
uname
to get better information on the operating system, etc.This is what I got on my system before:
-- Operating system: Darwin-21.5.0; ProductName: macOS; ProductVersion: 12.4; BuildVersion: 21F79; Darwin stewie.fritz.box 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64 -- Compiler: Apple clang version 14.0.0 (clang-1400.0.29.102); Target: arm64-apple-darwin21.5.0; Thread model: posix; InstalledDir: /Library/Developer/CommandLineTools/usr/bin
This is what I get with this PR:
-- [nohmann_json]: Host system: Darwin-21.5.0 -- [nohmann_json]: C++ compiler: Apple clang version 14.0.0 (clang-1400.0.29.102)
To me, "macOS 12.4" is easier to understand than just "Darwin-21.5.0".
What do you suggest? Most features produced some output and it appears that for new features this was simply forgotten. The difference is, that the feature summary will always output something instead of only when a feature is "active" (enabled or disabled depending on the feature). I'd argue that this predictable structure is easier to read and obviates any need to guess whether a feature is enabled or not. In any case, we could disable the output in specific situations, for example:
In this instance, I disagree, but I feel that way about the current OS info output (see below). ;-)
True. Unfortunately, this is probably impossible to do in CMake and I relied on most terminals supporting ANSI codes these days (even Windows supports ANSI now, I learned today) and accepted garbled output to text files. It could be done using Guess I'll remove the escape sequences. Too bad we can't have nice things. :-(
I agree wholeheartedly. I noticed it in CI and then forgot to put in the fix. Here's what the output was supposed to look like:
(On Linux we see some inaccuracies because of virtualization, but that is independent of the tools used. It would be easy to add information about the virtualized environment on most modern distributions using Is that acceptable? In this instance, I find the old output way too verbose and noisy. When is the added information actually helpful and do you not have to ask people to provide the log output anyway, in which case you could also ask for specific command output? Note that the new output will also include a |
581c1d0
to
9ca20c6
Compare
* Add a cache variable and set default from environment. * Add '.git' suffix to URL variable.
9ca20c6
to
239a974
Compare
I've made some modification to the
Using these tools, the output can be adjusted as desired. |
This PR cleans up the CMake code a bit in preparation for adding static library support.
test.cmake
in the main list file and have fewer sections with a single line of code. Alternatively, we could use the old section style, but I find the current choice visually clearer and less awkward for single-line sections.uname
, etc.download_test_data.cmake
intotest.cmake
and makeJSON_TestDataDirectory
configurable via environment variable.ci.cmake
/test.cmake
tojson_*.cmake
.I've held back a few changes that might break stuff and need careful review for a follow-up PR. There're some cosmetic changes affecting the same code that could still be done in this PR, though.
Notes for the follow-up PR:
CMAKE_MEMORYCHECK_COMMAND
is not an official CMake variable? (If so, rename.)