Skip to content

Commit

Permalink
Give up with Make and go for CMake.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rotonen committed Jul 30, 2023
1 parent e09ca15 commit e27f112
Show file tree
Hide file tree
Showing 15 changed files with 4,427 additions and 482 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/pr-smoketest-debian.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ jobs:
fail-fast: false
matrix:
debian:
# Bullseye is the oldest Debian with a new enough glm
- "bullseye" # 11
# Bookworm is the oldest Debian with a new enough clang
- "bookworm" # 12
- "trixie" # 13
compiler:
- g++
- clang
- clang++
container: debian:${{ matrix.debian }}-slim
steps:
- name: Install Dependencies
Expand All @@ -26,10 +25,18 @@ jobs:
run: |
apt-get -qq update
apt-get -qq upgrade -y
apt-get -qq install --no-install-recommends \
apt-file
apt-file update
apt-get -qq install -y --no-install-recommends \
ca-certificates \
git \
${{ matrix.compiler }} \
"$(\
apt-file search '${{ matrix.compiler }}' \
| head -n 1 |
| cut -d' ' -f 1 \
| sed 's/://g' \
)" \
cmake \
make \
ccache \
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/pr-smoketest-fedora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,29 @@ jobs:
fail-fast: false
matrix:
fedora:
# 32 is the oldest Fedora with a new enough glm
- "32"
- "33"
- "34"
# 34 is the oldest Fedora with a new enough clang
- "35"
- "36"
- "37"
- "38"
- "39"
compiler:
- g++
- clang
- clang++
container: fedora:${{ matrix.fedora }}
steps:
- name: Install Dependencies
run: |
dnf -y update
dnf -y install \
git \
${{ matrix.compiler }} \
"$(\
dnf repoquery \
--whatprovides '/usr/bin/${{ matrix.compiler }}' \
--arch x86_64 \
--latest-limit 1 \
--queryformat '%{NAME}\n' \
)" \
cmake \
make \
ccache \
Expand Down
22 changes: 9 additions & 13 deletions .github/workflows/pr-smoketest-opensuse-leap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,28 @@ jobs:
fail-fast: false
matrix:
suse:
# 15.3 is the oldest openSUSE Leap with a new enough glm
- "15.3"
# 15.4 is the oldest openSUSE Leap with a new enough clang
- "15.4"
- "15.5"
compiler:
- g++
- clang
- clang++
container: opensuse/leap:${{ matrix.suse }}
steps:
- name: Resolve Compiler Package Name
run: |
if [[ ${{ matrix.compiler }} == g++ ]]
then
echo compiler=gcc-c++ >> "$GITHUB_ENV"
else
echo compiler=clang >> "$GITHUB_ENV"
fi
- name: Install Dependencies
run: |
zypper --non-interactive update
zypper --non-interactive install \
tar \
gzip \
git \
${{ env.compiler }} \
"$(\
zypper se \
--provides \
--match-exact '/usr/bin/${{ matrix.compiler }}' \
| tail -n 1 \
| awk '{ print $2 }' \
)" \
cmake \
make \
ccache \
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/pr-smoketest-ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- "22.04" # LTS only for sanity
compiler:
- g++
- clang
- clang++
container: ubuntu:${{ matrix.ubuntu }}
steps:
- name: Install Dependencies
Expand All @@ -26,7 +26,11 @@ jobs:
apt-get -qq install -y --no-install-recommends \
ca-certificates \
git \
${{ matrix.compiler }} \
"$(\
dpkg -S '${{ matrix.compiler }}' \
| cut -d' ' -f 1 \
| sed 's/://g' \
)" \
cmake \
make \
ccache \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/push-unit-tests-dynamic-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ jobs:
- name: Set ccache up
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e # v1.2.9
with:
key: ${{ github.job }}-unit-tests-${{ matrix.fedora }}-${{ matrix.compiler }}
key: unit-tests-linux

- name: Build Anura
env:
CXX: clang
CXX: clang++
# Compile with number of available hyperthreads
run: |
cmake .
Expand Down
19 changes: 16 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*.exe
*.out
*.app
anura
./anura

# Dependency files
*.d
Expand Down Expand Up @@ -86,7 +86,7 @@ anura.kdev4
.kdev4/

#Visual Studio build files.
*resouces.aps
*resouces.aps
vcpkg_installed/
windows/build/
windows/*-Release/
Expand All @@ -95,4 +95,17 @@ windows/*-Debug/

#Don't commit master-config.cfg by default.
#It should be copied or symlinked from a module.
master-config.cfg
master-config.cfg

# CMake
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "imgui"]
path = imgui
path = src/imgui
url = https://github.com/ocornut/imgui
shallow = true
96 changes: 96 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# 3.12 added add_compile_definitions
cmake_minimum_required(VERSION 3.12)

# BEGIN Project config

# Build target for CXX project "anura"
project(anura LANGUAGES CXX)

# Use ccache to accelerate iterating on CXX files, if available
find_program(CCACHE "ccache")
if(CCACHE)
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE}")
endif(CCACHE)

# Add the source code
file(
GLOB
anura_SRC
"${CMAKE_CURRENT_LIST_DIR}/src/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/hex/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/imgui/imgui_draw.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/imgui/imgui_tables.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/imgui/imgui_widgets.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/imgui/imgui.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/imgui_additions/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/kre/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/svg/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/tiled/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/treetree/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/xhtml/*.cpp"
)

# Configure compiling against system provided libraries
# XXX - At the moment (2023-07) we have no idea of the upper and lower bounds
find_package(Freetype REQUIRED)
find_package(Boost REQUIRED)
find_package(SDL2 REQUIRED)

# Add the headers
include_directories(
"${CMAKE_CURRENT_LIST_DIR}/src"
"${CMAKE_CURRENT_LIST_DIR}/src/hex"
"${CMAKE_CURRENT_LIST_DIR}/src/imgui"
"${CMAKE_CURRENT_LIST_DIR}/src/imgui_additions"
"${CMAKE_CURRENT_LIST_DIR}/src/kre"
"${CMAKE_CURRENT_LIST_DIR}/src/svg"
"${CMAKE_CURRENT_LIST_DIR}/src/tiled"
"${CMAKE_CURRENT_LIST_DIR}/src/treetree"
"${CMAKE_CURRENT_LIST_DIR}/src/xhtml"
"${FREETYPE_INCLUDE_DIR_ft2build}"
)

# END Project config

# BEGIN Compiler config

# Good things, to keep

# Set C++ standard to C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Turn off (GNU) extensions (-std=c++17 vs. -std=gnu++17)
set(CMAKE_CXX_EXTENSIONS OFF)

# -O2 per default
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")

# Warnings as errors, raise all warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")

# Inject our own imgui config for our own vector operations
add_compile_definitions(IMGUI_USER_CONFIG="${CMAKE_CURRENT_LIST_DIR}/src/imgui_additions/imconfig_anura.h")

# Bad things, to get rid of

# Use imgui provided vector math
# XXX - imgui_custom.cpp relies on these
add_compile_definitions(IMGUI_DEFINE_MATH_OPERATORS)

# We need to hide a ton of warnings
include("${CMAKE_CURRENT_LIST_DIR}/cmake-includes/anura/silence-warnings/CMakeLists.txt")

# END Compiler config

# BEGIN Linker config

# Output an executable from the anura sources for anura
add_executable(anura "${anura_SRC}")

# Link libraries
target_link_libraries(
anura
PRIVATE
)

# END Linker config
Loading

0 comments on commit e27f112

Please sign in to comment.