96 lines
4.5 KiB
CMake
96 lines
4.5 KiB
CMake
project(librexy)
|
|
cmake_minimum_required(VERSION 3.0.2)
|
|
include(GNUInstallDirs)
|
|
include(CMakeDependentOption)
|
|
|
|
set(librexy_VERSION_STRING "000020000L")
|
|
set(librexy_VERSION_MAJOR 0)
|
|
set(librexy_VERSION_MINOR 2)
|
|
set(librexy_VERSION_REVISION 0)
|
|
set(INCLUDE_PATH ${CMAKE_SOURCE_DIR}/include)
|
|
include_directories(BEFORE SYSTEM "${INCLUDE_PATH}")
|
|
|
|
#find_program(CMAKE_CXX_CPPCHECK NAMES cppcheck)
|
|
#if(CMAKE_CXX_CPPCHECK)
|
|
# list(APPEND CMAKE_CXX_CPPCHECK "--enable=warning" "--inconclusive" "--force" "--inline-suppr")
|
|
#endif()
|
|
|
|
cmake_dependent_option(ENABLE_SHARED "Build shared library" ON "NOT BUILD_HEADER_ONLY" OFF)
|
|
cmake_dependent_option(ENABLE_SSO "Use small string optimization" ON "NOT BUILD_HEADER_ONLY" ON)
|
|
option(ENABLE_PROFILING "Enable asan" OFF)
|
|
option(BUILD_TESTS "Enable testing" OFF)
|
|
option(BUILD_HEADER_ONLY "Enable header only build" OFF)
|
|
mark_as_advanced(ENABLE_PROFILING)
|
|
|
|
set(LIBREXY_PUBLIC_HEADERS "include/rexy/rexy.hpp" "include/rexy/algorithm.hpp" "include/rexy/algorithm.tpp" "include/rexy/utility.hpp" "include/rexy/basic_string_hash.hpp" "include/rexy/hash.hpp" "include/rexy/string_view_hash.hpp" "include/rexy/string_hash.hpp" "include/rexy/mpmc_queue.hpp" "include/rexy/mpmc_queue.tpp" "include/rexy/traits.hpp" "include/rexy/steal.hpp" "include/rexy/expression.hpp" "include/rexy/string_base.hpp" "include/rexy/string.hpp" "include/rexy/string_base.tpp" "include/rexy/allocator.hpp" "include/rexy/meta.hpp" "include/rexy/buffer.hpp" "include/rexy/buffer.tpp" "include/rexy/debug_print.hpp" "include/rexy/deferred.hpp" "include/rexy/enum_traits.hpp" "include/rexy/storage_for.hpp" "include/rexy/storage_for.tpp" "include/rexy/visitor.hpp" "include/rexy/string_view.hpp" "include/rexy/string_view.tpp" "include/rexy/format.hpp" "include/rexy/format.tpp")
|
|
|
|
if(BUILD_HEADER_ONLY)
|
|
set(LIBREXY_BUILT_LIBRARY_HEADERS "")
|
|
set(librexy_HEADER_ONLY_BUILD 1)
|
|
|
|
add_library(rexy INTERFACE)
|
|
set(LIBREXY_LIBFLAGS "")
|
|
else()
|
|
set(LIBREXY_BUILT_LIBRARY_HEADERS "include/rexy/filerd.hpp" "include/rexy/threadpool.hpp" "include/rexy/demangle.hpp")
|
|
set(librexy_HEADER_ONLY_BUILD 0)
|
|
set(SOURCE_LIST "src/filerd.cpp" "src/string.cpp" "src/string_view.cpp" "src/threadpool.cpp" "src/demangle.cpp")
|
|
|
|
if(ENABLE_SHARED)
|
|
add_library(rexy SHARED ${SOURCE_LIST})
|
|
set_target_properties(rexy PROPERTIES SOVERSION "${librexy_VERSION_MAJOR}.${librexy_VERSION_MINOR}")
|
|
set(LIBREXY_LIBFLAGS "-lrexy")
|
|
target_link_libraries(rexy "-lpthread")
|
|
else()
|
|
add_library(rexy STATIC ${SOURCE_LIST})
|
|
set(LIBREXY_LIBFLAGS "-lrexy -lpthread")
|
|
target_link_libraries(rexy "-lpthread")
|
|
endif()
|
|
set_target_properties(rexy PROPERTIES VERSION "${librexy_VERSION_MAJOR}.${librexy_VERSION_MINOR}.${librexy_VERSION_REVISION}")
|
|
|
|
if(ENABLE_SSO)
|
|
set(librexy_ENABLE_SSO 1)
|
|
else()
|
|
set(librexy_ENABLE_SSO 0)
|
|
endif()
|
|
if(ENABLE_PROFILING)
|
|
target_compile_options(rexy PRIVATE -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls)
|
|
target_link_options(rexy PRIVATE -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls)
|
|
endif()
|
|
|
|
target_compile_options(rexy PRIVATE -Wall -Wextra -pedantic -std=c++20)
|
|
endif()
|
|
|
|
if(BUILD_TESTS)
|
|
add_library(ensure OBJECT "src/ensure.cpp")
|
|
target_compile_options(ensure PRIVATE -Wall -Wextra -pedantic -std=c++20)
|
|
enable_testing()
|
|
add_subdirectory(tests)
|
|
endif()
|
|
|
|
|
|
install(TARGETS rexy
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
)
|
|
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pc/librexy.pc"
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
|
)
|
|
install(FILES ${LIBREXY_PUBLIC_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rexy/")
|
|
install(FILES ${LIBREXY_BUILT_LIBRARY_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rexy/")
|
|
install(DIRECTORY "include/rexy/detail" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rexy" FILES_MATCHING PATTERN "*.hpp" PATTERN "*.tpp")
|
|
install(DIRECTORY "include/rexy/cx" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rexy" FILES_MATCHING PATTERN "*.hpp" PATTERN "*.tpp")
|
|
install(DIRECTORY "include/rexy/compat" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rexy" FILES_MATCHING PATTERN "*.hpp" PATTERN "*.tpp")
|
|
install(DIRECTORY "include/rexy/concepts" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rexy" FILES_MATCHING PATTERN "*.hpp" PATTERN "*.tpp")
|
|
|
|
configure_file(
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/pc/librexy.pc.cmake.in"
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/pc/librexy.pc"
|
|
@ONLY
|
|
)
|
|
configure_file(
|
|
"${INCLUDE_PATH}/rexy/rexy.hpp.in"
|
|
"${INCLUDE_PATH}/rexy/rexy.hpp"
|
|
)
|
|
|
|
add_custom_target(uninstall cat install_manifest.txt | xargs rm)
|