aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Christensen <philc@microsoft.com>2018-12-21 07:56:30 -0800
committerGitHub <noreply@github.com>2018-12-21 07:56:30 -0800
commit501abecda7b9997d4492a08114b0a94e78b46007 (patch)
treebf39e2a1b8cbd7e15d3e9fd0aa9be721d19d8e09
parentebe86abcdd6e05e7e52f1f92896f87c78b4e47d3 (diff)
parent3d164e3e4c19e54763fe34bcb9fe2e5bdcafc1d0 (diff)
downloadvcpkg-501abecda7b9997d4492a08114b0a94e78b46007.tar.gz
vcpkg-501abecda7b9997d4492a08114b0a94e78b46007.zip
Merge pull request #4994 from cneumann/fix-spdlog-external-fmt
[spdlog] Fix spdlog handling of external fmt lib
-rw-r--r--ports/spdlog/fmt-external-cmake-option.patch100
-rw-r--r--ports/spdlog/portfile.cmake8
2 files changed, 104 insertions, 4 deletions
diff --git a/ports/spdlog/fmt-external-cmake-option.patch b/ports/spdlog/fmt-external-cmake-option.patch
new file mode 100644
index 000000000..635eb3b23
--- /dev/null
+++ b/ports/spdlog/fmt-external-cmake-option.patch
@@ -0,0 +1,100 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index fc75346..5b3a5c8 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -59,6 +59,12 @@ cmake_dependent_option(SPDLOG_BUILD_TESTING
+ "BUILD_TESTING" OFF
+ )
+
++option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF)
++
++if(SPDLOG_FMT_EXTERNAL)
++ find_package(fmt REQUIRED CONFIG)
++endif()
++
+ target_include_directories(
+ spdlog
+ INTERFACE
+@@ -66,6 +72,11 @@ target_include_directories(
+ "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+ )
+
++if(SPDLOG_FMT_EXTERNAL)
++ target_compile_definitions(spdlog INTERFACE SPDLOG_FMT_EXTERNAL)
++ target_link_libraries(spdlog INTERFACE fmt::fmt)
++endif()
++
+ set(HEADER_BASE "${CMAKE_CURRENT_SOURCE_DIR}/include")
+
+ if(SPDLOG_BUILD_EXAMPLES)
+@@ -88,7 +99,8 @@ set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
+ set(include_install_dir "${CMAKE_INSTALL_INCLUDEDIR}")
+ set(pkgconfig_install_dir "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+ set(version_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
+-set(project_config "${PROJECT_NAME}Config.cmake")
++set(project_config "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake")
++set(targets_config "${PROJECT_NAME}Targets.cmake")
+ set(pkg_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc")
+ set(targets_export_name "${PROJECT_NAME}Targets")
+ set(namespace "${PROJECT_NAME}::")
+@@ -101,6 +113,8 @@ write_basic_package_version_file(
+
+ # configure pkg config file
+ configure_file("cmake/spdlog.pc.in" "${pkg_config}" @ONLY)
++# configure spdlogConfig.cmake file
++configure_file("cmake/Config.cmake.in" "${project_config}" @ONLY)
+
+ # install targets
+ install(
+@@ -114,9 +128,9 @@ install(
+ DESTINATION "${include_install_dir}"
+ )
+
+-# install project version file
++# install project config and version file
+ install(
+- FILES "${version_config}"
++ FILES "${project_config}" "${version_config}"
+ DESTINATION "${config_install_dir}"
+ )
+
+@@ -126,19 +140,19 @@ install(
+ DESTINATION "${pkgconfig_install_dir}"
+ )
+
+-# install project config file
++# install targets config file
+ install(
+ EXPORT "${targets_export_name}"
+ NAMESPACE "${namespace}"
+ DESTINATION "${config_install_dir}"
+- FILE ${project_config}
++ FILE ${targets_config}
+ )
+
+-# export build directory config file
++# export build directory targets file
+ export(
+ EXPORT ${targets_export_name}
+ NAMESPACE "${namespace}"
+- FILE ${project_config}
++ FILE ${targets_config}
+ )
+
+ # register project in CMake user registry
+diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in
+index ba0b36f..0b0fd11 100644
+--- a/cmake/Config.cmake.in
++++ b/cmake/Config.cmake.in
+@@ -21,4 +21,11 @@
+ # * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+ # *************************************************************************/
+
++set(SPDLOG_FMT_EXTERNAL @SPDLOG_FMT_EXTERNAL@)
++
+ include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
++
++if(SPDLOG_FMT_EXTERNAL)
++ include(CMakeFindDependencyMacro)
++ find_dependency(fmt CONFIG)
++endif()
diff --git a/ports/spdlog/portfile.cmake b/ports/spdlog/portfile.cmake
index 21f3121e9..c676c6467 100644
--- a/ports/spdlog/portfile.cmake
+++ b/ports/spdlog/portfile.cmake
@@ -6,6 +6,8 @@ vcpkg_from_github(
REF v1.2.1
SHA512 418f91efc207fa227558212d82c41639c0bb59e84ea47447e0b6276c4842e97f1f8aaf5802c071ef15d80ec525e317e70b6a39661a6c96ab39d33d9bd1570da1
HEAD_REF v1.x
+ PATCHES
+ fmt-external-cmake-option.patch # This patch is in the upstream project and can be removed next version update.
)
vcpkg_configure_cmake(
@@ -13,6 +15,7 @@ vcpkg_configure_cmake(
PREFER_NINJA
OPTIONS
-DSPDLOG_BUILD_TESTING=OFF
+ -DSPDLOG_FMT_EXTERNAL=ON
)
vcpkg_install_cmake()
@@ -22,11 +25,8 @@ vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/spdlog)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib)
-# use vcpkg-provided fmt library
+# use vcpkg-provided fmt library (see also option SPDLOG_FMT_EXTERNAL above)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/spdlog/fmt/bundled)
-file(READ ${CURRENT_PACKAGES_DIR}/include/spdlog/tweakme.h SPDLOG_TWEAKME_CONTENTS)
-string(REPLACE "// #define SPDLOG_FMT_EXTERNAL" "#define SPDLOG_FMT_EXTERNAL" SPDLOG_TWEAKME_CONTENTS "${SPDLOG_TWEAKME_CONTENTS}")
-file(WRITE ${CURRENT_PACKAGES_DIR}/include/spdlog/tweakme.h "${SPDLOG_TWEAKME_CONTENTS}")
# Handle copyright
file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/spdlog)