[cityhash] Add feature sse for non-x86-Windows (#20999)

* [cityhash] Add feature sse for non-x86-Windows

* version

* Add missing dependencies.

* version
This commit is contained in:
Jack·Boos·Yu 2021-10-28 14:10:49 +08:00 committed by GitHub
parent 7c10f9883d
commit 843e0ba0d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 93 additions and 19 deletions

View File

@ -1,8 +1,52 @@
cmake_minimum_required(VERSION 3.13)
project(cityhash CXX)
option(ENABLE_SSE "Build CityHash variants that depend on the _mm_crc32_u64 intrinsic." OFF)
set(CMAKE_CXX_STANDARD 11)
if (ENABLE_SSE)
include (CMakePushCheckState)
cmake_push_check_state()
if (MSVC)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles(
"#include <nmmintrin.h>
int main() {
_mm_crc32_u64(0, 0);
return 0;
}"
USE_SSE)
else()
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag ("-msse4.2" USE_SSE)
if (USE_SSE)
set (SSE2_FLAG "-msse4.2")
endif()
endif()
cmake_pop_check_state()
if (NOT USE_SSE)
message(FATAL_ERROR "This platform doesn't support feature SSE4.2")
endif()
else()
set(USE_SSE OFF)
endif()
add_library(cityhash STATIC src/city.cc)
list(APPEND CITY_HEADERS src/city.h)
if (USE_SSE)
list(APPEND CITY_HEADERS src/citycrc.h)
target_compile_options(cityhash PRIVATE ${SSE2_FLAG})
if (MSVC)
target_compile_definitions(cityhash PRIVATE __SSE4_2__)
endif()
endif()
target_include_directories(cityhash PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
@ -15,4 +59,4 @@ install(TARGETS cityhash EXPORT cityhash-config
)
install(EXPORT cityhash-config DESTINATION share/cmake/cityhash)
install(FILES src/city.h DESTINATION include)
install(FILES ${CITY_HEADERS} DESTINATION include)

View File

@ -8,30 +8,40 @@ vcpkg_from_github(
HEAD_REF master
)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
if(VCPKG_TARGET_IS_WINDOWS)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/config.h DESTINATION ${SOURCE_PATH}/src)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/config.h" DESTINATION "${SOURCE_PATH}/src")
else()
file(MAKE_DIRECTORY ${SOURCE_PATH}/out)
file(MAKE_DIRECTORY "${SOURCE_PATH}/out")
vcpkg_execute_required_process(
COMMAND ${SOURCE_PATH}/configure
WORKING_DIRECTORY ${SOURCE_PATH}/out
COMMAND "${SOURCE_PATH}/configure"
WORKING_DIRECTORY "${SOURCE_PATH}/out"
LOGNAME configure-${TARGET_TRIPLET}
)
file(COPY ${SOURCE_PATH}/out/config.h DESTINATION ${SOURCE_PATH}/src)
file(COPY "${SOURCE_PATH}/out/config.h" DESTINATION "${SOURCE_PATH}/src")
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
if (VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" AND "sse" IN_LIST FEATURES)
message(FATAL_ERROR "Feature 'sse' does not support Windows x86 triplet.")
endif()
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
"sse" ENABLE_SSE
)
vcpkg_install_cmake()
vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
${FEATURE_OPTIONS}
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_fixup_cmake_targets(CONFIG_PATH share/cmake/cityhash)
vcpkg_cmake_config_fixup(CONFIG_PATH share/cmake/cityhash)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share")
configure_file(${SOURCE_PATH}/COPYING ${CURRENT_PACKAGES_DIR}/share/cityhash/copyright COPYONLY)
configure_file("${SOURCE_PATH}/COPYING" "${CURRENT_PACKAGES_DIR}/share/cityhash/copyright" COPYONLY)

View File

@ -1,7 +1,22 @@
{
"name": "cityhash",
"version-string": "2013-01-08",
"port-version": 1,
"version-date": "2013-01-08",
"port-version": 2,
"description": "CityHash, a family of hash functions for strings.",
"homepage": "https://github.com/google/cityhash"
"homepage": "https://github.com/google/cityhash",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"sse": {
"description": "Build CityHash variants that depend on the _mm_crc32_u64 intrinsic."
}
}
}

View File

@ -1350,7 +1350,7 @@
},
"cityhash": {
"baseline": "2013-01-08",
"port-version": 1
"port-version": 2
},
"civetweb": {
"baseline": "1.15",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "9c1b6eaaf15c06d436ce42331b84566abd931f53",
"version-date": "2013-01-08",
"port-version": 2
},
{
"git-tree": "423306e7029cfac62069d751bb612e10b3777c13",
"version-string": "2013-01-08",