'Generic Commit'
All checks were successful
dropshell-build / build (push) Successful in 1h8m20s

This commit is contained in:
Your Name
2025-06-14 17:07:52 +12:00
parent 35c3c512b2
commit 091c1f0850
2 changed files with 54 additions and 90 deletions

View File

@ -1,54 +1,31 @@
cmake_minimum_required(VERSION 3.16)
# 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()
string(TIMESTAMP PROJECT_VERSION "%Y.%m%d.%H%M")
project(${PROJECT_NAME} VERSION ${PROJECT_VERSION} LANGUAGES CXX)
# C++ standard and build configuration
# Build configuration
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Static linking configuration
set(CMAKE_EXE_LINKER_FLAGS "-static -Wl,--allow-multiple-definition")
set(CMAKE_EXE_LINKER_FLAGS "-static")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF)
# Configure version.hpp
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/src/version.hpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/src/autogen/version.hpp"
@ONLY
)
# Pre-build script
add_custom_target(run_prebuild_script ALL
# Configure version.hpp and create executable
configure_file("src/version.hpp.in" "src/autogen/version.hpp" @ONLY)
add_custom_target(run_prebuild_script ALL
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/cmake_prebuild.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# Source files
file(GLOB_RECURSE SOURCES "src/*.cpp")
set_source_files_properties(${SOURCES} PROPERTIES GENERATED TRUE)
# Create executable
add_executable(${PROJECT_NAME} ${SOURCES})
add_dependencies(${PROJECT_NAME} run_prebuild_script)
# Include directories
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/src/autogen
${CMAKE_CURRENT_SOURCE_DIR}/src
)
${CMAKE_CURRENT_BINARY_DIR}/src/autogen src)
# Find packages
set(CMAKE_PREFIX_PATH /usr/local)
@ -58,12 +35,6 @@ find_package(nlohmann_json REQUIRED)
# Link libraries
target_link_libraries(${PROJECT_NAME} PRIVATE
nlohmann_json::nlohmann_json
Drogon::Drogon
/usr/lib/libunwind.a
/usr/lib/libunwind-x86_64.a
/usr/local/lib/libpgcommon.a
/usr/local/lib/libpgport.a
lzma
dl
)
nlohmann_json::nlohmann_json Drogon::Drogon
/usr/local/lib/libpgcommon.a /usr/local/lib/libpgport.a
lzma dl)