Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/builds-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ jobs:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
shell: bash
run: |
cmake -S . -B builds -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=off -DPYTHON_VERSION_TO_EMBED=3.12 -DSENTRY_CRASH_REPORTING=ON -DSENTRY_DSN=$SENTRY_DSN
export KNOBKRAFT_EXTERNAL_VERSION="$(cmake -P cmake/calc_version.cmake)"
cmake -S . -B builds -DKNOBKRAFT_EXTERNAL_VERSION=$KNOBKRAFT_EXTERNAL_VERSION -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=off -DPYTHON_VERSION_TO_EMBED=3.12 -DSENTRY_CRASH_REPORTING=ON -DSENTRY_DSN=$SENTRY_DSN

- name: CMake build
run: cmake --build builds --target package -- -j4
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/builds-ubuntu24.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ jobs:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
shell: bash
run: |
CC=gcc-14 CXX=g++-14 cmake -S . -B builds -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=off -DPYTHON_VERSION_TO_EMBED=3.12 -DSENTRY_CRASH_REPORTING=ON -DSENTRY_DSN=$SENTRY_DSN
export KNOBKRAFT_EXTERNAL_VERSION="$(cmake -P cmake/calc_version.cmake)"
CC=gcc-14 CXX=g++-14 cmake -S . -B builds -DKNOBKRAFT_EXTERNAL_VERSION=$KNOBKRAFT_EXTERNAL_VERSION -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=off -DPYTHON_VERSION_TO_EMBED=3.12 -DSENTRY_CRASH_REPORTING=ON -DSENTRY_DSN=$SENTRY_DSN

- name: CMake build
run: |
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/builds-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ jobs:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
shell: bash
run: |
cmake -S . -B Builds -G "Visual Studio 17 2022" -A x64 -DCRASH_REPORTING=ON -DSENTRY_DSN=$SENTRY_DSN -DSPARKLE_UPDATES=ON
export KNOBKRAFT_EXTERNAL_VERSION="$(cmake -P cmake/calc_version.cmake)"
cmake -S . -B Builds -G "Visual Studio 17 2022" -A x64 -DKNOBKRAFT_EXTERNAL_VERSION=$KNOBKRAFT_EXTERNAL_VERSION -DCRASH_REPORTING=ON -DSENTRY_DSN=$SENTRY_DSN -DSPARKLE_UPDATES=ON

- name: Run Python tests first
run: |
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ option(ASAN "Use Address Sanitization for Debug version (Windows only for now)"
# Gin requests C++ 20.
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(UNIX AND NOT APPLE)
# Linux settings allowing NixOs to be built
set(CMAKE_AR "gcc-ar")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_FINISH true)
ENDIF()
Comment thread
coderabbitai[bot] marked this conversation as resolved.
add_definitions(-D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)

# To avoid dependency on WebKit. This also came with MacOS, but as webkit is heavyweight, it is probably a good idea to turn it off for all
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ all: configure build sign-dmg verify-signed
apple: notarize staple verify-notarization

configure:
@echo "Configuring build for type $(BUILD_TYPE) in directory $(BUILD_DIR), using Python from $(PYTHON_TO_USE)"
cmake -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DPYTHON_EXECUTABLE=$(PYTHON_TO_USE) -DCODESIGN_CERTIFICATE_NAME="$(APPLE_DEVELOPER_IDENTITY)"
export KNOBKRAFT_EXTERNAL_VERSION="$(cmake -P cmake/calc_version.cmake)"
@echo "Configuring build for type $(BUILD_TYPE) in directory $(BUILD_DIR), using Python from $(PYTHON_TO_USE). Version is $KNOBKRAFT_EXTERNAL_VERSION"
cmake -S . -B $(BUILD_DIR) -DKNOBKRAFT_EXTERNAL_VERSION=$KNOBKRAFT_EXTERNAL_VERSION -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DPYTHON_EXECUTABLE=$(PYTHON_TO_USE) -DCODESIGN_CERTIFICATE_NAME="$(APPLE_DEVELOPER_IDENTITY)"

