diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/metrohash/CMakeLists.txt | |
Diffstat (limited to 'vcpkg/ports/metrohash/CMakeLists.txt')
| -rw-r--r-- | vcpkg/ports/metrohash/CMakeLists.txt | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/vcpkg/ports/metrohash/CMakeLists.txt b/vcpkg/ports/metrohash/CMakeLists.txt new file mode 100644 index 0000000..d63a713 --- /dev/null +++ b/vcpkg/ports/metrohash/CMakeLists.txt @@ -0,0 +1,69 @@ +cmake_minimum_required(VERSION 3.5) +project(metrohash LANGUAGES CXX) +set(CMAKE_CXX_STANDARD 11) + +add_library(metrohash + src/metrohash64.cpp + src/metrohash128.cpp + ) +list(APPEND metro_headers src/metrohash.h src/metrohash64.h src/metrohash128.h) + +include(CheckCXXSourceCompiles) +include(CheckCXXCompilerFlag) + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + check_cxx_compiler_flag("-msse4.2" HAS_MSSE42) + if(HAS_MSSE42) + target_compile_options(metrohash PRIVATE -msse4.2) + string(APPEND CMAKE_REQUIRED_FLAGS " -msse4.2") + endif() +endif() + +check_cxx_source_compiles( +"#include <nmmintrin.h> +int main() { + _mm_crc32_u64(0, 0); + return 0; +}" +HAS_mm_crc32_u64) + +if(HAS_mm_crc32_u64) + list(APPEND metro_headers src/metrohash128crc.h) + target_sources(metrohash PRIVATE src/metrohash128crc.cpp) +endif() +if(CMAKE_CXX_COMPILER_ID MATCHES GNU) + target_compile_options(metrohash PRIVATE -march=native) +endif() + +set_target_properties(metrohash PROPERTIES + PUBLIC_HEADER "${metro_headers}" + ) + +include(CMakePackageConfigHelpers) + +set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") +set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") +set(config_install_dir "lib/cmake/${PROJECT_NAME}") +set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") +set(namespace "${PROJECT_NAME}::") + +configure_package_config_file( + "${CMAKE_SOURCE_DIR}/cmake/Config.cmake.in" + "${project_config}" + INSTALL_DESTINATION "${config_install_dir}" +) +#Installation +install(TARGETS metrohash + EXPORT "${TARGETS_EXPORT_NAME}" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + PUBLIC_HEADER DESTINATION "include") + +install( + FILES "${project_config}" + DESTINATION "${config_install_dir}" +) +install(EXPORT "${TARGETS_EXPORT_NAME}" + NAMESPACE "${namespace}" + DESTINATION "${config_install_dir}" + ) |