-
Notifications
You must be signed in to change notification settings - Fork 38
CMake changes for NixOS #486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
christofmuc
wants to merge
5
commits into
master
Choose a base branch
from
features/CMake_for_NixOS
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
40ed7c3
Extract the version calculation from git from the main CMake file, so…
christofmuc da9d27f
Fix syntax errors
christofmuc 305a0ae
Using the wrong editor for a Makefile can make you look stupid
christofmuc c294a1c
Fix version calculation script
christofmuc ca7d0ef
More parsing goodies?
christofmuc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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}) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Add validation for KNOBKRAFT_EXTERNAL_VERSION. If +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 |
||
|
|
||
| # 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: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ) | ||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.