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

Warning flags are getting propagated #1825

Closed
prateek9623 opened this issue Feb 10, 2021 · 13 comments
Closed

Warning flags are getting propagated #1825

prateek9623 opened this issue Feb 10, 2021 · 13 comments

Comments

@prateek9623
Copy link
Contributor

prateek9623 commented Feb 10, 2021

The shared library of spdlog is propagating MSVC warning flags, which is creating issues while compiling my CUDA based application as NVCC don't play well with MSVC warning flags.

So, can we make this PRIVATE

spdlog/CMakeLists.txt

Lines 134 to 136 in ff6e3c9

if(MSVC)
target_compile_options(spdlog PUBLIC /wd4251 /wd4275)
endif()

Environment
OS: Windows
Compiler: MSVC(14.28.29333), NVCC 11.2

To Reproduce
link with CUDA based application using vcpkg

Expected behavior
the warning should not propagate from spdlog

@gabime
Copy link
Owner

gabime commented Feb 10, 2021

I think making it private would cause warnings for users of spdlog through include, but not sure.

@prateek9623
Copy link
Contributor Author

@gabime I didn't understand, are you saying about spdlog_header_only?

@gabime
Copy link
Owner

gabime commented Feb 10, 2021

No. About users getting the warnings after including spdlog.h if the warning suppression is made private

@prateek9623
Copy link
Contributor Author

ya, it will, but it also prevents in their codebase also. Which is a risk for them. As this warning suppression is not just for spdlog if it is public.

@gabime
Copy link
Owner

gabime commented Feb 10, 2021

I dont see an easy solution for this. If the made private there will be complains about new warnings that suddenly appear.

@prateek9623
Copy link
Contributor Author

prateek9623 commented Feb 10, 2021

If not private can we do something like this:
set(PROJECT_WARNINGS /wd4251 /wd4275)
target_compile_options(spdlog PUBLIC $<$<COMPILE_LANGUAGE:C>:${PROJECT_WARNINGS}> $<$<COMPILE_LANGUAGE:CXX>:${PROJECT_WARNINGS}> )

@tt4g
Copy link
Contributor

tt4g commented Feb 10, 2021

I think we can add an option when the "compiler is MSVC, not CUDA".

target_compile_options(${project_name} INTERFACE
  $<$<AND:$<CXX_COMPILER_ID:MSVC>,$<NOT:$<CXX_COMPILER_ID:NVIDIA>>>:/wd4251 /wd4275>)

CMAKE_ <LANG> _COMPILER_ID list: https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html

@prateek9623
Copy link
Contributor Author

I think we can add an option when the "compiler is MSVC, not CUDA".

target_compile_options(${project_name} INTERFACE
  $<$<AND:$<CXX_COMPILER_ID:MSVC>,$<NOT:$<CXX_COMPILER_ID:NVIDIA>>>:/wd4251 /wd4275>)

CMAKE_ <LANG> _COMPILER_ID list: https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html

this wouldn't work I think as CMAKE_ _COMPILER_ID cant be multiple values

@prateek9623
Copy link
Contributor Author

set(PROJECT_WARNINGS /wd4251 /wd4275)
target_compile_options(spdlog PUBLIC $<AND:$<CXX_COMPILER_ID:MSVC>, 
$<NOT:$<COMPILE_LANGUAGE:CUDA>>>:${PROJECT_WARNINGS}> )

I think this is a more elegant solution, "compiler is MSVC and language is not CUDA"

@prateek9623
Copy link
Contributor Author

@gabime any comment on this?

@gabime
Copy link
Owner

gabime commented Feb 12, 2021

If this fixes your problem, please issue a pr.

@prateek9623
Copy link
Contributor Author

@gabime when should i expect this fix to reflect in vcpkg

@tt4g
Copy link
Contributor

tt4g commented Feb 12, 2021

We do not maintain vcpkg.
Please wait for the vcpkg maintainer's response (microsoft/vcpkg#16153) or send a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants