58 lines
1.7 KiB
CMake
58 lines
1.7 KiB
CMake
cmake_minimum_required(VERSION 3.14)
|
|
project(LLS VERSION 1.0 LANGUAGES C CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
|
endif()
|
|
|
|
# --- SQLite ------------------------------------------------------------------
|
|
# Use the system SQLite if present, otherwise download the amalgamation.
|
|
find_package(SQLite3)
|
|
|
|
if(NOT SQLite3_FOUND)
|
|
message(STATUS "System SQLite3 not found - fetching the amalgamation")
|
|
include(FetchContent)
|
|
if(POLICY CMP0135)
|
|
cmake_policy(SET CMP0135 NEW)
|
|
endif()
|
|
FetchContent_Declare(sqlite3_amalgamation
|
|
URL https://www.sqlite.org/2024/sqlite-amalgamation-3450100.zip)
|
|
FetchContent_MakeAvailable(sqlite3_amalgamation)
|
|
|
|
find_package(Threads REQUIRED)
|
|
add_library(sqlite3_local STATIC ${sqlite3_amalgamation_SOURCE_DIR}/sqlite3.c)
|
|
target_include_directories(sqlite3_local PUBLIC ${sqlite3_amalgamation_SOURCE_DIR})
|
|
target_link_libraries(sqlite3_local PUBLIC Threads::Threads ${CMAKE_DL_LIBS})
|
|
add_library(SQLite::SQLite3 ALIAS sqlite3_local)
|
|
endif()
|
|
|
|
# --- Application -------------------------------------------------------------
|
|
add_executable(lls
|
|
src/main.cpp
|
|
src/Completer.cpp
|
|
src/Config.cpp
|
|
src/Database.cpp
|
|
src/Display.cpp
|
|
src/ExternalEditor.cpp
|
|
src/LineEditor.cpp
|
|
src/Repl.cpp
|
|
src/Status.cpp
|
|
src/StringUtil.cpp
|
|
src/Table.cpp
|
|
src/Terminal.cpp
|
|
src/Tokenizer.cpp
|
|
)
|
|
|
|
target_include_directories(lls PRIVATE include)
|
|
target_link_libraries(lls PRIVATE SQLite::SQLite3)
|
|
|
|
if(MSVC)
|
|
target_compile_options(lls PRIVATE /W4)
|
|
else()
|
|
target_compile_options(lls PRIVATE -Wall -Wextra -Wpedantic)
|
|
endif()
|