'Generic Commit'
All checks were successful
Build-Test-Publish / build (push) Successful in 33s

This commit is contained in:
Your Name
2025-06-14 11:34:02 +12:00
parent 47ce8407a1
commit 9fb018f162
11 changed files with 341 additions and 176 deletions

View File

@@ -1,71 +1,69 @@
cmake_minimum_required(VERSION 3.10)
project(simple_object_storage)
set(PROJECT_EXE_NAME simple_object_storage)
cmake_minimum_required(VERSION 3.16)
# Set the build type to Debug
#set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type (e.g., Debug, Release)" FORCE)
# Generate version from current date
execute_process(
COMMAND date "+%Y.%m%d.%H%M"
OUTPUT_VARIABLE PROJECT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Project setup
if(NOT DEFINED PROJECT_NAME)
message(FATAL_ERROR "PROJECT_NAME is not defined. Pass it via -DPROJECT_NAME=<name>")
endif()
project(${PROJECT_NAME} VERSION ${PROJECT_VERSION} LANGUAGES CXX)
# C++ standard and build configuration
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Linking flags (removed -static)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
# Static linking configuration
set(CMAKE_EXE_LINKER_FLAGS "-static -Wl,--allow-multiple-definition")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF)
# Configure version information
string(TIMESTAMP CURRENT_YEAR "%Y")
string(TIMESTAMP CURRENT_MONTH "%m")
string(TIMESTAMP CURRENT_DAY "%d")
string(TIMESTAMP CURRENT_HOUR "%H")
string(TIMESTAMP CURRENT_MINUTE "%M")
set(PROJECT_VERSION "${CURRENT_YEAR}.${CURRENT_MONTH}${CURRENT_DAY}.${CURRENT_HOUR}${CURRENT_MINUTE}")
string(TIMESTAMP RELEASE_DATE "%Y-%m-%d")
# Configure version.hpp file
# Configure version.hpp
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/src/version.hpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/src/autogen/version.hpp"
@ONLY
)
# Find all source files in src directory
file(GLOB_RECURSE SOURCES
"src/*.cpp"
"src/sqlite3/*.c"
# Pre-build script
add_custom_target(run_prebuild_script ALL
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/cmake_prebuild.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
# Find all header files in src directory
file(GLOB_RECURSE HEADERS
"src/*.hpp"
"src/sqlite3/*.h"
)
# Add include directories
include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src/autogen>
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/autogen
)
# Source files
file(GLOB_RECURSE SOURCES "src/*.cpp")
set_source_files_properties(${SOURCES} PROPERTIES GENERATED TRUE)
# Create executable
add_executable(${PROJECT_EXE_NAME} ${SOURCES})
add_executable(${PROJECT_NAME} ${SOURCES})
add_dependencies(${PROJECT_NAME} run_prebuild_script)
include(FetchContent)
# Add nlohmann/json
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
# Include directories
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/src/autogen
${CMAKE_CURRENT_SOURCE_DIR}/src
)
FetchContent_MakeAvailable(nlohmann_json)
# Remove specific static flags as CMAKE_EXE_LINKER_FLAGS handles it now
target_link_libraries(${PROJECT_EXE_NAME}
# Find packages
set(CMAKE_PREFIX_PATH /usr/local)
find_package(OpenSSL REQUIRED)
find_package(Drogon CONFIG REQUIRED)
find_package(nlohmann_json REQUIRED)
# Link libraries
target_link_libraries(${PROJECT_NAME} PRIVATE
nlohmann_json::nlohmann_json
)
# Install target
install(TARGETS ${PROJECT_EXE_NAME}
RUNTIME DESTINATION bin
)
Drogon::Drogon
/usr/lib/libunwind.a
/usr/lib/libunwind-x86_64.a
/usr/local/lib/libpgcommon.a
/usr/local/lib/libpgport.a
lzma
dl
)