.PHONY: build
build $(KNOBKRAFT_DMG):
Expand Down
13 changes: 1 addition & 12 deletions The-Orm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,8 @@

cmake_minimum_required(VERSION 3.14)

# Get the version from our sub cmakefile
execute_process(
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_LIST_DIR}/gitversion.cmake"
ERROR_VARIABLE PROJECT_VERSION
ERROR_STRIP_TRAILING_WHITESPACE
)
# Cleanup output
string(REGEX REPLACE "^[[:space:]]+|[[:space:]]+$" "" PROJECT_VERSION "${PROJECT_VERSION}")
string(REGEX REPLACE "\n$" "" PROJECT_VERSION "${PROJECT_VERSION}")
message(STATUS "Project version is '${PROJECT_VERSION}'")

# Start project
project(KnobKraftOrm VERSION ${PROJECT_VERSION})
project(KnobKraftOrm VERSION ${KNOBKRAFT_EXTERNAL_VERSION})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Add validation for KNOBKRAFT_EXTERNAL_VERSION.

If KNOBKRAFT_EXTERNAL_VERSION is not set or is empty (e.g., due to the calc_version.cmake failures noted in other files), the project() command will fail or produce an invalid version.

+if(NOT DEFINED KNOBKRAFT_EXTERNAL_VERSION OR KNOBKRAFT_EXTERNAL_VERSION STREQUAL "")
+    message(FATAL_ERROR "KNOBKRAFT_EXTERNAL_VERSION must be set. Please pass -DKNOBKRAFT_EXTERNAL_VERSION=<version> to CMake.")
+endif()
+
 project(KnobKraftOrm VERSION ${KNOBKRAFT_EXTERNAL_VERSION})
🤖 Prompt for AI Agents
In The-Orm/CMakeLists.txt around line 10, the project() call uses
KNOBKRAFT_EXTERNAL_VERSION without validating it; add a check immediately before
the project() line to verify the variable is defined and non-empty and either
set a safe default (e.g., "0.0.0") or call message(FATAL_ERROR ...) with a clear
error asking to run calc_version.cmake so the build fails fast with a helpful
message instead of producing an invalid project() invocation.


# Now you can use PROJECT_DEV_TAG in your CMake scripts or in your code to handle the "-dev" part.
# For example, you could add a preprocessor definition that your code could use:
Expand Down
33 changes: 33 additions & 0 deletions cmake/calc_version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Get the version from our sub cmakefile
execute_process(
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_LIST_DIR}/gitversion.cmake"
OUTPUT_VARIABLE PROJECT_VERSION
ERROR_VARIABLE PROJECT_VERSION_ERROR
RESULT_VARIABLE PROJECT_VERSION_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.

if(NOT PROJECT_VERSION_RESULT EQUAL 0)
if(PROJECT_VERSION_ERROR)
message(FATAL_ERROR "Version calculation failed: ${PROJECT_VERSION_ERROR}")
else()
message(FATAL_ERROR "Version calculation failed with exit code ${PROJECT_VERSION_RESULT}")
endif()
endif()

# Strip CMake's status prefix and surrounding whitespace
# Drop any CMake status lines like "-- Found Git: ..."
string(REGEX REPLACE "(^|\n)--[^\n]*" "" PROJECT_VERSION "${PROJECT_VERSION}")
# Trim whitespace
string(REGEX REPLACE "^[[:space:]]+|[[:space:]]+$" "" PROJECT_VERSION "${PROJECT_VERSION}")

if(PROJECT_VERSION STREQUAL "")
message(FATAL_ERROR "Version calculation returned an empty string")
endif()

# Emit plain text so shell captures are clean
execute_process(
COMMAND ${CMAKE_COMMAND} -E echo "${PROJECT_VERSION}"
)

File renamed without changes.
Loading