Skip to content
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

Can messages in CMakeLists.txt be optional? #478

Closed
Unarelith opened this issue Apr 29, 2020 · 6 comments
Closed

Can messages in CMakeLists.txt be optional? #478

Unarelith opened this issue Apr 29, 2020 · 6 comments
Assignees
Labels
build system requests or issues related to the build system

Comments

@Unarelith
Copy link

In the CMakeLists.txt, could it be possible to add a variable to toggle the display of those messages?

entt/CMakeLists.txt

Lines 40 to 43 in dfc1861

message("*")
message("* ${PROJECT_NAME} v${PROJECT_VERSION} (${CMAKE_BUILD_TYPE})")
message("* Copyright (c) 2017-2020 Michele Caini <michele.caini@gmail.com>")
message("*")

message(WARNING "The option USE_LIBCPP is set (by default) but libc++ is not available. The flag will not be added to the target.")

From all the libraries I'm using in my project, EnTT is the only one to talk about itself in the CMake log:

 $ cmake -B build .; and cmake --build build -j8
-- Submodule update
*
* EnTT v3.4.0 (RelWithDebInfo)
* Copyright (c) 2017-2020 Michele Caini <michele.caini@gmail.com>
*
CMake Warning at external/entt/CMakeLists.txt:66 (message):
  The option USE_LIBCPP is set (by default) but libc++ is not available.  The
  flag will not be added to the target.


-- Configuring done
-- Generating done
-- Build files have been written to: /home/bazin_q/Projects/Games/OpenMiner/build
[  9%] Built target sfml-system
[ 37%] Built target gamekit
[ 43%] Built target sfml-network
[ 55%] Built target openminer_common
[ 75%] Built target openminer_server_lib
[ 76%] Built target openminer_server
[100%] Built target openminer

against:

 $ cmake -B build .; and cmake --build build -j8
-- Submodule update
-- Configuring done
-- Generating done
-- Build files have been written to: /home/bazin_q/Projects/Games/OpenMiner/build
[  9%] Built target sfml-system
[ 37%] Built target gamekit
[ 43%] Built target sfml-network
[ 55%] Built target openminer_common
[ 75%] Built target openminer_server_lib
[ 76%] Built target openminer_server
[100%] Built target openminer
@skypjack skypjack self-assigned this Apr 29, 2020
@skypjack skypjack added the build system requests or issues related to the build system label Apr 29, 2020
@skypjack
Copy link
Owner

I think that setting the cmake's message mode to VERBOSE is enough. Does it solve your problem?

@Unarelith
Copy link
Author

For the first messages, setting message to VERBOSE is fine, thanks.

However about this change:

option(USE_LIBCPP "Use libc++ by adding -stdlib=libc++ flag if availbale." OFF)
  • I think it should stay ON, but if you want to keep it OFF you'll also need to remove the (by default) in the warning message
  • There was a typo "availbale" -> "available"

I think that a good way to make this warning optional would be to add a variable to toggle it.

@skypjack
Copy link
Owner

I think it should stay ON

Yeah, I thought the same yesterday. I'm changing it soon.

I think that a good way to make this warning optional would be to add a variable to toggle it.

Well, in fact, there exists already a way to toggle it. You can set the USE_LIBCPP option to OFF. Doesn't it work for you?

@Unarelith
Copy link
Author

Well, in fact, there exists already a way to toggle it. You can set the USE_LIBCPP option to OFF. Doesn't it work for you?

I still want to use libc++ by default, but I don't want the warning to appear each time I run cmake. :/

@skypjack
Copy link
Owner

Oh, I see what you mean. You distribute your application, so you don't know what's on the target platform and you don't want to set an option to OFF by default.
I think we can safely set also that message to VERBOSE rather than to WARNING. I don't see any problem with this. It's informative but it doesn't cause any problem.

@Unarelith
Copy link
Author

Unarelith commented Apr 30, 2020

Debian 9 and Ubuntu 16 users needs to either upgrade their libstdc++ (not trivial) or install libc++ to have a C++17-compliant library. That's why I think ON is the best default value for that option.

Setting this message to verbose could be a way to do it, yes, since you'll still see:

-- Performing Test HAS_LIBCPP
-- Performing Test HAS_LIBCPP - Failed

But setting it to verbose makes it less noticeable for people that actually cares about the warning. That's why I though a specific variable to disable the warning would be a nice way.

Some users could do set(USE_LIBCPP_WARN OFF) or something alike to disable the warning, while other people will still get the expected result.

But it's just my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system requests or issues related to the build system
Projects
None yet
Development

No branches or pull requests

2 participants