- 2015.06.16 17:51 "Re: [Tiff] CMake support for building libtiff", by Lee Howard
- 2015.06.17 03:16 "Re: [Tiff] CMake support for building libtiff", by Bob Friesenhahn
-
2015.06.17 22:38 "Re: [Tiff] CMake support for building libtiff", by Roger Leigh
-
2015.06.18 22:08 "Re: [Tiff] CMake support for building libtiff", by Roger Leigh
-
2015.06.19 11:54 "Re: [Tiff] CMake support for building libtiff", by Roger Leigh
-
2015.07.02 07:10 "[Tiff] [patch] Additional CMake fixes", by Roger Leigh
- 2015.07.04 22:10 "Re: [Tiff] [patch] Additional CMake fixes", by Bob Friesenhahn
-
2015.08.29 11:34 "[Tiff] [patch] Docs for cmake build and some minor tweaks", by Roger Leigh
- 2015.08.29 15:36 "Re: [Tiff] [patch] Docs for cmake build and some minor tweaks", by Bob Friesenhahn
-
2015.08.31 15:12 "[Tiff] [patch] cmake fixes", by
- 2015.08.31 15:34 "Re: [Tiff] [patch] cmake fixes", by Bob Friesenhahn
-
2015.07.02 07:10 "[Tiff] [patch] Additional CMake fixes", by Roger Leigh
- 2015.06.19 13:53 "Re: [Tiff] CMake support for building libtiff", by Rhys Thomas
-
2015.06.19 11:54 "Re: [Tiff] CMake support for building libtiff", by Roger Leigh
-
2015.06.19 13:41 "Re: [Tiff] 4.0.4beta: Symbol differences on Unix and Windows", by Bob Friesenhahn
- 2015.06.18 21:56 "[Tiff] 4.0.4beta: Symbol differences on Unix and Windows", by Roger Leigh
-
2015.06.18 22:08 "Re: [Tiff] CMake support for building libtiff", by Roger Leigh
- 2015.06.25 02:32 "Re: [Tiff] CMake support for building libtiff", by Bob Friesenhahn
2015.07.02 07:10 "[Tiff] [patch] Additional CMake fixes", by Roger Leigh
- fixes for snprintf with VS2015 (it was working, but broke with stricter warnings)
- enable a default set of warnings with GCC/clang and MSVC
- add a 'd' suffix for debug libs with MSVC, which seems to be common practice with MSVC and allows debug/release libs to be installed in parallel
Regards,
Roger
From 8299aee17452dbe04c6e1f363d9bd664deea111e Mon Sep 17 00:00:00 2001 From: Roger Leigh <r.leigh@dundee.ac.uk>
Date: Wed, 1 Jul 2015 15:58:20 +0100
Subject: [PATCH 1/3] cmake: Correct snprintf fallback for VS2015
---
CMakeLists.txt | 15 ++++++++++-----
libtiff/tif_config.h.cmake.in | 7 -------
port/CMakeLists.txt | 2 +-
port/libport.h | 2 +-
4 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bdd443d..4828513 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,6 +58,7 @@ set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "tiff@lists.maptools.org")
include(GNUInstallDirs)
+include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
include(CheckIncludeFile)
include(CheckTypeSize)
@@ -314,7 +315,6 @@ check_function_exists(memmove HAVE_MEMMOVE)
check_function_exists(memset HAVE_MEMSET)
check_function_exists(mmap HAVE_MMAP)
check_function_exists(setmode HAVE_SETMODE)
HAVE_SNPRINTF) -check_function_exists(snprintf
check_function_exists(strcasecmp HAVE_STRCASECMP)
check_function_exists(strchr HAVE_STRCHR)
check_function_exists(strrchr HAVE_STRRCHR)
@@ -325,10 +325,15 @@ check_function_exists(strtoull HAVE_STRTOULL)
check_function_exists(getopt HAVE_GETOPT)
check_function_exists(lfind HAVE_LFIND)-# VS2013 has a usable _snprintf
MSVC_VERSION VERSION_LESS 1800 AND MSVC_VERSION VERSION_LESS 1900) -if(NOT
check_function_exists(_snprintf HAVE__SNPRINTF) -
-endif()
+# May be inlined, so check it compiles:
+check_c_source_compiles("
+#include <stdio.h>
+int main(void) {
+ char buf[10];
+ snprintf(buf, 10, \"Test %d\", 1);
+ return 0;
+}"
+ HAVE_SNPRINTF)
# CPU bit order
set(fillorder FILLORDER_MSB2LSB)
diff --git a/libtiff/tif_config.h.cmake.in b/libtiff/tif_config.h.cmake.in
index 61596c3..de0f3a3 100644
--- a/libtiff/tif_config.h.cmake.in
+++ b/libtiff/tif_config.h.cmake.in
@@ -95,13 +95,6 @@
Define to 1 if you have the `snprintf' function. */ /*
HAVE_SNPRINTF 1 #cmakedefine
-/* Define to 1 if you have the `_snprintf' function. */
-#cmakedefine HAVE__SNPRINTF 1
-
-#if !defined(HAVE_SNPRINTF) && defined(HAVE__SNPRINTF)
-#define snprintf _snprintf
-#endif
-
/* Define to 1 if you have the `sqrt' function. */
#cmakedefine HAVE_SQRT 1
diff --git a/port/CMakeLists.txt b/port/CMakeLists.txt
index 354ed4d..8b221d1 100644
--- a/port/CMakeLists.txt
+++ b/port/CMakeLists.txt
@@ -39,7 +39,7 @@ endif()
if(NOT HAVE_LFIND)
list(APPEND port_USED_FILES lfind.c)
endif()
HAVE_SNPRINTF AND NOT HAVE__SNPRINTF) -if(NOT
+if(MSVC AND NOT HAVE_SNPRINTF)
list(APPEND port_USED_FILES snprintf.c)
endif()
if(NOT HAVE_STRCASECMP)
diff --git a/port/libport.h b/port/libport.h
index 909ae1f..d11d074 100644
--- a/port/libport.h
+++ b/port/libport.h
@@ -48,7 +48,7 @@ lfind(const void *key, const void *base, size_t *nmemb, size_t size,
int(*compar)(const void *, const
From 2829e8c216eae89161300930e576da4c2c3da1f8 Mon Sep 17 00:00:00 2001 From: Roger Leigh <r.leigh@dundee.ac.uk>
Date: Wed, 1 Jul 2015 15:59:13 +0100
Subject: [PATCH 2/3] cmake: Add extra warning flags
---
CMakeLists.txt | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4828513..d6c32fa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -91,6 +91,64 @@ set(EXTRA_DIST
nmake.opt
libtiff-4.pc.in)
+# These are annoyingly verbose, produce false positives or don't work
+# nicely with all supported compiler versions, so are disabled unless
+# explicitly enabled.
+option(extra-warnings "Enable extra compiler warnings" OFF)
+
+# This will cause the compiler to fail when an error occurs.
+option(fatal-warnings "Compiler warnings are errors" OFF)
+
+# Check if the compiler supports each of the following additional
+# flags, and enable them if supported. This greatly improves the
+# quality of the build by checking for a number of common problems,
+# some of which are quite serious.
+if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
+ CMAKE_C_COMPILER_ID MATCHES "Clang")
+ set(test_flags
+ -Wall
+ -Winline
+ -W
+ -Wformat-security
+ -Wpointer-arith
+ -Wdisabled-optimization
+ -Wno-unknown-pragmas
+ -Wdeclaration-after-statement
+ -fstrict-aliasing)
+ if(extra-warnings)
+ list(APPEND test_flags
+ -Wfloat-equal
+ -Wmissing-prototypes
+ -Wunreachable-code)
+ endif()
+ if(fatal-warnings)
+ list(APPEND test_flags
+ -Werror)
+ endif()
+elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+ set(test_flags)
+ if(extra-warnings)
+ list(APPEND test_flags
+ /W4)
+ else()
+ list(APPEND test_flags
+ /W3)
+ endif()
+ if (fatal-warnings)
+ list(APPEND test_flags
+ /WX)
+ endif()
+endif()
+
+foreach(flag ${test_flags})
+ string(REGEX REPLACE "[^A-Za-z0-9]" "_" flag_var "${flag}")
+ set(test_c_flag "C_FLAG${flag_var}")
+ CHECK_C_COMPILER_FLAG(${flag} "${test_c_flag}")
+ if (${test_c_flag})
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
+ endif (${test_c_flag})
+endforeach(flag ${test_flags})
+
# Check if LD supports linker scripts.
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
global: sym;
--
2.4.5
From e57dd32dd28e4c0579b41f777895d5ddec3e652a Mon Sep 17 00:00:00 2001 From: Roger Leigh <r.leigh@dundee.ac.uk>
Date: Wed, 1 Jul 2015 15:59:48 +0100
Subject: [PATCH 3/3] cmake: Add d suffix to debug libraries with MSVC
---
CMakeLists.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d6c32fa..d49508a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -149,6 +149,10 @@ foreach(flag ${test_flags})
endif (${test_c_flag})
endforeach(flag ${test_flags})
+if(MSVC)
+ set(CMAKE_DEBUG_POSTFIX "d")
+endif()
+
# Check if LD supports linker scripts.
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
global: sym;
--
2.4.5