2020-03-11 06:40:15 +08:00
|
|
|
cmake_minimum_required(VERSION 3.14)
|
2020-05-01 08:38:52 +08:00
|
|
|
project(metrohash LANGUAGES CXX)
|
2020-03-11 06:40:15 +08:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
|
|
|
|
add_library(metrohash
|
|
|
|
src/metrohash64.cpp
|
|
|
|
src/metrohash128.cpp
|
|
|
|
src/metrohash128crc.cpp
|
|
|
|
)
|
|
|
|
target_compile_options(metrohash PRIVATE -march=native)
|
2020-05-01 08:38:52 +08:00
|
|
|
set(metro_headers src/metrohash.h src/metrohash64.h src/metrohash128.h src/metrohash128crc.h)
|
2020-03-11 06:40:15 +08:00
|
|
|
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"
|
2020-05-20 05:47:19 +08:00
|
|
|
PUBLIC_HEADER DESTINATION "include")
|
|
|
|
|
2020-05-01 08:38:52 +08:00
|
|
|
install(
|
|
|
|
FILES "${project_config}"
|
|
|
|
DESTINATION "${config_install_dir}"
|
|
|
|
)
|
2020-03-11 06:40:15 +08:00
|
|
|
install(EXPORT "${TARGETS_EXPORT_NAME}"
|
|
|
|
NAMESPACE "${namespace}"
|
|
|
|
DESTINATION "${config_install_dir}"
|
|
|
|
)
|