From 8cfa3e8e31393c3c0de2c63f6e212b27f2d809fe Mon Sep 17 00:00:00 2001 From: Jean Gautier Date: Fri, 31 Jul 2020 07:33:26 +0200 Subject: [PATCH] [stx] Add new port (#12011) * Add port STX * stx: improve include files handling, disabled shared library support * [stx] remove CMakeLists.txt, add CMakeLists.patch, fixes * Update ports/stx/CMakeLists.patch to remove comments Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> * CMakeLists.txt remove comment for installed region * Update ports/stx/portfile.cmake Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> * Update ports/stx/portfile.cmake Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> * Use vcpkg_check_linkage(ONLY_STATIC_LIBRARY) instead of custom logic Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> * Update portfile.cmake Co-authored-by: Jean Gautier Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> --- ports/stx/CMakeLists.patch | 71 ++++++++++++++++++++++++++++++++++++++ ports/stx/CONTROL | 8 +++++ ports/stx/portfile.cmake | 35 +++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 ports/stx/CMakeLists.patch create mode 100644 ports/stx/CONTROL create mode 100644 ports/stx/portfile.cmake diff --git a/ports/stx/CMakeLists.patch b/ports/stx/CMakeLists.patch new file mode 100644 index 00000000000..70aaccbfda8 --- /dev/null +++ b/ports/stx/CMakeLists.patch @@ -0,0 +1,71 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e4ed99e..b0d2b15 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -204,12 +204,7 @@ endif() + # =============================================== + + if(STX_ENABLE_BACKTRACE) +- if(NOT EXISTS third_party/abseil) +- execute_process( +- COMMAND git submodule update --init --recursive third_party/abseil +- WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) +- endif() +- add_subdirectory(third_party/abseil) ++ find_package(absl CONFIG REQUIRED) + endif() + + # the atomics library doesn't automatically link on my Android phone +@@ -246,13 +241,17 @@ else() + add_library(stx STATIC ${STX_SRCS}) + endif() + +-target_include_directories(stx PUBLIC include) ++target_include_directories(stx PUBLIC ++ $ ++ $ ++) ++ + target_compile_options(stx PRIVATE ${STX_FLAGS} ${STX_WARNING_FLAGS}) + target_compile_definitions(stx PUBLIC ${STX_COMPILER_DEFS}) + target_link_libraries(stx ${STX_LIB_DEPENDENCIES}) + + if(STX_ENABLE_BACKTRACE) +- target_link_libraries(stx absl::stacktrace absl::symbolize) ++ target_link_libraries(stx PUBLIC absl::stacktrace absl::symbolize) + endif() + + if(ANDROID) +@@ -288,6 +287,7 @@ endif() + # + # =============================================== + ++ + if(STX_BUILD_BENCHMARKS) + + if(NOT EXISTS third_party/benchmark) +@@ -433,3 +433,24 @@ if(STX_BUILD_DOCS) + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/docs/html/assets) + + endif() ++ ++install( ++ TARGETS stx ++ EXPORT stx ++ ARCHIVE DESTINATION lib ++ LIBRARY DESTINATION lib ++ RUNTIME DESTINATION bin ++) ++ ++install( ++ DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ ++ DESTINATION include ++ FILES_MATCHING PATTERN "*.h*") ++ ++install( ++ EXPORT stx ++ DESTINATION share/stx ++ FILE stxConfig.cmake ++ NAMESPACE stx:: ++) ++ diff --git a/ports/stx/CONTROL b/ports/stx/CONTROL new file mode 100644 index 00000000000..cd6886925d1 --- /dev/null +++ b/ports/stx/CONTROL @@ -0,0 +1,8 @@ +Source: stx +Version: 1.0.1 +Homepage: https://github.com/lamarrr/STX +Description: C++17 & C++ 20 error-handling and utility extensions + +Feature: backtrace +Description: stacktrace support for STX +Build-Depends: abseil diff --git a/ports/stx/portfile.cmake b/ports/stx/portfile.cmake new file mode 100644 index 00000000000..ebfca54ab39 --- /dev/null +++ b/ports/stx/portfile.cmake @@ -0,0 +1,35 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO lamarrr/STX + REF v1.0.1 + SHA512 544ca32f07cd863082fa9688f5d56e2715b0129ff90d2a8533cc24a92c943e5848c4b2b06a71f54c12668f6e89e9e3c649f595f9eb886f671a5fa18d343f794b + HEAD_REF master + PATCHES + "CMakeLists.patch" +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + backtrace STX_ENABLE_BACKTRACE +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS + ${FEATURE_OPTIONS} + -DSTX_BUILD_DOCS=OFF + -DSTX_BUILD_BENCHMARKS=OFF + -DSTX_BUILD_SHARED=OFF +) + +vcpkg_install_cmake() +vcpkg_fixup_cmake_targets(CONFIG_PATH share/stx) +vcpkg_copy_pdbs() + +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" +)