rttrorg / rttr

C++ Reflection Library
https://www.rttr.org
MIT License
3.12k stars 430 forks source link

Compile errors when compiling a project with -Werror #294

Open FlexW opened 3 years ago

FlexW commented 3 years ago

In my project, I want that warnings are treated as errors. However, if I add the rttr library to my project with add_subdirectory(rttr) and then link against it with target_link_libraries(RTTR::Core_Lib), my build fails as there are some warnings (that were treated as errors) that come from the rttr library. A solution would be to include the library headers as system headers. I could get along with adding SYSTEM before PUBLIC in target_include_directories in src/rttr/CMakeLists.txt. I'm not an CMake expert so I don't know if thats the right way to do things. Also have a look at this blog post.

Edit: I do add -Werror as a private option to my build target, not as a global flag.

paulhazen commented 3 years ago

This works with visual studio (sorry I don't have much experience outside of visual studio):

This is a section within our precompiled header:

#pragma warning( push )
#pragma warning ( disable : ALL_CODE_ANALYSIS_WARNINGS )

/*
 * Any warnings that would normally be generated by included files here will be suppressed. 
 */

#pragma warning (pop)

You could try and find whatever analogous solution there is for the compiler you are using.

FlexW commented 3 years ago

You could try and find whatever analogous solution there is for the compiler you are using.

This could be a solution, but I think this problem shouldn't occur in the first place. There are a lot of libraries that get build with CMake where I don't have that problem (like glm, assimp, etc.).