I would like to use a global set of flags to compile the project, which means that in my top-level CMakeLists.txt file, I specified:
ADD_DEFINITIONS ( -Wall -Weffc++ -pedantic -std=c++0x )
However, for a specific file (say, "foo.cpp") in a subdirectory, I want to switch compile flags so that I don't use -WeffC ++ (including a commercial library that I cannot change). To simplify things, to use only -Wall, I tried:
SET_SOURCE_FILES_PROPERTIES( foo.cpp PROPERTIES COMPILE_FLAGS -Wall ) ADD_EXECUTABLE( foo foo.cpp )
which did not work. I also tried
SET_PROPERTY( SOURCE foo.cpp PROPERTY COMPILE_FLAGS -Wall ) ADD_EXECUTABLE( foo foo.cpp )
and
ADD_EXECUTABLE( foo foo.cpp ) SET_TARGET_PROPERTIES( foo PROPERTIES COMPILE_FLAGS -Wall )
which did not work.
Finally, I tried to remove this error:
REMOVE_DEFINITIONS( -Weffc++ ) ADD_EXECUTABLE( foo foo.cpp ) ADD_DEFINITIONS( -Weffc++ )
which also didnβt work (that is, I get a lot of style warnings in the commercial library). (** Note: ARE warnings are suppressed if I DO NOT re-enable the -WeffC ++ directive after creating the executable.)
I also tried temporarily removing the compilation flags: http://www.cmake.org/pipermail/cmake/2007-June/014614.html , but that didn't help.
Is there an elegant solution for this?
c ++ compiler-warnings cmake
JB Brown Nov 30 2018-12-12T00: 00Z
source share