[vincentlaucsb-csv-parser] New port (#32780)

This commit is contained in:
Weihang Ding 2023-07-28 23:20:17 +08:00 committed by GitHub
parent ccd2e8b4b9
commit 0d8b396a5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 187 additions and 0 deletions

View File

@ -0,0 +1,67 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e729a8b..c63edab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,12 @@
cmake_minimum_required(VERSION 3.9)
project(csv)
+include(GNUInstallDirs)
+
+find_path(HEDLEY_INCLUDE_DIRS "hedley.h")
+find_package(mio CONFIG REQUIRED)
+find_package(string-view-lite CONFIG REQUIRED)
+
if(CSV_CXX_STANDARD)
set(CMAKE_CXX_STANDARD ${CSV_CXX_STANDARD})
else()
@@ -38,16 +44,27 @@ set(CSV_TEST_DIR ${CMAKE_CURRENT_LIST_DIR}/tests)
include_directories(${CSV_INCLUDE_DIR})
-## Load developer specific CMake settings
-if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
- SET(CSV_DEVELOPER TRUE)
-endif()
+SET(CSV_DEVELOPER OFF)
## Main Library
add_subdirectory(${CSV_SOURCE_DIR})
-## Executables
-add_subdirectory("programs")
+install(TARGETS csv EXPORT unofficial-vincentlaucsb-csv-parser)
+
+install(
+ EXPORT unofficial-vincentlaucsb-csv-parser
+ FILE unofficial-vincentlaucsb-csv-parser-config.cmake
+ DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/unofficial-vincentlaucsb-csv-parser"
+ NAMESPACE unofficial::vincentlaucsb-csv-parser::
+)
+
+install(
+ DIRECTORY "${CMAKE_SOURCE_DIR}/include/"
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/vincentlaucsb-csv-parser"
+ PATTERN "*.cpp" EXCLUDE
+ PATTERN "CMakeLists.txt" EXCLUDE
+ PATTERN "external" EXCLUDE
+)
## Developer settings
if (CSV_DEVELOPER)
diff --git a/include/internal/CMakeLists.txt b/include/internal/CMakeLists.txt
index 42cac24..30ea9e7 100644
--- a/include/internal/CMakeLists.txt
+++ b/include/internal/CMakeLists.txt
@@ -23,5 +23,9 @@ target_sources(csv
data_type.h
)
-set_target_properties(csv PROPERTIES LINKER_LANGUAGE CXX)
-target_link_libraries(csv PRIVATE Threads::Threads)
+set_target_properties(csv PROPERTIES LINKER_LANGUAGE CXX OUTPUT_NAME "vincentlaucsb-csv-parser-csv")
+target_include_directories(csv
+ PUBLIC ${HEDLEY_INCLUDE_DIRS}
+ INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/vincentlaucsb-csv-parser>
+)
+target_link_libraries(csv PRIVATE Threads::Threads PUBLIC mio::mio mio::mio-headers nonstd::string-view-lite)

View File

@ -0,0 +1,45 @@
diff --git a/include/internal/basic_csv_parser.hpp b/include/internal/basic_csv_parser.hpp
index d76b2d9..8dd0110 100644
--- a/include/internal/basic_csv_parser.hpp
+++ b/include/internal/basic_csv_parser.hpp
@@ -15,7 +15,7 @@
#include <thread>
#include <vector>
-#include "../external/mio.hpp"
+#include "mio/mmap.hpp"
#include "col_names.hpp"
#include "common.hpp"
#include "csv_format.hpp"
diff --git a/include/internal/common.hpp b/include/internal/common.hpp
index c132bfb..dff4d03 100644
--- a/include/internal/common.hpp
+++ b/include/internal/common.hpp
@@ -28,12 +28,12 @@
#pragma once
#include <type_traits>
-#include "../external/string_view.hpp"
+#include "nonstd/string_view.hpp"
// If there is another version of Hedley, then the newer one
// takes precedence.
// See: https://github.com/nemequ/hedley
-#include "../external/hedley.h"
+#include "hedley.h"
namespace csv {
#ifdef _MSC_VER
diff --git a/include/internal/csv_reader.hpp b/include/internal/csv_reader.hpp
index 798ef3b..007fa23 100644
--- a/include/internal/csv_reader.hpp
+++ b/include/internal/csv_reader.hpp
@@ -15,7 +15,7 @@
#include <string>
#include <vector>
-#include "../external/mio.hpp"
+#include "mio/mmap.hpp"
#include "basic_csv_parser.hpp"
#include "common.hpp"
#include "data_type.h"

View File

@ -0,0 +1,37 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO vincentlaucsb/csv-parser
REF "${VERSION}"
SHA512 26ed124ebe9592931ad141bdc53569537b7599de2ba6a7230d4a514cba27bf2684f2b320be9a39a7c5277fcfd75eb972aa3a39bd9613dd237f865b50f5437178
HEAD_REF master
PATCHES
001-fix-cmake.patch
002-fix-include.patch
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DBUILD_PYTHON=OFF
MAYBE_UNUSED_VARIABLES
BUILD_PYTHON
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-vincentlaucsb-csv-parser)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(READ "${CURRENT_PACKAGES_DIR}/share/unofficial-vincentlaucsb-csv-parser/unofficial-vincentlaucsb-csv-parser-config.cmake" cmake_config)
file(WRITE "${CURRENT_PACKAGES_DIR}/share/unofficial-vincentlaucsb-csv-parser/unofficial-vincentlaucsb-csv-parser-config.cmake"
"include(CMakeFindDependencyMacro)
find_dependency(Threads)
find_dependency(mio CONFIG)
find_dependency(string-view-lite CONFIG)
${cmake_config}
")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

View File

@ -0,0 +1,4 @@
csv-parser provides CMake targets:
find_package(unofficial-vincentlaucsb-csv-parser CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::vincentlaucsb-csv-parser::csv)

View File

@ -0,0 +1,21 @@
{
"name": "vincentlaucsb-csv-parser",
"version": "2.1.3",
"description": "A modern C++ library for reading, writing, and analyzing CSV (and similar) files.",
"homepage": "https://github.com/vincentlaucsb/csv-parser",
"license": "MIT",
"supports": "!uwp",
"dependencies": [
"hedley",
"mio",
"string-view-lite",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}

View File

@ -8528,6 +8528,10 @@
"baseline": "1.0.0+20221123",
"port-version": 1
},
"vincentlaucsb-csv-parser": {
"baseline": "2.1.3",
"port-version": 0
},
"visit-struct": {
"baseline": "1.1.0",
"port-version": 0

View File

@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "85d641f84a8f718a13d9f7ac169a4f2542c4d7c8",
"version": "2.1.3",
"port-version": 0
}
]
}