[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 <jean.gautier@ssi.gouv.fr>
Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com>
This commit is contained in:
Jean Gautier 2020-07-31 07:33:26 +02:00 committed by GitHub
parent 565df6ec85
commit 8cfa3e8e31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 114 additions and 0 deletions

View File

@ -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
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:include>
+)
+
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::
+)
+

8
ports/stx/CONTROL Normal file
View File

@ -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

35
ports/stx/portfile.cmake Normal file
View File

@ -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"
)