GNOME Bugzilla – Bug 792883
cmake: no way to turn off -Werror
Last modified: 2018-06-30 00:03:45 UTC
With configure, there was --disable-error-on-warning, but I can't find a similar setting for cmake. The build fails for me on NetBSD-8.99.12/amd64 with boost-1.66.0 with: In file included from /scratch/wip/gnucash-devel/work/.buildlink/include/boost/locale.hpp:17:0, from /scratch/wip/gnucash-devel/work/gnucash-2.7.3/gnucash/import-export/csv-imp/gnc-csv-tokenizer.cpp:11: /scratch/wip/gnucash-devel/work/.buildlink/include/boost/locale/format.hpp:124:22: error: 'template<class> class std::auto_ptr' is deprecated [-Werror=deprecated-declarations] std::auto_ptr<data> d; ^ In file included from /usr/include/g++/memory:81:0, from /scratch/wip/gnucash-devel/work/gnucash-2.7.3/gnucash/import-export/csv-imp/gnc-tokenizer.hpp:46, from /scratch/wip/gnucash-devel/work/gnucash-2.7.3/gnucash/import-export/csv-imp/gnc-csv-tokenizer.hpp:45, from /scratch/wip/gnucash-devel/work/gnucash-2.7.3/gnucash/import-export/csv-imp/gnc-csv-tokenizer.cpp:1: /usr/include/g++/bits/unique_ptr.h:49:28: note: declared here template<typename> class auto_ptr; ^ In file included from /scratch/wip/gnucash-devel/work/.buildlink/include/boost/locale.hpp:19:0, from /scratch/wip/gnucash-devel/work/gnucash-2.7.3/gnucash/import-export/csv-imp/gnc-csv-tokenizer.cpp:11: /scratch/wip/gnucash-devel/work/.buildlink/include/boost/locale/generator.hpp:223:18: error: 'template<class> class std::auto_ptr' is deprecated [-Werror=deprecated-declarations] std::auto_ptr<data> d; ^ In file included from /usr/include/g++/memory:81:0, from /scratch/wip/gnucash-devel/work/gnucash-2.7.3/gnucash/import-export/csv-imp/gnc-tokenizer.hpp:46, from /scratch/wip/gnucash-devel/work/gnucash-2.7.3/gnucash/import-export/csv-imp/gnc-csv-tokenizer.hpp:45, from /scratch/wip/gnucash-devel/work/gnucash-2.7.3/gnucash/import-export/csv-imp/gnc-csv-tokenizer.cpp:1: /usr/include/g++/bits/unique_ptr.h:49:28: note: declared here template<typename> class auto_ptr; ^ In file included from /scratch/wip/gnucash-devel/work/.buildlink/include/boost/locale.hpp:22:0, from /scratch/wip/gnucash-devel/work/gnucash-2.7.3/gnucash/import-export/csv-imp/gnc-csv-tokenizer.cpp:11: /scratch/wip/gnucash-devel/work/.buildlink/include/boost/locale/localization_backend.hpp:107:18: error: 'template<class> class std::auto_ptr' is deprecated +[-Werror=deprecated-declarations] std::auto_ptr<localization_backend> get() const; ^ In file included from /usr/include/g++/memory:81:0, from /scratch/wip/gnucash-devel/work/gnucash-2.7.3/gnucash/import-export/csv-imp/gnc-tokenizer.hpp:46, from /scratch/wip/gnucash-devel/work/gnucash-2.7.3/gnucash/import-export/csv-imp/gnc-csv-tokenizer.hpp:45, from /scratch/wip/gnucash-devel/work/gnucash-2.7.3/gnucash/import-export/csv-imp/gnc-csv-tokenizer.cpp:1: /usr/include/g++/bits/unique_ptr.h:49:28: note: declared here template<typename> class auto_ptr; ^ ...
You can always add your own flags with -DCMAKE_C_FLAGS and -DCMAKE_CXX_FLAGS. CMake will fill those in from $CFLAGS and $CXXFLAGS in the environment if they're defined and you don't explicitly pass the cmake flags. Note that cmake *doesn't* look at $CPPFLAGS and doesn't have an equivalent. As currently written CMakeLists.txt puts them in front (which is bad, that way you can't override the ones supplied by CMakeLists.txt) but you can still turn off the deprecation warning with -DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations". CMakeLists.txt already does that for CMAKE_CXX_FLAGS_DEBUG and that's also wrong.
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" works around the problem. I still claim that the build system should not add -Werror, but the workaround is good enough for me.
I've rearranged the commands which add flags to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS so that command-line provided values will come after the ones set in CMakeLists.txt. That will allow you to pass -DCMAKE_C_FLAGS="-Wno-error" -DCMAKE_CXX_FLAGS="-Wno-error" to disable error-on-warning if you like.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=792883. Please update any external references or bookmarks.