[gdal] fix for building static library (#5839)

This commit is contained in:
JuttaAnders 2019-03-27 19:47:15 +01:00 committed by Phil Christensen
parent 2e04d02e9d
commit c88974a223
3 changed files with 49 additions and 17 deletions

View File

@ -1,9 +1,6 @@
diff -Nuar a/nmake.opt b/nmake.opt
--- a/nmake.opt 2018-05-04 09:05:46.000000000 +0200
+++ b/nmake.opt 2018-05-11 22:58:39.387603800 +0200
@@ -124,11 +124,21 @@
CXX_PDB_FLAGS=
!ENDIF
--- a/nmake.opt Fri Dec 14 22:34:20 2018
+++ b/nmake.opt Wed Mar 27 11:00:00 2019
@@ -133,7 +133,17 @@
+# Flags to choose CRT variant to link against (e.g. static: /MT, /MTd, dynamic: /MD, /MDd)
+# Ensure MRSID_CONFIG in mrsid/nmake.opt is set appropriately as well
@ -16,12 +13,10 @@ diff -Nuar a/nmake.opt b/nmake.opt
+!ENDIF
+
!IFNDEF OPTFLAGS
!IFNDEF DEBUG
!IF "$(DEBUG)" == "0"
-OPTFLAGS= $(CXX_ANALYZE_FLAGS) $(CXX_PDB_FLAGS) /nologo /MP /MD /EHsc /Ox /FC /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DNDEBUG
+OPTFLAGS= $(CXX_ANALYZE_FLAGS) $(CXX_PDB_FLAGS) /nologo /MP $(CXX_CRT_FLAGS) /EHsc /Ox /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DNDEBUG
!ELSE
-OPTFLAGS= $(CXX_ANALYZE_FLAGS) $(CXX_PDB_FLAGS) /nologo /MP /MDd /EHsc /FC /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DDEBUG
+OPTFLAGS= $(CXX_ANALYZE_FLAGS) $(CXX_PDB_FLAGS) /nologo /MP $(CXX_CRT_FLAGS) /EHsc /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DDEBUG
!ENDIF
!ENDIF # OPTFLAGS

View File

@ -0,0 +1,27 @@
--- a/makefile.vc Fri Dec 14 22:34:20 2018
+++ b/makefile.vc Wed Mar 27 11:00:00 2019
@@ -60,3 +60,3 @@
-default: $(TARGET_LIB) $(PLUGIN_TARGET) apps_dir
+default: $(TARGET_LIB) $(PLUGIN_TARGET)
@@ -227,4 +227,2 @@
$(MAKE) /f makefile.vc plugins-install
- cd ..\apps
- $(MAKE) /f makefile.vc install
cd ..
@@ -232,8 +230,2 @@
$(INSTALL) LICENSE.TXT $(DATADIR)
-!IFDEF HTMLDIR
- -mkdir $(HTMLDIR)
- cd frmts
- $(MAKE) /f makefile.vc html-install
- cd ..
-!ENDIF
!IFDEF INCLUDE_OGR_FRMTS
@@ -241,5 +233,2 @@
$(MAKE) /f makefile.vc plugins-install
-!IFDEF HTMLDIR
- $(MAKE) /f makefile.vc html-install
-!ENDIF
cd ..\..

View File

@ -11,9 +11,7 @@ if (TRIPLET_SYSTEM_ARCH MATCHES "arm")
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
message(FATAL_ERROR "GDAL's nmake buildsystem does not support building static libraries")
elseif(VCPKG_CRT_LINKAGE STREQUAL "static")
message(FATAL_ERROR "GDAL's nmake buildsystem does not support static crt linkage")
list(APPEND NMAKE_OPTIONS "DLLBUILD=0")
endif()
include(vcpkg_common_functions)
@ -43,6 +41,7 @@ foreach(BUILD_TYPE IN LISTS BUILD_TYPES)
SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src-${TARGET_TRIPLET}-${BUILD_TYPE}/gdal-${GDAL_VERSION_STR}
PATCHES
${CMAKE_CURRENT_LIST_DIR}/0001-Fix-debug-crt-flags.patch
${CMAKE_CURRENT_LIST_DIR}/0002-Fix-static-build.patch
)
endforeach()
@ -64,8 +63,8 @@ file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}/debug/lib/libpng16d.lib" PNG_LIBRA
# Setup geos libraries + include path
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}/include" GEOS_INCLUDE_DIR)
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}/lib/geos_c.lib" GEOS_LIBRARY_REL)
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}/debug/lib/geos_cd.lib" GEOS_LIBRARY_DBG)
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}/lib/libgeos.lib" GEOS_LIBRARY_REL)
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}/debug/lib/libgeosd.lib" GEOS_LIBRARY_DBG)
# Setup expat libraries + include path
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}/include" EXPAT_INCLUDE_DIR)
@ -155,6 +154,7 @@ endif()
if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
list(APPEND NMAKE_OPTIONS PROJ_FLAGS=-DPROJ_STATIC)
list(APPEND NMAKE_OPTIONS CURL_CFLAGS=-DCURL_STATICLIB)
else()
# Enables PDBs for release and debug builds
list(APPEND NMAKE_OPTIONS WITH_PDB=1)
@ -175,11 +175,14 @@ list(APPEND NMAKE_OPTIONS_REL
EXPAT_LIB=${EXPAT_LIBRARY_REL}
"CURL_LIB=${CURL_LIBRARY_REL} wsock32.lib wldap32.lib winmm.lib"
SQLITE_LIB=${SQLITE_LIBRARY_REL}
PG_LIB=${PGSQL_LIBRARY_REL}
OPENJPEG_LIB=${OPENJPEG_LIBRARY_REL}
WEBP_LIBS=${WEBP_LIBRARY_REL}
LIBXML2_LIB=${XML2_LIBRARY_REL}
)
if(NOT VCPKG_LIBRARY_LINKAGE STREQUAL "static")
# Static Build does not like PG_LIB
list(APPEND NMAKE_OPTIONS_REL PG_LIB=${PGSQL_LIBRARY_REL})
endif()
list(APPEND NMAKE_OPTIONS_DBG
${NMAKE_OPTIONS}
@ -190,12 +193,15 @@ list(APPEND NMAKE_OPTIONS_DBG
EXPAT_LIB=${EXPAT_LIBRARY_DBG}
"CURL_LIB=${CURL_LIBRARY_DBG} wsock32.lib wldap32.lib winmm.lib"
SQLITE_LIB=${SQLITE_LIBRARY_DBG}
PG_LIB=${PGSQL_LIBRARY_DBG}
OPENJPEG_LIB=${OPENJPEG_LIBRARY_DBG}
WEBP_LIBS=${WEBP_LIBRARY_DBG}
LIBXML2_LIB=${XML2_LIBRARY_DBG}
DEBUG=1
)
if(NOT VCPKG_LIBRARY_LINKAGE STREQUAL "static")
# Static Build does not like PG_LIB
list(APPEND NMAKE_OPTIONS_REL PG_LIB=${PGSQL_LIBRARY_DBG})
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
################
@ -226,7 +232,10 @@ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
endif()
message(STATUS "Packaging ${TARGET_TRIPLET}")
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/gdal/html)
if(NOT VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/gdal/html)
endif()
vcpkg_execute_required_process(
COMMAND ${NMAKE} -f makefile.vc
@ -249,6 +258,7 @@ if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(COPY ${SOURCE_PATH_DEBUG}/gdal.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/gdal.lib ${CURRENT_PACKAGES_DIR}/debug/lib/gdald.lib)
endif()
else()
set(GDAL_TOOL_PATH ${CURRENT_PACKAGES_DIR}/tools/gdal)