Enable header only build
This commit is contained in:
parent
3fc89111ea
commit
5e49ed5f9a
@ -1,6 +1,7 @@
|
|||||||
project(librexy)
|
project(librexy)
|
||||||
cmake_minimum_required(VERSION 3.0.2)
|
cmake_minimum_required(VERSION 3.0.2)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
include(CMakeDependentOption)
|
||||||
|
|
||||||
set(librexy_VERSION_STRING "000020000L")
|
set(librexy_VERSION_STRING "000020000L")
|
||||||
set(librexy_VERSION_MAJOR 0)
|
set(librexy_VERSION_MAJOR 0)
|
||||||
@ -10,37 +11,52 @@ set(INCLUDE_PATH ${CMAKE_SOURCE_DIR}/include)
|
|||||||
include_directories(BEFORE SYSTEM "${INCLUDE_PATH}")
|
include_directories(BEFORE SYSTEM "${INCLUDE_PATH}")
|
||||||
|
|
||||||
|
|
||||||
option(ENABLE_SHARED "Build shared library" ON)
|
cmake_dependent_option(ENABLE_SHARED "Build shared library" ON "NOT BUILD_HEADER_ONLY" OFF)
|
||||||
option(ENABLE_PROFILING "Enable asan" OFF)
|
option(ENABLE_PROFILING "Enable asan" OFF)
|
||||||
option(BUILD_TESTS "Enable testing" OFF)
|
option(BUILD_TESTS "Enable testing" OFF)
|
||||||
|
option(BUILD_HEADER_ONLY "Enable header only build" OFF)
|
||||||
mark_as_advanced(ENABLE_PROFILING)
|
mark_as_advanced(ENABLE_PROFILING)
|
||||||
|
|
||||||
set(SOURCE_LIST "src/filerd.cpp" "src/string.cpp" "src/string_view.cpp" "src/threadpool.cpp" "src/demangle.cpp")
|
set(LIBREXY_PUBLIC_HEADERS "include/rexy/rexy.hpp" "include/rexy/algorithm.hpp" "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")
|
||||||
add_library(ensure OBJECT "src/ensure.cpp")
|
|
||||||
target_compile_options(ensure PRIVATE -Wall -Wextra -pedantic -std=c++20)
|
if(BUILD_HEADER_ONLY)
|
||||||
if(ENABLE_SHARED)
|
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})
|
add_library(rexy SHARED ${SOURCE_LIST})
|
||||||
set_target_properties(rexy PROPERTIES SOVERSION "${librexy_VERSION_MAJOR}.${librexy_VERSION_MINOR}")
|
set_target_properties(rexy PROPERTIES SOVERSION "${librexy_VERSION_MAJOR}.${librexy_VERSION_MINOR}")
|
||||||
set(LIBREXY_LIBFLAGS "-lrexy")
|
set(LIBREXY_LIBFLAGS "-lrexy")
|
||||||
target_link_libraries(rexy "-lpthread")
|
target_link_libraries(rexy "-lpthread")
|
||||||
else()
|
else()
|
||||||
add_library(rexy STATIC ${SOURCE_LIST})
|
add_library(rexy STATIC ${SOURCE_LIST})
|
||||||
set(LIBREXY_LIBFLAGS "-lrexy -lpthread")
|
set(LIBREXY_LIBFLAGS "-lrexy -lpthread")
|
||||||
target_link_libraries(rexy "-lpthread")
|
target_link_libraries(rexy "-lpthread")
|
||||||
endif()
|
endif()
|
||||||
set_target_properties(rexy PROPERTIES VERSION "${librexy_VERSION_MAJOR}.${librexy_VERSION_MINOR}.${librexy_VERSION_REVISION}")
|
set_target_properties(rexy PROPERTIES VERSION "${librexy_VERSION_MAJOR}.${librexy_VERSION_MINOR}.${librexy_VERSION_REVISION}")
|
||||||
|
|
||||||
if(ENABLE_PROFILING)
|
if(ENABLE_PROFILING)
|
||||||
target_compile_options(rexy PRIVATE -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls)
|
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)
|
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()
|
endif()
|
||||||
|
|
||||||
if(BUILD_TESTS)
|
if(BUILD_TESTS)
|
||||||
|
add_library(ensure OBJECT "src/ensure.cpp")
|
||||||
|
target_compile_options(ensure PRIVATE -Wall -Wextra -pedantic -std=c++20)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(LIBREXY_PUBLIC_HEADERS "include/rexy/rexy.hpp" "include/rexy/algorithm.hpp" "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/filerd.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/demangle.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")
|
|
||||||
target_compile_options(rexy PRIVATE -Wall -Wextra -pedantic -std=c++20)
|
|
||||||
|
|
||||||
install(TARGETS rexy
|
install(TARGETS rexy
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
@ -50,6 +66,7 @@ install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pc/librexy.pc"
|
|||||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
||||||
)
|
)
|
||||||
install(FILES ${LIBREXY_PUBLIC_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rexy/")
|
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/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/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/compat" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rexy" FILES_MATCHING PATTERN "*.hpp" PATTERN "*.tpp")
|
||||||
|
|||||||
@ -29,6 +29,8 @@
|
|||||||
#include "rexy.hpp"
|
#include "rexy.hpp"
|
||||||
#include "buffer.hpp"
|
#include "buffer.hpp"
|
||||||
|
|
||||||
|
#ifndef LIBREXY_HEADER_ONLY
|
||||||
|
|
||||||
namespace rexy{
|
namespace rexy{
|
||||||
|
|
||||||
//RAII wrapper for FILE*
|
//RAII wrapper for FILE*
|
||||||
@ -73,4 +75,14 @@ namespace rexy{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else //LIBREXY_HEADER_ONLY
|
||||||
|
|
||||||
|
namespace rexy{
|
||||||
|
|
||||||
|
static_assert(false, "rexy::filerd is not available when built with header only support");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //LIBREXY_HEADER_ONLY
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
This file is a part of rexy's general purpose library
|
This file is a part of rexy's general purpose library
|
||||||
Copyright (C) 2021 rexy712
|
Copyright (C) 2021-2022 rexy712
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -16,9 +16,19 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef REXY_REXY_HPP
|
#ifndef REXY_CONFIG_REXY_HPP
|
||||||
#define REXY_REXY_HPP
|
#define REXY_CONFIG_REXY_HPP
|
||||||
|
|
||||||
|
#define LIBREXY_BUILD_HEADER_ONLY @librexy_HEADER_ONLY_BUILD@
|
||||||
|
|
||||||
|
#if LIBREXY_BUILD_HEADER_ONLY
|
||||||
|
#define LIBREXY_HEADER_ONLY 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LIBREXY_VERSION @librexy_VERSION_STRING@
|
#define LIBREXY_VERSION @librexy_VERSION_STRING@
|
||||||
|
#define LIBREXY_VERSION_MAJOR @librexy_VERSION_MAJOR@
|
||||||
|
#define LIBREXY_VERSION_MINOR @librexy_VERSION_MINOR@
|
||||||
|
#define LIBREXY_VERSION_REVISION @librexy_VERSION_REVISION@
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -28,18 +28,12 @@ namespace rexy{
|
|||||||
//new allocated string
|
//new allocated string
|
||||||
using string = basic_string<char,allocator<char>>;
|
using string = basic_string<char,allocator<char>>;
|
||||||
|
|
||||||
|
#ifndef LIBREXY_HEADER_ONLY
|
||||||
extern template class basic_string<char,allocator<char>>;
|
extern template class basic_string<char,allocator<char>>;
|
||||||
extern template class basic_string<wchar_t,allocator<wchar_t>>;
|
extern template class basic_string<wchar_t,allocator<wchar_t>>;
|
||||||
extern template class basic_string<char16_t,allocator<char16_t>>;
|
extern template class basic_string<char16_t,allocator<char16_t>>;
|
||||||
extern template class basic_string<char32_t,allocator<char32_t>>;
|
extern template class basic_string<char32_t,allocator<char32_t>>;
|
||||||
|
#endif
|
||||||
|
|
||||||
using string_view = basic_string_view<char>;
|
|
||||||
|
|
||||||
extern template class basic_string_view<char>;
|
|
||||||
extern template class basic_string_view<wchar_t>;
|
|
||||||
extern template class basic_string_view<char16_t>;
|
|
||||||
extern template class basic_string_view<char32_t>;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -706,11 +706,4 @@ namespace{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef REXY_BINARY_BASE_HPP
|
|
||||||
#include "detail/binary_string_conv.hpp"
|
|
||||||
#endif
|
|
||||||
#ifdef REXY_HASH_HPP
|
|
||||||
#include "static_string_hash.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
#include <iterator> //reverse_iterator
|
#include <iterator> //reverse_iterator
|
||||||
|
|
||||||
#include "compat/constexpr.hpp"
|
#include "compat/constexpr.hpp"
|
||||||
|
#include "rexy.hpp"
|
||||||
|
|
||||||
namespace rexy{
|
namespace rexy{
|
||||||
|
|
||||||
@ -101,8 +102,14 @@ namespace rexy{
|
|||||||
template<class T>
|
template<class T>
|
||||||
basic_string_view(const T*, size_t) -> basic_string_view<T>;
|
basic_string_view(const T*, size_t) -> basic_string_view<T>;
|
||||||
|
|
||||||
template<class T>
|
using string_view = basic_string_view<char>;
|
||||||
using static_string [[deprecated]] = basic_string_view<T>;
|
|
||||||
|
#ifndef LIBREXY_HEADER_ONLY
|
||||||
|
extern template class basic_string_view<char>;
|
||||||
|
extern template class basic_string_view<wchar_t>;
|
||||||
|
extern template class basic_string_view<char16_t>;
|
||||||
|
extern template class basic_string_view<char32_t>;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,8 +131,14 @@ namespace{
|
|||||||
std::ostream& operator<<(std::ostream& os, const rexy::basic_string_view<Char>& str){
|
std::ostream& operator<<(std::ostream& os, const rexy::basic_string_view<Char>& str){
|
||||||
return os << str.c_str();
|
return os << str.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "string_view.tpp"
|
#include "string_view.tpp"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef REXY_HASH_HPP
|
||||||
|
#include "string_view_hash.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
//Never actually used in the project. This just ensures that all syntax is correct during builds.
|
//Never actually used in the project. This just ensures that all syntax is correct during builds.
|
||||||
|
|
||||||
|
#include "rexy/rexy.hpp"
|
||||||
#include "rexy/algorithm.hpp"
|
#include "rexy/algorithm.hpp"
|
||||||
#include "rexy/allocator.hpp"
|
#include "rexy/allocator.hpp"
|
||||||
#include "rexy/buffer.hpp"
|
#include "rexy/buffer.hpp"
|
||||||
#include "rexy/buffer.tpp"
|
#include "rexy/buffer.tpp"
|
||||||
#include "rexy/expression.hpp"
|
#include "rexy/expression.hpp"
|
||||||
#include "rexy/filerd.hpp"
|
|
||||||
#include "rexy/hash.hpp"
|
#include "rexy/hash.hpp"
|
||||||
#include "rexy/mpmc_queue.hpp"
|
#include "rexy/mpmc_queue.hpp"
|
||||||
#include "rexy/steal.hpp"
|
#include "rexy/steal.hpp"
|
||||||
@ -18,13 +18,18 @@
|
|||||||
#include "rexy/meta.hpp"
|
#include "rexy/meta.hpp"
|
||||||
#include "rexy/enum_traits.hpp"
|
#include "rexy/enum_traits.hpp"
|
||||||
#include "rexy/deferred.hpp"
|
#include "rexy/deferred.hpp"
|
||||||
#include "rexy/demangle.hpp"
|
|
||||||
#include "rexy/debug_print.hpp"
|
#include "rexy/debug_print.hpp"
|
||||||
#include "rexy/storage_for.hpp"
|
#include "rexy/storage_for.hpp"
|
||||||
#include "rexy/visitor.hpp"
|
#include "rexy/visitor.hpp"
|
||||||
#include "rexy/string_view.hpp"
|
#include "rexy/string_view.hpp"
|
||||||
#include "rexy/string_view.tpp"
|
#include "rexy/string_view.tpp"
|
||||||
|
|
||||||
|
#ifndef LIBREXY_HEADER_ONLY
|
||||||
|
#include "rexy/filerd.hpp"
|
||||||
|
#include "rexy/threadpool.hpp"
|
||||||
|
#include "rexy/demangle.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "rexy/detail/string_appender.hpp"
|
#include "rexy/detail/string_appender.hpp"
|
||||||
|
|
||||||
#include "rexy/cx/array.hpp"
|
#include "rexy/cx/array.hpp"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user