Skip to content

Commit

Permalink
Add CPack
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinHelmut committed Oct 28, 2023
1 parent 0445c1d commit 696bd4f
Show file tree
Hide file tree
Showing 126 changed files with 2,503 additions and 244 deletions.
3 changes: 2 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ Checks: >
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-readability-magic-numbers,
-readability-function-cognitive-complexity,
-readability-magic-numbers,
-misc-non-private-member-variables-in-classes,
-clang-analyzer-optin.cplusplus.UninitializedObject,
-misc-static-assert,
Expand Down
5 changes: 5 additions & 0 deletions .gitattributes → .gitattributes_example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
*.jpg filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.gif filter=lfs diff=lfs merge=lfs -text
*.ico filter=lfs diff=lfs merge=lfs -text
*.icns filter=lfs diff=lfs merge=lfs -text
*.bmp filter=lfs diff=lfs merge=lfs -text
*.tif filter=lfs diff=lfs merge=lfs -text
*.tiff filter=lfs diff=lfs merge=lfs -text
*.webp filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
*.webm filter=lfs diff=lfs merge=lfs -text
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ env:

jobs:
build:
runs-on: macos-latest
runs-on: macos-latest-xlarge

steps:
- uses: actions/checkout@v3

- name: Install GitHub CLI
run: |
brew update
brew install llvm
ln -s "$(brew --prefix llvm)/bin/clang-format" "/usr/local/bin/clang-format"
ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy"
Expand Down
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# Application build output
build/

# Created by CPack when executing tests.
Testing/

# Generated by the profiler on debug.
profile.json
*-profile.json

# Created by running the application.
*.log

# User defined CMake preset file.
CMakeUserPresets.json
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
cmake_minimum_required(VERSION 3.22)

include(cmake/AppleBuild.cmake)
include(cmake/UniversalAppleBuild.cmake)

project(
BasicGuiProjectSetupSDL2OpenGL
BasicGuiProjectSetupOpenGL
DESCRIPTION "Base gui project setup with SDL2 and OpenGL."
VERSION 1.0.0
LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(PROJECT_COMPANY_NAME "My Company")
set(PROJECT_COMPANY_NAMESPACE "com.mycompany") # Reverse domain name notation

include(cmake/StandardProjectSettings.cmake)
include(GNUInstallDirs)

# Link this "library" to use the warnings specified in CompilerWarnings.cmake
# Link this "library" to use the warnings specified in CompilerWarnings.cmake.
add_library(project_warnings INTERFACE)
include(cmake/CompilerWarnings.cmake)
set_project_warnings(project_warnings)

enable_testing()

add_subdirectory(packaging)
add_subdirectory(vendor)
add_subdirectory(src)
56 changes: 56 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 22,
"patch": 0
},
"configurePresets": [
{
"name": "debug",
"displayName": "Debug",
"generator": "Ninja",
"binaryDir": "build/debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"displayName": "Release",
"generator": "Ninja",
"binaryDir": "build/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "xcode-debug",
"displayName": "Debug (Xcode)",
"generator": "Xcode",
"binaryDir": "build/xcode-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "xcode-release",
"displayName": "Release (Xcode)",
"generator": "Xcode",
"binaryDir": "build/xcode-release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
}
]
}
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Martin Helmut Fieber
Copyright (c) 2022-2023 Martin Helmut Fieber

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
31 changes: 10 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
# Base GUI project setup with SDL2 and OpenGL

