-
Notifications
You must be signed in to change notification settings - Fork 12
chore: Add boilerplate CMake project and Taskfile tasks to lint CMake files. #7
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3666123
chore: Add boilerplate CMake project and Taskfile tasks to lint CMake…
kirkrodrigues 591bb13
Use config file for gersemi.
kirkrodrigues 13e4277
Disable yamllint for yaml-language-server line.
kirkrodrigues cd6d93d
Move cmake lint tasks where they should go; Add to list of lint tasks.
kirkrodrigues cf15a8e
Add to readme and don't allow venv to run twice.
kirkrodrigues 24d4792
Ignore CMakeLists.txt in build directory.
kirkrodrigues 03ddcfb
Add target_include_directories and split sources into var.
kirkrodrigues 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # yamllint disable-line rule:line-length | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/master/gersemi/configuration.schema.json | ||
|
|
||
| line_length: 100 | ||
| list_expansion: "favour-expansion" |
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,38 @@ | ||
| # CMake 3.22.1 is the default on Ubuntu 22.04 | ||
| cmake_minimum_required(VERSION 3.22.1) | ||
|
|
||
| project( | ||
| spider | ||
| LANGUAGES | ||
| C | ||
| CXX | ||
| VERSION 0.1.0 | ||
| ) | ||
|
|
||
| # Enable exporting compile commands | ||
| set(CMAKE_EXPORT_COMPILE_COMMANDS | ||
| ON | ||
| CACHE BOOL | ||
| "Enable/Disable output of compile commands during generation." | ||
| FORCE | ||
| ) | ||
|
|
||
| # Set the default build type to Release if not specified | ||
| if(NOT CMAKE_BUILD_TYPE) | ||
| set(SPIDER_DEFAULT_BUILD_TYPE "Release") | ||
| message(STATUS "No build type specified. Setting to '${SPIDER_DEFAULT_BUILD_TYPE}'.") | ||
| set(CMAKE_BUILD_TYPE | ||
| "${SPIDER_DEFAULT_BUILD_TYPE}" | ||
| CACHE STRING | ||
| "Choose the type of build." | ||
| FORCE | ||
| ) | ||
| endif() | ||
|
|
||
| add_executable(spider) | ||
| target_compile_features(spider PRIVATE cxx_std_20) | ||
|
|
||
| set(SPIDER_SOURCES src/spider/spider.cpp) | ||
| target_sources(spider PRIVATE ${SPIDER_SOURCES}) | ||
|
|
||
| target_include_directories(spider PRIVATE src/) | ||
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 |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| gersemi>=0.16.2 | ||
| yamllint>=1.35.1 |
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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #include <iostream> | ||
|
|
||
| int main() { | ||
| std::cout << "Hello, world!" << std::endl; | ||
| return 0; | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider adding build type options validation.
The build type configuration could benefit from validating allowed values and documenting available options.
if(NOT CMAKE_BUILD_TYPE) set(SPIDER_DEFAULT_BUILD_TYPE "Release") message(STATUS "No build type specified. Setting to '${SPIDER_DEFAULT_BUILD_TYPE}'.") set(CMAKE_BUILD_TYPE "${SPIDER_DEFAULT_BUILD_TYPE}" CACHE STRING - "Choose the type of build." + "Choose the type of build (Debug/Release/RelWithDebInfo/MinSizeRel)." FORCE ) + # Provide drop-down in CMake GUIs + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Release" "RelWithDebInfo" "MinSizeRel") endif()📝 Committable suggestion