From 265d7f9a003d7d03eaf6a0c4daa4bec690faa4d4 Mon Sep 17 00:00:00 2001 From: Jeff McKenna Date: Fri, 13 Mar 2026 13:00:40 -0300 Subject: [PATCH 1/5] avoid C4996 warning on MSVC --- libgeotiff/bin/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libgeotiff/bin/CMakeLists.txt b/libgeotiff/bin/CMakeLists.txt index 9ce8cf5..99b8682 100644 --- a/libgeotiff/bin/CMakeLists.txt +++ b/libgeotiff/bin/CMakeLists.txt @@ -13,6 +13,12 @@ INCLUDE_DIRECTORIES( IF(WIN32 AND MSVC) SET(GETOPT_SOURCE getopt.c) ENDIF() + +# avoid warnings of "This function or variable may be unsafe" +if(MSVC) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) +endif() + ############################################################################### # Collect programs to build From 0136f313548071f28d8cc6887437d53c96956fb0 Mon Sep 17 00:00:00 2001 From: Jeff McKenna Date: Fri, 13 Mar 2026 13:19:36 -0300 Subject: [PATCH 2/5] restrict flag to utilities Co-authored-by: Even Rouault --- libgeotiff/bin/CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libgeotiff/bin/CMakeLists.txt b/libgeotiff/bin/CMakeLists.txt index 99b8682..3bde91d 100644 --- a/libgeotiff/bin/CMakeLists.txt +++ b/libgeotiff/bin/CMakeLists.txt @@ -29,6 +29,21 @@ MESSAGE(STATUS "Adding GeoTIFF utilities to build") FOREACH(utility ${GEOTIFF_UTILITIES}) ADD_EXECUTABLE(${utility} ${utility}.c ${GETOPT_SOURCE}) TARGET_LINK_LIBRARIES(${utility} PRIVATE ${GEOTIFF_LIBRARY_TARGET}) + +############################################################################### +# Collect programs to build + +SET(GEOTIFF_UTILITIES makegeo listgeo applygeo) + +MESSAGE(STATUS "Adding GeoTIFF utilities to build") + +FOREACH(utility ${GEOTIFF_UTILITIES}) + ADD_EXECUTABLE(${utility} ${utility}.c ${GETOPT_SOURCE}) + TARGET_LINK_LIBRARIES(${utility} PRIVATE ${GEOTIFF_LIBRARY_TARGET}) + # avoid warnings of "This function or variable may be unsafe" + if(MSVC) + target_compile_definitions(${utility} PRIVATE -D_CRT_SECURE_NO_WARNINGS) + endif() ENDFOREACH() ADD_EXECUTABLE(geotifcp geotifcp.c ${GETOPT_SOURCE}) From d088962f00d7d42a0fe76e21f9633b0c3e9a09c4 Mon Sep 17 00:00:00 2001 From: Jeff McKenna Date: Fri, 13 Mar 2026 13:28:25 -0300 Subject: [PATCH 3/5] remove original Co-authored-by: Even Rouault --- libgeotiff/bin/CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libgeotiff/bin/CMakeLists.txt b/libgeotiff/bin/CMakeLists.txt index 3bde91d..371f84d 100644 --- a/libgeotiff/bin/CMakeLists.txt +++ b/libgeotiff/bin/CMakeLists.txt @@ -13,12 +13,6 @@ INCLUDE_DIRECTORIES( IF(WIN32 AND MSVC) SET(GETOPT_SOURCE getopt.c) ENDIF() - -# avoid warnings of "This function or variable may be unsafe" -if(MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) -endif() - ############################################################################### # Collect programs to build From 517271afbbb9a2f189cfad14e97f59f8636edff7 Mon Sep 17 00:00:00 2001 From: Jeff McKenna Date: Fri, 13 Mar 2026 13:30:35 -0300 Subject: [PATCH 4/5] cleanup --- libgeotiff/bin/CMakeLists.txt | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/libgeotiff/bin/CMakeLists.txt b/libgeotiff/bin/CMakeLists.txt index 371f84d..4d8ef5a 100644 --- a/libgeotiff/bin/CMakeLists.txt +++ b/libgeotiff/bin/CMakeLists.txt @@ -23,21 +23,10 @@ MESSAGE(STATUS "Adding GeoTIFF utilities to build") FOREACH(utility ${GEOTIFF_UTILITIES}) ADD_EXECUTABLE(${utility} ${utility}.c ${GETOPT_SOURCE}) TARGET_LINK_LIBRARIES(${utility} PRIVATE ${GEOTIFF_LIBRARY_TARGET}) - -############################################################################### -# Collect programs to build - -SET(GEOTIFF_UTILITIES makegeo listgeo applygeo) - -MESSAGE(STATUS "Adding GeoTIFF utilities to build") - -FOREACH(utility ${GEOTIFF_UTILITIES}) - ADD_EXECUTABLE(${utility} ${utility}.c ${GETOPT_SOURCE}) - TARGET_LINK_LIBRARIES(${utility} PRIVATE ${GEOTIFF_LIBRARY_TARGET}) - # avoid warnings of "This function or variable may be unsafe" - if(MSVC) + # avoid warnings of "This function or variable may be unsafe" + if(MSVC) target_compile_definitions(${utility} PRIVATE -D_CRT_SECURE_NO_WARNINGS) - endif() + endif() ENDFOREACH() ADD_EXECUTABLE(geotifcp geotifcp.c ${GETOPT_SOURCE}) From b40859b9c21f3423f496ced94496cfc32c4a44e0 Mon Sep 17 00:00:00 2001 From: Jeff McKenna Date: Fri, 13 Mar 2026 13:43:06 -0300 Subject: [PATCH 5/5] handle warning for geotifcp --- libgeotiff/bin/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libgeotiff/bin/CMakeLists.txt b/libgeotiff/bin/CMakeLists.txt index 4d8ef5a..e9fce21 100644 --- a/libgeotiff/bin/CMakeLists.txt +++ b/libgeotiff/bin/CMakeLists.txt @@ -36,6 +36,9 @@ TARGET_LINK_LIBRARIES(geotifcp ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES}) target_include_directories(geotifcp PRIVATE $) +if(MSVC) + target_compile_definitions(geotifcp PRIVATE -D_CRT_SECURE_NO_WARNINGS) +endif() SET(GEOTIFF_UTILITIES ${GEOTIFF_UTILITIES} geotifcp )