diff --git a/CMakeLists.txt b/CMakeLists.txt index d0acd5774..6f696383a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -352,7 +352,8 @@ if(WIN32) endif() if(MSVC) - target_compile_definitions(gpsbabel PRIVATE _CRT_SECURE_NO_DEPRECATE) + target_compile_definitions(gpsbabel PRIVATE _CRT_SECURE_NO_WARNINGS) + target_compile_definitions(gpsbabel PRIVATE _CRT_NONSTDC_NO_WARNINGS) target_compile_options(gpsbabel PRIVATE /MP -wd4100 -wd4267) endif() diff --git a/GPSBabel.pro b/GPSBabel.pro index 47b2be048..c852797fe 100644 --- a/GPSBabel.pro +++ b/GPSBabel.pro @@ -338,9 +338,20 @@ win32 { } win32-msvc* { - DEFINES += _CRT_SECURE_NO_DEPRECATE - QMAKE_CFLAGS += /MP -wd4100 -wd4267 - QMAKE_CXXFLAGS += /MP -wd4100 -wd4267 + DEFINES += _CRT_SECURE_NO_WARNINGS + DEFINES += _CRT_NONSTDC_NO_WARNINGS + QMAKE_CFLAGS += /MP -wd4267 + QMAKE_CXXFLAGS += /MP -wd4267 + # The -wd (disable warning) and -w3 (change warning to level 3) options are exclusive. + # The win32-msvc makespec uses -w34100, which can interfer with -wd4100. + # Their are two qmake settings for warnings in CONFIG: warn_on and warn_off. + # This results in the warning showing with msbuild, but not with nmake, even if + # -wd4100 is included in QMAKE_CFLAGS and QMAKE_CXXFLAGS. + # Override win32-msvc, leaving these warnings at their default of level 4, which + # will not show up because we run at level 3. + # shapelib/shpopen.c can cause a C4100 error. + QMAKE_CFLAGS_WARN_ON -= -w34100 + QMAKE_CXXFLAGS_WARN_ON -= -w34100 } include(shapelib.pri) diff --git a/defs.h b/defs.h index c093020de..b08b45f8a 100644 --- a/defs.h +++ b/defs.h @@ -126,19 +126,6 @@ constexpr double KNOTS_TO_MPS(double a) {return a * kMPSPerKnot;} #define CENTI_TO_MICRO(t) ((t) * 10000) /* Centiseconds to Microseconds */ #define MICRO_TO_CENTI(t) ((t) / 10000) /* Centiseconds to Microseconds */ -#if __WIN32__ -# ifndef fileno -# define fileno _fileno -# endif -# define strdup _strdup -#endif - -#if __WIN32__ -#if !defined _CRT_SECURE_NO_DEPRECATE -# define _CRT_SECURE_NO_DEPRECATE 1 -#endif -#endif - /* Pathname separator character */ #if __WIN32__ # define GB_PATHSEP '\\' diff --git a/shapelib.cmake b/shapelib.cmake index 0d53c71ac..d52f28e3c 100644 --- a/shapelib.cmake +++ b/shapelib.cmake @@ -19,6 +19,11 @@ else() # note gpsbabel has conditional code include "shapelib/shapefil.h", # so it doesn't actually rely on the include directory being PUBLIC/INTERFACE target_include_directories(shp PUBLIC shape) + if(MSVC) + target_compile_definitions(shp PRIVATE _CRT_SECURE_NO_WARNINGS) + target_compile_definitions(shp PRIVATE _CRT_NONSTDC_NO_WARNINGS) + target_compile_options(shp PRIVATE /MP -wd4100 -wd4267) + endif() list(APPEND LIBS shp) elseif(GPSBABEL_WITH_SHAPELIB STREQUAL "custom") message(STATUS "shapelib is enabled but but must be manually configured.") diff --git a/zlib.cmake b/zlib.cmake index 950b57833..6f1fe6fda 100644 --- a/zlib.cmake +++ b/zlib.cmake @@ -54,6 +54,11 @@ else() target_compile_definitions(z PRIVATE HAVE_STDARG_H) endif() endif() + if(MSVC) + target_compile_definitions(z PRIVATE _CRT_SECURE_NO_WARNINGS) + target_compile_definitions(z PRIVATE _CRT_NONSTDC_NO_WARNINGS) + target_compile_options(z PRIVATE /MP -wd4100 -wd4267) + endif() target_include_directories(z PUBLIC zlib) list(APPEND LIBS z) elseif(GPSBABEL_WITH_ZLIB STREQUAL "custom")