aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexej Harm <alexej.h@xiphos.de>2019-09-17 20:39:29 +0200
committerdan-shaw <51385773+dan-shaw@users.noreply.github.com>2019-09-17 11:39:29 -0700
commitd4ac0789529a6a5701e33052506d5fb381113d8f (patch)
treeb5742241294f3cbdcb05768e71a2a6fe4bf1f8dc
parentc5e1adb2435c01dcc2e821e39f98c97d8527acf4 (diff)
downloadvcpkg-d4ac0789529a6a5701e33052506d5fb381113d8f.tar.gz
vcpkg-d4ac0789529a6a5701e33052506d5fb381113d8f.zip
[date] Add official CMake targets support (#8151)
-rw-r--r--ports/date/0001-fix-uwp.patch13
-rw-r--r--ports/date/CMakeLists.txt44
-rw-r--r--ports/date/CONTROL4
-rw-r--r--ports/date/portfile.cmake36
-rw-r--r--ports/date/usage4
-rw-r--r--ports/date/vcpkg-cmake-wrapper.cmake11
6 files changed, 49 insertions, 63 deletions
diff --git a/ports/date/0001-fix-uwp.patch b/ports/date/0001-fix-uwp.patch
new file mode 100644
index 000000000..b414722cd
--- /dev/null
+++ b/ports/date/0001-fix-uwp.patch
@@ -0,0 +1,13 @@
+diff --git i/include/date/date.h w/include/date/date.h
+index fce6200..6a77ad4 100644
+--- i/include/date/date.h
++++ w/include/date/date.h
+@@ -82,7 +82,7 @@
+ #ifdef _MSC_VER
+ # pragma warning(push)
+ // warning C4127: conditional expression is constant
+-# pragma warning(disable : 4127)
++# pragma warning(disable : 4127 4996)
+ #endif
+
+ namespace date
diff --git a/ports/date/CMakeLists.txt b/ports/date/CMakeLists.txt
deleted file mode 100644
index bacbf2716..000000000
--- a/ports/date/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-cmake_minimum_required(VERSION 3.5.1)
-project(tz CXX)
-
-set(CMAKE_CXX_STANDARD 11)
-if(MSVC)
- add_compile_options(/W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS)
-endif()
-
-option(HAS_REMOTE_API "" 0)
-
-add_definitions(-DNOMINMAX -DHAS_REMOTE_API=${HAS_REMOTE_API})
-
-add_library(date INTERFACE)
-target_include_directories(date INTERFACE $<INSTALL_INTERFACE:include>)
-
-add_library(tz src/tz.cpp)
-target_include_directories(tz PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
-
-if(HAS_REMOTE_API)
- find_package(CURL REQUIRED)
- target_include_directories(tz PUBLIC $<BUILD_INTERFACE:${CURL_INCLUDE_DIRS}>)
- target_link_libraries(tz PUBLIC ${CURL_LIBRARIES})
-endif()
-
-if(BUILD_SHARED_LIBS)
- target_compile_definitions(tz PRIVATE -DDATE_BUILD_DLL)
-endif()
-
-install(
- TARGETS tz date
- EXPORT tz
- RUNTIME DESTINATION bin
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib
-)
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-date-config.cmake" "include(\${CMAKE_CURRENT_LIST_DIR}/unofficial-date-targets.cmake)\n")
-
-install(EXPORT tz FILE unofficial-date-targets.cmake NAMESPACE unofficial::date:: DESTINATION share/unofficial-date)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-date-config.cmake DESTINATION share/unofficial-date)
-
-if(NOT DISABLE_INSTALL_HEADERS)
- install(FILES include/date/date.h include/date/tz.h include/date/julian.h include/date/iso_week.h include/date/islamic.h DESTINATION include/date)
-endif()
diff --git a/ports/date/CONTROL b/ports/date/CONTROL
index 03cd721cb..eb1712116 100644
--- a/ports/date/CONTROL
+++ b/ports/date/CONTROL
@@ -1,7 +1,7 @@
Source: date
-Version: 2019-05-18-1
+Version: 2019-09-09
Homepage: https://github.com/HowardHinnant/date
-Description: A date and time library based on the C++11/14/17 <chrono> header
+Description: A date and time library based on the C++17 <chrono> header
Feature: remote-api
Description: support automatic download of tz data
diff --git a/ports/date/portfile.cmake b/ports/date/portfile.cmake
index c82db3330..ab2250b97 100644
--- a/ports/date/portfile.cmake
+++ b/ports/date/portfile.cmake
@@ -10,37 +10,39 @@ endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO HowardHinnant/date
- REF ed0368fc75427ef05cefdf19a39b60d7bed2f039
- SHA512 5f6a0d7e094fd1ab7b6a1ea9a96e467138220e9207e2eda68f71b68d6c56759e7470fabdfa920d92876e9c9b466e56ea8102333f407a46bb4cba43a2dfeb5e3a
+ REF 44344000f0fa32e66787d6d2c9ff5ddfd3605df7
+ SHA512 1ec75a4b6310f735261c996c63df8176f0523d8f59a23edd49fd8efbdcbf1e78051ba2f36df0920f6f5e6bbc8f81ea4639f73e05bb1cb7f97a8e500bde667782
HEAD_REF master
+ PATCHES "${CMAKE_CURRENT_LIST_DIR}/0001-fix-uwp.patch"
)
-file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
-
-set(HAS_REMOTE_API 0)
+set(DATE_USE_SYSTEM_TZ_DB 1)
if("remote-api" IN_LIST FEATURES)
- set(HAS_REMOTE_API 1)
+ set(DATE_USE_SYSTEM_TZ_DB 0)
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
- OPTIONS -DHAS_REMOTE_API=${HAS_REMOTE_API}
- OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
+ OPTIONS
+ -DUSE_SYSTEM_TZ_DB=${DATE_USE_SYSTEM_TZ_DB}
+ -DENABLE_DATE_TESTING=OFF
)
vcpkg_install_cmake()
-vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-date TARGET_PATH share/unofficial-date)
+if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
+ vcpkg_fixup_cmake_targets(CONFIG_PATH CMake TARGET_PATH share/date)
+else()
+ vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/date TARGET_PATH share/date)
+endif()
vcpkg_copy_pdbs()
-set(HEADER "${CURRENT_PACKAGES_DIR}/include/date/tz.h")
-file(READ "${HEADER}" _contents)
-string(REPLACE "#define TZ_H" "#define TZ_H\n#undef HAS_REMOTE_API\n#define HAS_REMOTE_API ${HAS_REMOTE_API}" _contents "${_contents}")
-if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
- string(REPLACE "ifdef DATE_BUILD_DLL" "if 1" _contents "${_contents}")
-endif()
-file(WRITE "${HEADER}" "${_contents}")
-
+file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(INSTALL ${SOURCE_PATH}/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/date RENAME copyright)
+file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/date)
+
+# Remove the wrapper when backwards compatibility with the unofficial::date::date and unofficial::date::tz
+# targets is no longer required.
+file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/date)
diff --git a/ports/date/usage b/ports/date/usage
new file mode 100644
index 000000000..82f42f7f2
--- /dev/null
+++ b/ports/date/usage
@@ -0,0 +1,4 @@
+The package date provides CMake targets:
+
+ find_package(date CONFIG REQUIRED)
+ target_link_libraries(main PRIVATE date::date date::tz)
diff --git a/ports/date/vcpkg-cmake-wrapper.cmake b/ports/date/vcpkg-cmake-wrapper.cmake
new file mode 100644
index 000000000..317c49b8c
--- /dev/null
+++ b/ports/date/vcpkg-cmake-wrapper.cmake
@@ -0,0 +1,11 @@
+_find_package(${ARGS})
+
+if(NOT TARGET unofficial::date::date AND TARGET date::date)
+ add_library(unofficial::date::date INTERFACE IMPORTED)
+ target_link_libraries(unofficial::date::date INTERFACE date::date)
+endif()
+
+if(NOT TARGET unofficial::date::tz AND TARGET date::tz)
+ add_library(unofficial::date::tz INTERFACE IMPORTED)
+ target_link_libraries(unofficial::date::tz INTERFACE date::tz)
+endif()