portfile.cmake 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. vcpkg_from_github(
  2. OUT_SOURCE_PATH SOURCE_PATH
  3. REPO gabime/spdlog
  4. REF v1.10.0
  5. SHA512 e82ec0a0c813ed2f1c8a31a0f21dbb733d0a7bd8d05284feae3bd66040bc53ad47a93b26c3e389c7e5623cfdeba1854d690992c842748e072aab3e6e6ecc5666
  6. HEAD_REF v1.x
  7. )
  8. vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
  9. FEATURES
  10. benchmark SPDLOG_BUILD_BENCH
  11. wchar SPDLOG_WCHAR_SUPPORT
  12. )
  13. # SPDLOG_WCHAR_FILENAMES can only be configured in triplet file since it is an alternative (not additive)
  14. if(NOT DEFINED SPDLOG_WCHAR_FILENAMES)
  15. set(SPDLOG_WCHAR_FILENAMES OFF)
  16. endif()
  17. if(NOT VCPKG_TARGET_IS_WINDOWS)
  18. if("wchar" IN_LIST FEATURES)
  19. message(WARNING "Feature 'wchar' is only supported for Windows and has no effect on other platforms.")
  20. elseif(SPDLOG_WCHAR_FILENAMES)
  21. message(FATAL_ERROR "Build option 'SPDLOG_WCHAR_FILENAMES' is for Windows.")
  22. endif()
  23. endif()
  24. string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SPDLOG_BUILD_SHARED)
  25. vcpkg_cmake_configure(
  26. SOURCE_PATH ${SOURCE_PATH}
  27. OPTIONS
  28. ${FEATURE_OPTIONS}
  29. -DSPDLOG_FMT_EXTERNAL=ON
  30. -DSPDLOG_INSTALL=ON
  31. -DSPDLOG_BUILD_SHARED=${SPDLOG_BUILD_SHARED}
  32. -DSPDLOG_WCHAR_FILENAMES=${SPDLOG_WCHAR_FILENAMES}
  33. -DSPDLOG_BUILD_EXAMPLE=OFF
  34. )
  35. vcpkg_cmake_install()
  36. vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/spdlog)
  37. vcpkg_fixup_pkgconfig()
  38. vcpkg_copy_pdbs()
  39. # use vcpkg-provided fmt library (see also option SPDLOG_FMT_EXTERNAL above)
  40. file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/spdlog/fmt/bundled)
  41. # add support for integration other than cmake
  42. vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/spdlog/tweakme.h
  43. "// #define SPDLOG_FMT_EXTERNAL"
  44. "#ifndef SPDLOG_FMT_EXTERNAL\n#define SPDLOG_FMT_EXTERNAL\n#endif"
  45. )
  46. if(SPDLOG_WCHAR_SUPPORT)
  47. vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/spdlog/tweakme.h
  48. "// #define SPDLOG_WCHAR_TO_UTF8_SUPPORT"
  49. "#ifndef SPDLOG_WCHAR_TO_UTF8_SUPPORT\n#define SPDLOG_WCHAR_TO_UTF8_SUPPORT\n#endif"
  50. )
  51. endif()
  52. if(SPDLOG_WCHAR_FILENAMES)
  53. vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/spdlog/tweakme.h
  54. "// #define SPDLOG_WCHAR_FILENAMES"
  55. "#ifndef SPDLOG_WCHAR_FILENAMES\n#define SPDLOG_WCHAR_FILENAMES\n#endif"
  56. )
  57. endif()
  58. file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include
  59. ${CURRENT_PACKAGES_DIR}/debug/share)
  60. # Handle copyright
  61. file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)