Project Setup

This commit is contained in:
Robert Fry 2025-04-14 02:42:26 +01:00
parent bc913343ce
commit 30e3154a31
Signed by: robertfry
GPG Key ID: E89FFC8597BFE26C
5 changed files with 84 additions and 1 deletions

16
.clang-tidy Normal file
View File

@ -0,0 +1,16 @@
# https://clang.llvm.org/extra/clang-tidy/checks/list.html
Checks: '-*,
bugprone-*,
cert-*,
misc-*,
concurrency-*,
performance-*,
portability-*,
readability-*,
clang-analyzer-*,
'
# CheckOptions:
WarningsAsErrors: '*'
HeaderFilterRegex: '.'
FormatStyle: 'file'

24
.cmake/get_cpm.cmake Normal file
View File

@ -0,0 +1,24 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
set(CPM_DOWNLOAD_VERSION 0.40.8)
set(CPM_HASH_SUM "78ba32abdf798bc616bab7c73aac32a17bbd7b06ad9e26a6add69de8f3ae4791")
if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)
include(${CPM_DOWNLOAD_LOCATION})

16
.gitignore vendored
View File

@ -1,4 +1,13 @@
#
# Project
#
.build/
#
# ---> C
#
# Prerequisites
*.d
@ -52,7 +61,10 @@ Module.symvers
Mkfile.old
dkms.conf
#
# ---> C++
#
# Prerequisites
*.d
@ -86,7 +98,10 @@ dkms.conf
*.out
*.app
#
# ---> CMake
#
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
@ -99,4 +114,3 @@ compile_commands.json
CTestTestfile.cmake
_deps
CMakeUserPresets.json

22
CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.12)
project("C Rogue Game" VERSION "1.0.0" LANGUAGES "C"
DESCRIPTION "A rogue-like game written in C99")
include(.cmake/get_cpm.cmake)
CPMAddPackage("gh:robertefry/RockHopperStandards@1.3.6")
set(BINARY_NAME "c_rogue")
add_executable(${BINARY_NAME} "")
target_compile_features(${BINARY_NAME} PUBLIC c_std_99)
target_rockhopper_standards(${BINARY_NAME})
target_link_libraries(${BINARY_NAME} PUBLIC "ncurses")
file(GLOB_RECURSE BINARY_HEADERS "include/*.h")
file(GLOB_RECURSE BINARY_SOURCES "src/*.c" "src/*.h")
target_sources(${BINARY_NAME} PUBLIC ${BINARY_HEADERS} PRIVATE ${BINARY_SOURCES})
message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")

7
src/main.c Normal file
View File

@ -0,0 +1,7 @@
#include <stdio.h>
int main(void)
{
printf("Hello, World!\n");
}