C++ gui project template with SDL2 and OpenGL 4.1.
C++ GUI project template with [SDL2](https://www.libsdl.org) and [Dear ImGUI](https://github.com/ocornut/imgui) with
OpenGL 4.1.

![Image of the example app.](example-app.png)

## Setup
## How to get started

The project uses [CMake](https://cmake.org) and [Ninja](https://ninja-build.org).
After using this template to create your own repository, it is time to first run and then customize!

Build the application in debug mode:
- Start here: [Quick Start](docs/QuickStart.md)
- Continue here: [Usage Guide](docs/README.md)

```shell
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -B build/debug
ninja -C build/debug
```
## Other versions

Run the application:

```shell
cd ./build/debug/src/app && ./App
```

### Using Litr

When using [Litr](https://github.com/krieselreihe/litr), the quick setup to build and run the application is:

```shell
litr build,start
```
There is also a [SDL2 version using the SDL2 Renderer](https://github.com/MartinHelmut/cpp-gui-template-sdl2) instead of
OpenGL specifically, but it does not support
multi-viewports or detached widgets.

## Disclaimer

Expand Down
7 changes: 2 additions & 5 deletions cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function(set_project_warnings project_name)
set(CLANG_WARNINGS
-Wall
-Wextra # reasonable and standard
# -Wshadow # warn the user if a variable declaration shadows one from a
-Wshadow # warn the user if a variable declaration shadows one from a
# parent context
-Wnon-virtual-dtor # warn the user if a class with virtual functions has a
# non-virtual destructor. This helps catch hard to
Expand All @@ -56,9 +56,6 @@ function(set_project_warnings project_name)
-Wnull-dereference # warn if a null dereference is detected
-Wformat=2 # warn on security issues around functions that format output
# (ie printf)
# @todo: Temporarily deactivated for SDL2
# -Wdouble-promotion # warn if float is implicit promoted to double
# -Wold-style-cast # warn for c-style casts
)

if (WARNINGS_AS_ERRORS)
Expand All @@ -69,7 +66,7 @@ function(set_project_warnings project_name)
set(GCC_WARNINGS
${CLANG_WARNINGS}
-Wmisleading-indentation # warn if indentation implies blocks where blocks
# @todo: Currently not supported in CI due to an old gcc version.
# @todo: Somehow those make problems in some versions of Clang in Windows. So I deactivate them for now.
# -Wduplicated-branches # warn if if / else branches have duplicated code
# -Wduplicated-cond # warn if if / else chain has duplicated conditions
# -Wlogical-op # warn about logical operations being used where bitwise were
Expand Down
7 changes: 1 addition & 6 deletions cmake/StandardProjectSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)

# Set the possible values of build type for cmake-gui, ccmake
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo")
endif ()

find_program(CCACHE ccache)
Expand All @@ -23,11 +23,6 @@ if (DEACTIVATE_LOGGING)
add_compile_definitions(APP_DEACTIVATE_LOGGING)
endif ()

option(TRACE "Enable detailed execution flow tracing" OFF)
if (TRACE)
add_compile_definitions(TRACE)
endif ()

option(DEBUG "Enable debug statements and asserts" OFF)
if (DEBUG OR CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(DEBUG APP_PROFILE)
Expand Down
4 changes: 2 additions & 2 deletions cmake/StaticAnalyzers.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
if (NOT CMAKE_BUILD_TYPE STREQUAL "Release")
find_program(CLANGTIDY clang-tidy)
if (CLANGTIDY)
message(STATUS "Using clang-tidy")
message(STATUS "Using clang-tidy, found ${CLANGTIDY}")
set(CMAKE_CXX_CLANG_TIDY "${CLANGTIDY};-extra-arg=-Wno-unknown-warning-option")
else ()
message(WARNING "clang-tidy requested but executable not found")
endif ()

# This will gradually increase memory usage of the program,
# running on Apple M1, 13.0.
# discovered on Apple M1, 13.0.
if (NOT WIN32)
message(STATUS "Using address sanitizer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -fsanitize=address -g")
Expand Down
5 changes: 2 additions & 3 deletions cmake/AppleBuild.cmake → cmake/UniversalAppleBuild.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# This file needs to be included before calling `project`.
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
if (APPLE AND "${CMAKE_GENERATOR}" STREQUAL "Xcode")
# Generate universal executable for Apple hardware.
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "")
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)")

# Support older macOS versions.
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15 CACHE STRING "Minimum OS X deployment version")
set(CMAKE_OSX_SYSROOT macosx10.15)
endif ()
Loading

0 comments on commit 696bd4f

Please sign in to comment.