diff --git a/.gitignore b/.gitignore index 7446455..a3a2fd4 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ obj *.d test.cpp tester.cpp +pc/librexy.pc diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..10ef559 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,48 @@ +include(GNUInstallDirs) + +cmake_minimum_required(VERSION 3.0.2) +project(librexy) +set(librexy_VERSION_MAJOR 0) +set(librexy_VERSION_MINOR 1) +set(librexy_VERSION_REVISION 0) +set(INCLUDE_PATH ${CMAKE_SOURCE_DIR}) +include_directories("${INCLUDE_PATH}") + +set(LIBREXY_LIBFLAGS "-lrexy") + +option(ENABLE_SHARED "Build shared library" ON) +option(ENABLE_PROFILING "Enable asan" OFF) +mark_as_advanced(ENABLE_PROFILING) + +set(SOURCE_LIST "rexy/src/binary.cpp" "rexy/src/string_base.cpp" "rexy/src/filerd.cpp") +if(ENABLE_SHARED) + add_library(rexy SHARED ${SOURCE_LIST}) + set_target_properties(rexy PROPERTIES SOVERSION "${librexy_VERSION_MAJOR}.${librexy_VERSION_MINOR}.${librexy_VERSION_REVISION}") +else() + add_library(rexy STATIC ${SOURCE_LIST}) +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() + +set(LIBREXY_PUBLIC_HEADERS "rexy/include/binary.hpp" "rexy/include/string_base.hpp" "rexy/include/string.hpp" "rexy/include/filerd.hpp" "rexy/include/string_base.tpp" "rexy/include/detail/binary_string_conv.hpp" "rexy/include/detail/default_allocator.hpp" "rexy/include/detail/util.hpp") +target_compile_options(rexy PRIVATE -Wall -Wextra -pedantic -std=c++17) + +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/") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/pc/librexy.pc.cmake.in" + "${CMAKE_CURRENT_SOURCE_DIR}/pc/librexy.pc" + @ONLY +) + +add_custom_target(uninstall cat install_manifest.txt | xargs rm) diff --git a/pc/librexy.pc.cmake.in b/pc/librexy.pc.cmake.in new file mode 100644 index 0000000..a11959e --- /dev/null +++ b/pc/librexy.pc.cmake.in @@ -0,0 +1,9 @@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: librexy +Description: Rexy's common utilities for C++ +URL: https://gitlab.com/rexy712/librexy +Version: @librexy_VERSION_MAJOR@.@librexy_VERSION_MINOR@.@librexy_VERSION_REVISION@ +Libs: -L${libdir} @LIBREXY_LIBFLAGS@ +Cflags: -I${includedir}