@@ -846,8 +846,13 @@ endfunction()
846846# e.g. for '../src/mylib' the destination will be '<system-include-dir>/mylib/'.
847847# @param IDE_FOLDER - folder in the generated IDE project for the library. Optional. Defaults to "Libs".
848848# @param PREPROCESSOR_DEFINITIONS [<def1>[=<val1>] ...] - preprocessor macro definitions. Optional.
849+ # @param NO_EXPORT - if specified, the library will not be exported as a package. Optional.
850+ # @param NO_WARNINGS_AS_ERRORS - if specified, warnings will not be treated as errors. Optional.
849851function (myci_declare_library name )
850- set (options NO_EXPORT)
852+ set (options
853+ NO_EXPORT
854+ NO_WARNINGS_AS_ERRORS
855+ )
851856 set (single
852857 IDE_FOLDER
853858 RESOURCE_DIRECTORY
@@ -898,21 +903,33 @@ function(myci_declare_library name)
898903
899904 # enable sane warnings and other compiler options
900905 if (MSVC )
906+ if (arg_NO_WARNINGS_AS_ERRORS)
907+ set (warnings_as_errors)
908+ else ()
909+ set (warnings_as_errors /WX)
910+ endif ()
911+
901912 target_compile_options (${name} PRIVATE
902913 $<$<COMPILE_LANGUAGE :CXX >:/W4 >
903- $<$< COMPILE_LANGUAGE : CXX >:/ WX > # warnings = errors
914+ ${warnings_as_errors}
904915 # /W4 includes check for non-virtual-destructor.
905916 # There is no equivalent for -fstring-aliasing, as MSVS generally assumes a more conservative aliasing model by default.
906917
907918 # disable some warnings
908919 /wd4458 # local declaration hides class member
909920 )
910921 else ()
922+ if (arg_NO_WARNINGS_AS_ERRORS)
923+ set (warnings_as_errors)
924+ else ()
925+ set (warnings_as_errors -Werror)
926+ endif ()
927+
911928 target_compile_options (${name} PRIVATE
912929 # Enable more warnings only for C++ files.
913930 # We don't care much about C files, as C code is only maintained by 3rd party.
914931 $<$<COMPILE_LANGUAGE :CXX >:-Wall >
915- $<$< COMPILE_LANGUAGE : CXX >:- Werror >
932+ ${warnings_as_errors}
916933 $<$<COMPILE_LANGUAGE :CXX >:-Wnon -virtual -dtor > # only for C++ files
917934 -fstrict-aliasing
918935 )
0 commit comments