Consolidate into two static libs - one with assertions and one without
This commit is contained in:
229
CMakeLists.txt
229
CMakeLists.txt
@@ -103,31 +103,8 @@ add_custom_command(
|
||||
add_custom_target(generate_json_tokens
|
||||
DEPENDS ${CMAKE_BINARY_DIR}/json_tokens.cpp)
|
||||
|
||||
set(SOURCES
|
||||
src/main.cpp
|
||||
src/config.cpp
|
||||
src/connection.cpp
|
||||
src/connection_registry.cpp
|
||||
src/server.cpp
|
||||
src/json_commit_request_parser.cpp
|
||||
src/http_handler.cpp
|
||||
src/api_url_parser.cpp
|
||||
src/arena_allocator.cpp
|
||||
src/format.cpp
|
||||
src/metric.cpp
|
||||
src/process_collector.cpp
|
||||
${CMAKE_BINARY_DIR}/json_tokens.cpp)
|
||||
|
||||
add_executable(weaseldb ${SOURCES})
|
||||
add_dependencies(weaseldb generate_json_tokens)
|
||||
target_link_libraries(
|
||||
weaseldb
|
||||
Threads::Threads
|
||||
toml11::toml11
|
||||
weaseljson
|
||||
simdutf::simdutf
|
||||
llhttp_static
|
||||
perfetto)
|
||||
add_executable(weaseldb src/main.cpp)
|
||||
target_link_libraries(weaseldb weaseldb_sources)
|
||||
|
||||
enable_testing()
|
||||
|
||||
@@ -136,145 +113,125 @@ add_library(test_data STATIC benchmarks/test_data.cpp)
|
||||
target_include_directories(test_data PUBLIC benchmarks)
|
||||
target_link_libraries(test_data simdutf::simdutf)
|
||||
|
||||
add_executable(test_arena_allocator tests/test_arena_allocator.cpp
|
||||
src/arena_allocator.cpp src/format.cpp)
|
||||
target_link_libraries(test_arena_allocator doctest::doctest)
|
||||
target_include_directories(test_arena_allocator PRIVATE src)
|
||||
# Create doctest implementation library
|
||||
add_library(doctest_impl STATIC doctest_impl.cpp)
|
||||
target_link_libraries(doctest_impl PUBLIC doctest::doctest)
|
||||
|
||||
# Create nanobench implementation library
|
||||
add_library(nanobench_impl STATIC nanobench_impl.cpp)
|
||||
target_link_libraries(nanobench_impl PUBLIC nanobench)
|
||||
|
||||
# Define all source files in one place
|
||||
set(WEASELDB_SOURCES
|
||||
src/arena_allocator.cpp
|
||||
src/format.cpp
|
||||
src/metric.cpp
|
||||
src/json_commit_request_parser.cpp
|
||||
src/api_url_parser.cpp
|
||||
src/server.cpp
|
||||
src/connection.cpp
|
||||
src/connection_registry.cpp
|
||||
src/http_handler.cpp
|
||||
src/config.cpp
|
||||
src/process_collector.cpp
|
||||
${CMAKE_BINARY_DIR}/json_tokens.cpp)
|
||||
|
||||
# Create library based on build type
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
# In debug builds, use single library with assertions enabled
|
||||
add_library(weaseldb_sources STATIC ${WEASELDB_SOURCES})
|
||||
add_dependencies(weaseldb_sources generate_json_tokens)
|
||||
target_include_directories(weaseldb_sources PUBLIC src)
|
||||
target_link_libraries(
|
||||
weaseldb_sources PUBLIC simdutf::simdutf weaseljson Threads::Threads
|
||||
llhttp_static toml11::toml11 perfetto)
|
||||
target_compile_options(weaseldb_sources PRIVATE -UNDEBUG)
|
||||
|
||||
# Alias for tests to use same target name
|
||||
add_library(weaseldb_sources_debug ALIAS weaseldb_sources)
|
||||
else()
|
||||
# In release builds, create both variants
|
||||
add_library(weaseldb_sources STATIC ${WEASELDB_SOURCES})
|
||||
add_dependencies(weaseldb_sources generate_json_tokens)
|
||||
target_include_directories(weaseldb_sources PUBLIC src)
|
||||
target_link_libraries(
|
||||
weaseldb_sources PUBLIC simdutf::simdutf weaseljson Threads::Threads
|
||||
llhttp_static toml11::toml11 perfetto)
|
||||
|
||||
# Debug version with assertions enabled for tests
|
||||
add_library(weaseldb_sources_debug STATIC ${WEASELDB_SOURCES})
|
||||
add_dependencies(weaseldb_sources_debug generate_json_tokens)
|
||||
target_include_directories(weaseldb_sources_debug PUBLIC src)
|
||||
target_link_libraries(
|
||||
weaseldb_sources_debug PUBLIC simdutf::simdutf weaseljson Threads::Threads
|
||||
llhttp_static toml11::toml11 perfetto)
|
||||
target_compile_options(weaseldb_sources_debug PRIVATE -UNDEBUG)
|
||||
endif()
|
||||
|
||||
add_executable(test_arena_allocator tests/test_arena_allocator.cpp)
|
||||
target_link_libraries(test_arena_allocator doctest_impl weaseldb_sources_debug)
|
||||
target_compile_options(test_arena_allocator PRIVATE -UNDEBUG)
|
||||
|
||||
add_executable(
|
||||
test_commit_request
|
||||
tests/test_commit_request.cpp src/json_commit_request_parser.cpp
|
||||
tests/nlohmann_reference_parser.cpp tests/parser_comparison.cpp
|
||||
src/arena_allocator.cpp ${CMAKE_BINARY_DIR}/json_tokens.cpp)
|
||||
add_dependencies(test_commit_request generate_json_tokens)
|
||||
target_link_libraries(test_commit_request doctest::doctest weaseljson test_data
|
||||
nlohmann_json::nlohmann_json simdutf::simdutf)
|
||||
target_include_directories(test_commit_request PRIVATE src tests)
|
||||
tests/test_commit_request.cpp tests/nlohmann_reference_parser.cpp
|
||||
tests/parser_comparison.cpp)
|
||||
target_link_libraries(test_commit_request doctest_impl weaseldb_sources_debug
|
||||
test_data nlohmann_json::nlohmann_json)
|
||||
target_include_directories(test_commit_request PRIVATE tests)
|
||||
target_compile_options(test_commit_request PRIVATE -UNDEBUG)
|
||||
|
||||
add_executable(
|
||||
test_http_handler
|
||||
tests/test_http_handler.cpp
|
||||
src/http_handler.cpp
|
||||
src/api_url_parser.cpp
|
||||
src/server.cpp
|
||||
src/config.cpp
|
||||
src/json_commit_request_parser.cpp
|
||||
src/arena_allocator.cpp
|
||||
src/format.cpp
|
||||
src/connection.cpp
|
||||
src/connection_registry.cpp
|
||||
src/metric.cpp
|
||||
${CMAKE_BINARY_DIR}/json_tokens.cpp)
|
||||
add_dependencies(test_http_handler generate_json_tokens)
|
||||
target_link_libraries(
|
||||
test_http_handler
|
||||
doctest::doctest
|
||||
llhttp_static
|
||||
Threads::Threads
|
||||
toml11::toml11
|
||||
perfetto
|
||||
simdutf::simdutf
|
||||
weaseljson)
|
||||
target_include_directories(test_http_handler PRIVATE src)
|
||||
target_compile_definitions(test_http_handler
|
||||
PRIVATE DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN)
|
||||
add_executable(test_http_handler tests/test_http_handler.cpp)
|
||||
target_link_libraries(test_http_handler doctest_impl weaseldb_sources_debug)
|
||||
target_compile_options(test_http_handler PRIVATE -UNDEBUG)
|
||||
|
||||
add_executable(
|
||||
test_server_connection_return
|
||||
tests/test_server_connection_return.cpp
|
||||
src/server.cpp
|
||||
src/connection.cpp
|
||||
src/connection_registry.cpp
|
||||
src/arena_allocator.cpp
|
||||
src/config.cpp
|
||||
src/http_handler.cpp
|
||||
src/api_url_parser.cpp
|
||||
src/json_commit_request_parser.cpp
|
||||
src/format.cpp
|
||||
src/metric.cpp
|
||||
${CMAKE_BINARY_DIR}/json_tokens.cpp)
|
||||
add_dependencies(test_server_connection_return generate_json_tokens)
|
||||
target_link_libraries(
|
||||
test_server_connection_return
|
||||
doctest::doctest
|
||||
llhttp_static
|
||||
Threads::Threads
|
||||
toml11::toml11
|
||||
perfetto
|
||||
weaseljson
|
||||
simdutf::simdutf)
|
||||
target_include_directories(test_server_connection_return PRIVATE src)
|
||||
target_compile_definitions(test_server_connection_return
|
||||
PRIVATE DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN)
|
||||
add_executable(test_server_connection_return
|
||||
tests/test_server_connection_return.cpp)
|
||||
target_link_libraries(test_server_connection_return doctest_impl
|
||||
weaseldb_sources_debug)
|
||||
target_compile_options(test_server_connection_return PRIVATE -UNDEBUG)
|
||||
|
||||
# Metrics system test
|
||||
add_executable(test_metric tests/test_metric.cpp src/metric.cpp
|
||||
src/arena_allocator.cpp src/format.cpp)
|
||||
target_link_libraries(test_metric doctest::doctest Threads::Threads
|
||||
simdutf::simdutf weaseljson)
|
||||
target_include_directories(test_metric PRIVATE src)
|
||||
add_executable(test_metric tests/test_metric.cpp)
|
||||
target_link_libraries(test_metric doctest_impl weaseldb_sources_debug)
|
||||
target_compile_options(test_metric PRIVATE -UNDEBUG)
|
||||
|
||||
# Register with CTest
|
||||
add_test(NAME metric_tests COMMAND test_metric)
|
||||
|
||||
add_executable(bench_arena_allocator benchmarks/bench_arena_allocator.cpp
|
||||
src/arena_allocator.cpp)
|
||||
target_link_libraries(bench_arena_allocator nanobench)
|
||||
target_include_directories(bench_arena_allocator PRIVATE src)
|
||||
add_executable(bench_arena_allocator benchmarks/bench_arena_allocator.cpp)
|
||||
target_link_libraries(bench_arena_allocator nanobench_impl weaseldb_sources)
|
||||
|
||||
add_executable(bench_volatile_loop benchmarks/bench_volatile_loop.cpp)
|
||||
target_link_libraries(bench_volatile_loop nanobench)
|
||||
target_link_libraries(bench_volatile_loop nanobench_impl)
|
||||
|
||||
add_executable(
|
||||
bench_commit_request
|
||||
benchmarks/bench_commit_request.cpp src/json_commit_request_parser.cpp
|
||||
src/arena_allocator.cpp ${CMAKE_BINARY_DIR}/json_tokens.cpp)
|
||||
add_dependencies(bench_commit_request generate_json_tokens)
|
||||
target_link_libraries(bench_commit_request nanobench weaseljson test_data
|
||||
simdutf::simdutf)
|
||||
target_include_directories(bench_commit_request PRIVATE src)
|
||||
add_executable(bench_commit_request benchmarks/bench_commit_request.cpp)
|
||||
target_link_libraries(bench_commit_request nanobench_impl weaseldb_sources
|
||||
test_data)
|
||||
|
||||
add_executable(
|
||||
bench_parser_comparison
|
||||
benchmarks/bench_parser_comparison.cpp src/json_commit_request_parser.cpp
|
||||
src/arena_allocator.cpp ${CMAKE_BINARY_DIR}/json_tokens.cpp)
|
||||
add_dependencies(bench_parser_comparison generate_json_tokens)
|
||||
target_link_libraries(bench_parser_comparison nanobench weaseljson test_data
|
||||
nlohmann_json::nlohmann_json simdutf::simdutf)
|
||||
add_executable(bench_parser_comparison benchmarks/bench_parser_comparison.cpp)
|
||||
target_link_libraries(bench_parser_comparison nanobench_impl weaseldb_sources
|
||||
test_data nlohmann_json::nlohmann_json)
|
||||
target_include_directories(bench_parser_comparison
|
||||
PRIVATE src ${rapidjson_SOURCE_DIR}/include)
|
||||
PRIVATE ${rapidjson_SOURCE_DIR}/include)
|
||||
|
||||
add_executable(bench_thread_pipeline benchmarks/bench_thread_pipeline.cpp)
|
||||
target_link_libraries(bench_thread_pipeline nanobench Threads::Threads)
|
||||
target_link_libraries(bench_thread_pipeline nanobench_impl Threads::Threads)
|
||||
target_include_directories(bench_thread_pipeline PRIVATE src)
|
||||
|
||||
add_executable(bench_format_comparison benchmarks/bench_format_comparison.cpp
|
||||
src/arena_allocator.cpp src/format.cpp)
|
||||
target_link_libraries(bench_format_comparison nanobench)
|
||||
target_include_directories(bench_format_comparison PRIVATE src)
|
||||
add_executable(bench_format_comparison benchmarks/bench_format_comparison.cpp)
|
||||
target_link_libraries(bench_format_comparison nanobench_impl weaseldb_sources)
|
||||
|
||||
# Metrics system benchmark
|
||||
add_executable(bench_metric benchmarks/bench_metric.cpp src/metric.cpp
|
||||
src/arena_allocator.cpp src/format.cpp)
|
||||
target_link_libraries(bench_metric nanobench Threads::Threads simdutf::simdutf
|
||||
weaseljson)
|
||||
target_include_directories(bench_metric PRIVATE src)
|
||||
add_executable(bench_metric benchmarks/bench_metric.cpp)
|
||||
target_link_libraries(bench_metric nanobench_impl weaseldb_sources)
|
||||
|
||||
# Register benchmark with CTest
|
||||
add_test(NAME metric_benchmarks COMMAND bench_metric)
|
||||
|
||||
# Debug tools
|
||||
add_executable(
|
||||
debug_arena tools/debug_arena.cpp src/json_commit_request_parser.cpp
|
||||
src/arena_allocator.cpp ${CMAKE_BINARY_DIR}/json_tokens.cpp)
|
||||
add_dependencies(debug_arena generate_json_tokens)
|
||||
target_link_libraries(debug_arena weaseljson simdutf::simdutf)
|
||||
target_include_directories(debug_arena PRIVATE src)
|
||||
add_executable(debug_arena tools/debug_arena.cpp)
|
||||
target_link_libraries(debug_arena weaseldb_sources)
|
||||
|
||||
# Load tester
|
||||
add_executable(load_tester tools/load_tester.cpp)
|
||||
@@ -291,11 +248,7 @@ add_test(NAME parser_comparison_benchmarks COMMAND bench_parser_comparison)
|
||||
add_test(NAME thread_pipeline_benchmarks COMMAND bench_thread_pipeline)
|
||||
add_test(NAME format_comparison_benchmarks COMMAND bench_format_comparison)
|
||||
|
||||
add_executable(test_api_url_parser tests/test_api_url_parser.cpp
|
||||
src/api_url_parser.cpp)
|
||||
target_link_libraries(test_api_url_parser doctest::doctest)
|
||||
target_include_directories(test_api_url_parser PRIVATE src)
|
||||
target_compile_definitions(test_api_url_parser
|
||||
PRIVATE DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN)
|
||||
add_executable(test_api_url_parser tests/test_api_url_parser.cpp)
|
||||
target_link_libraries(test_api_url_parser doctest_impl weaseldb_sources_debug)
|
||||
target_compile_options(test_api_url_parser PRIVATE -UNDEBUG)
|
||||
add_test(NAME api_url_parser_tests COMMAND test_api_url_parser)
|
||||
|
||||
Reference in New Issue
Block a user