include(ExternalProject) cmake_minimum_required(VERSION 3.9) project(BeeDB) ## Set default settings set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_FLAGS "-pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused -Wold-style-cast") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -DNDEBUG") set(CMAKE_BUILD_TYPE DEBUG) # "Debug" is default build type, overwrite with 'cmake -DCMAKE_BUILD_TYPE=Release' ## SQL Parser as external project ExternalProject_Add( sql-parser GIT_REPOSITORY "https://github.com/jangemue/sql-parser.git" PREFIX "${CMAKE_CURRENT_BINARY_DIR}/lib/sql-parser/prefix" TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib/sql-parser/tmp" DOWNLOAD_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib/sql-parser/download" SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib/sql-parser/src" BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib/sql-parser/bin" ) ## Include and link directories include_directories(${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/lib/ ${CMAKE_CURRENT_BINARY_DIR}/lib/sql-parser/src/src) link_directories(${CMAKE_CURRENT_BINARY_DIR}/lib ${CMAKE_CURRENT_BINARY_DIR}/lib/sql-parser/bin/lib) ## BeeDB sources add_executable(beedb src/beedb.cpp src/database.cpp src/disk/storage_manager.cpp src/disk/buffer_manager.cpp src/disk/lru_strategy.cpp src/disk/lru_k_strategy.cpp src/disk/lfu_strategy.cpp src/table/table.cpp src/table/column.cpp src/table/value.cpp src/table/table_disk_manager.cpp src/execution/binary_operator.cpp src/execution/sequential_scan_operator.cpp src/execution/index_scan_operator.cpp src/execution/create_table_operator.cpp src/execution/create_index_operator.cpp src/execution/insert_operator.cpp src/execution/selection_operator.cpp src/execution/projection_operator.cpp src/execution/nested_loops_join_operator.cpp src/execution/hash_join_operator.cpp src/execution/limit_operator.cpp src/execution/build_index_operator.cpp src/execution/order_operator.cpp src/execution/aggregate_operator.cpp src/execution/cross_product_operator.cpp src/execution/tuple_buffer_operator.cpp src/execution/add_to_index_operator.cpp src/execution/update_operator.cpp src/expression/attribute.cpp src/expression/predicate.cpp src/plan/physical/plan.cpp src/plan/logical/builder.cpp src/plan/physical/builder.cpp src/io/executor.cpp src/io/file_executor.cpp src/io/user_console.cpp src/io/printing_executor.cpp src/io/result_output_formatter.cpp src/io/command/commander.cpp src/io/command/custom_commands.cpp src/util/text_table.cpp src/util/ini_parser.cpp src/parser/query_parser.cpp src/parser/hsql_parser.cpp src/plan/logical/plan.cpp src/plan/optimizer/optimizer.cpp ) ## Build target add_dependencies(beedb sql-parser) target_link_libraries(beedb sqlparser) ## Git install hook target add_custom_target(git-hook cp ${PROJECT_SOURCE_DIR}/.pre-commit-hook ${PROJECT_SOURCE_DIR}/.git/hooks/pre-commit && chmod +x ${PROJECT_SOURCE_DIR}/.git/hooks/pre-commit)