mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-28 19:25:27 +08:00
Merge pull request #1042 from KindDragon/gflags-static
[gflags] Fix bug with static linking
This commit is contained in:
commit
946bff8619
46
ports/gflags/fix-install.patch
Normal file
46
ports/gflags/fix-install.patch
Normal file
@ -0,0 +1,46 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 3fd9d70..0debb89 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -397,11 +397,11 @@ endif ()
|
||||
# ----------------------------------------------------------------------------
|
||||
# installation directories
|
||||
if (OS_WINDOWS)
|
||||
- set (RUNTIME_INSTALL_DIR Bin)
|
||||
- set (LIBRARY_INSTALL_DIR Lib)
|
||||
- set (INCLUDE_INSTALL_DIR Include)
|
||||
- set (CONFIG_INSTALL_DIR CMake)
|
||||
- set (PKGCONFIG_INSTALL_DIR)
|
||||
+ set (RUNTIME_INSTALL_DIR "bin")
|
||||
+ set (LIBRARY_INSTALL_DIR "lib")
|
||||
+ set (INCLUDE_INSTALL_DIR "include")
|
||||
+ set (CONFIG_INSTALL_DIR "share/${PACKAGE_NAME}")
|
||||
+ set (PKGCONFIG_INSTALL_DIR "")
|
||||
else ()
|
||||
set (RUNTIME_INSTALL_DIR bin)
|
||||
# The LIB_INSTALL_DIR and LIB_SUFFIX variables are used by the Fedora
|
||||
@@ -501,14 +501,22 @@ configure_file (cmake/version.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-co
|
||||
if (BUILD_SHARED_LIBS AND INSTALL_SHARED_LIBS)
|
||||
foreach (opts IN ITEMS "" _nothreads)
|
||||
if (BUILD_gflags${opts}_LIB)
|
||||
- install (TARGETS gflags${opts}_shared DESTINATION ${LIBRARY_INSTALL_DIR} EXPORT ${EXPORT_NAME})
|
||||
+ install (TARGETS gflags${opts}_shared
|
||||
+ EXPORT ${EXPORT_NAME}
|
||||
+ RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
|
||||
+ LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
|
||||
+ ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR})
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif ()
|
||||
if (BUILD_STATIC_LIBS AND INSTALL_STATIC_LIBS)
|
||||
foreach (opts IN ITEMS "" _nothreads)
|
||||
if (BUILD_gflags${opts}_LIB)
|
||||
- install (TARGETS gflags${opts}_static DESTINATION ${LIBRARY_INSTALL_DIR} EXPORT ${EXPORT_NAME})
|
||||
+ install (TARGETS gflags${opts}_static
|
||||
+ EXPORT ${EXPORT_NAME}
|
||||
+ RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
|
||||
+ LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
|
||||
+ ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR})
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif ()
|
13
ports/gflags/fix-static-linking.patch
Normal file
13
ports/gflags/fix-static-linking.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/src/gflags.h.in b/src/gflags.h.in
|
||||
index 43b3f7a..82e640f 100644
|
||||
--- a/src/gflags.h.in
|
||||
+++ b/src/gflags.h.in
|
||||
@@ -86,7 +86,7 @@
|
||||
|
||||
// We always want to export variables defined in user code
|
||||
#ifndef GFLAGS_DLL_DEFINE_FLAG
|
||||
-# ifdef _MSC_VER
|
||||
+# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
|
||||
# define GFLAGS_DLL_DEFINE_FLAG __declspec(dllexport)
|
||||
# else
|
||||
# define GFLAGS_DLL_DEFINE_FLAG
|
@ -1,17 +1,23 @@
|
||||
include(vcpkg_common_functions)
|
||||
find_program(GIT git)
|
||||
|
||||
vcpkg_download_distfile(ARCHIVE
|
||||
URLS "https://github.com/gflags/gflags/archive/v2.2.0.zip"
|
||||
FILENAME "gflags-v2.2.0.zip"
|
||||
SHA512 638d094cdcc759a35ebd0e57900216deec6113242d2dcc964beff7b88cf56e3dbab3dce6e10a055bfd94cb5daebb8632382219a5ef40a689e14c76b263d3eca5)
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO gflags/gflags
|
||||
REF v2.2.0
|
||||
SHA512 e2106ca70ff539024f888bca12487b3bf7f4f51928acf5ae3e1022f6bbd5e3b7882196ec50b609fd52f739e1f7b13eec7d4b3535d8216ec019a3577de6b4228d
|
||||
HEAD_REF master
|
||||
)
|
||||
|
||||
vcpkg_extract_source_archive(${ARCHIVE})
|
||||
|
||||
set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/gflags-2.2.0)
|
||||
vcpkg_apply_patches(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PATCHES "${CMAKE_CURRENT_LIST_DIR}/fix-install.patch"
|
||||
PATCHES "${CMAKE_CURRENT_LIST_DIR}/fix-static-linking.patch"
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
-DGFLAGS_REGISTER_BUILD_DIR:BOOL=OFF
|
||||
-DGFLAGS_REGISTER_INSTALL_PREFIX:BOOL=OFF
|
||||
@ -19,40 +25,11 @@ vcpkg_configure_cmake(
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
vcpkg_fixup_cmake_targets()
|
||||
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
|
||||
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/gflags.dll ${CURRENT_PACKAGES_DIR}/bin/gflags.dll)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/gflags.dll ${CURRENT_PACKAGES_DIR}/debug/bin/gflags.dll)
|
||||
endif()
|
||||
|
||||
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/cmake ${CURRENT_PACKAGES_DIR}/share/gflags)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
||||
|
||||
file(READ ${CURRENT_PACKAGES_DIR}/debug/cmake/gflags-targets-debug.cmake GFLAGS_DEBUG_MODULE)
|
||||
string(REPLACE "\${_IMPORT_PREFIX}" "\${_IMPORT_PREFIX}/debug" GFLAGS_DEBUG_MODULE "${GFLAGS_DEBUG_MODULE}")
|
||||
string(REPLACE "/Lib/gflags.dll" "/bin/gflags.dll" GFLAGS_DEBUG_MODULE "${GFLAGS_DEBUG_MODULE}")
|
||||
string(REPLACE "/Lib/gflags_nothreads.dll" "/bin/gflags_nothreads.dll" GFLAGS_DEBUG_MODULE "${GFLAGS_DEBUG_MODULE}")
|
||||
file(WRITE ${CURRENT_PACKAGES_DIR}/share/gflags/gflags-targets-debug.cmake "${GFLAGS_DEBUG_MODULE}")
|
||||
|
||||
file(READ ${CURRENT_PACKAGES_DIR}/share/gflags/gflags-targets-release.cmake GFLAGS_RELEASE_MODULE)
|
||||
string(REPLACE "/Lib/gflags.dll" "/bin/gflags.dll" GFLAGS_RELEASE_MODULE "${GFLAGS_RELEASE_MODULE}")
|
||||
string(REPLACE "/Lib/gflags_nothreads.dll" "/bin/gflags_nothreads.dll" GFLAGS_RELEASE_MODULE "${GFLAGS_RELEASE_MODULE}")
|
||||
file(WRITE ${CURRENT_PACKAGES_DIR}/share/gflags/gflags-targets-release.cmake "${GFLAGS_RELEASE_MODULE}")
|
||||
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/cmake)
|
||||
|
||||
file(READ ${CURRENT_PACKAGES_DIR}/share/gflags/gflags-targets.cmake GFLAGS_CONFIG_MODULE)
|
||||
string(REPLACE "get_filename_component(_IMPORT_PREFIX \"\${_IMPORT_PREFIX}\" PATH)"
|
||||
"get_filename_component(_IMPORT_PREFIX \"\${_IMPORT_PREFIX}\" PATH)\nget_filename_component(_IMPORT_PREFIX \"\${_IMPORT_PREFIX}\" PATH)"
|
||||
GFLAGS_CONFIG_MODULE "${GFLAGS_CONFIG_MODULE}")
|
||||
file(WRITE ${CURRENT_PACKAGES_DIR}/share/gflags/gflags-targets.cmake "${GFLAGS_CONFIG_MODULE}")
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
|
||||
|
||||
file(INSTALL ${SOURCE_PATH}/COPYING.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/gflags RENAME copyright)
|
||||
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/Include ${CURRENT_PACKAGES_DIR}/include)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/Lib ${CURRENT_PACKAGES_DIR}/lib)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/Lib ${CURRENT_PACKAGES_DIR}/debug/lib)
|
||||
|
||||
vcpkg_copy_pdbs()
|
||||
|
Loading…
x
Reference in New Issue
Block a user