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 1bfdc08 commit 0400135
Show file tree
Hide file tree
Showing 17 changed files with 4,641 additions and 483 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/pr-smoketest-debian.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- "trixie" # 13
compiler:
- g++
- clang
- clang++
container: debian:${{ matrix.debian }}-slim
steps:
- name: Install Dependencies
Expand All @@ -26,10 +26,18 @@ jobs:
run: |
apt-get -qq update
apt-get -qq upgrade -y
apt-get -qq install -y --no-install-recommends \
apt-file
apt-file update
apt-get -qq install -y --no-install-recommends \
ca-certificates \
git \
${{ matrix.compiler }} \
"$(\
apt-file search '/usr/bin/${{ matrix.compiler }}' \
| head -n 1 \
| cut -d' ' -f 1 \
| sed 's/://g' \
)" \
cmake \
make \
ccache \
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/pr-smoketest-fedora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ jobs:
fail-fast: false
matrix:
fedora:
# 32 is the oldest Fedora with a new enough glm
- "32"
- "33"
- "34"
- "35"
- "36"
# 37 is the oldest Fedora with a new enough dnf for resolving CXX
- "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}' \
)" \
cmake \
make \
ccache \
Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/pr-smoketest-opensuse-leap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,29 @@ jobs:
fail-fast: false
matrix:
suse:
# 15.3 is the oldest openSUSE Leap with a new enough glm
# 15.3 is the oldest openSUSE Leap with a new enough clang
- "15.3"
- "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
18 changes: 15 additions & 3 deletions .github/workflows/pr-smoketest-ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ jobs:
strategy:
fail-fast: false
matrix:
# Versions between LTS are not available for long - we only do forwards
ubuntu:
- "22.04" # LTS only for sanity
- "20.04"
- "22.04"
- "22.10"
- "23.04"
compiler:
- g++
- clang
- clang++
container: ubuntu:${{ matrix.ubuntu }}
steps:
- name: Install Dependencies
Expand All @@ -23,10 +27,18 @@ jobs:
run: |
apt-get -qq update
apt-get -qq upgrade -y
apt-get -qq install -y --no-install-recommends \
apt-file
apt-file update
apt-get -qq install -y --no-install-recommends \
ca-certificates \
git \
${{ matrix.compiler }} \
"$(\
apt-file search '/usr/bin/${{ matrix.compiler }}' \
| head -n 1 \
| 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
121 changes: 121 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# BEGIN CMake setup

# 3.12 added add_compile_definitions
cmake_minimum_required(VERSION 3.12)

# Include repo local modules
set(
CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake-includes/modules"
)

# END CMake setup

# 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 COMPONENTS filesystem regex)
find_package(SDL2 REQUIRED)
find_package(OpenGL REQUIRED)
find_package(Cairo REQUIRED)
find_package(ZLIB REQUIRED)
find_package(GLEW REQUIRED)
find_package(SDL2_ttf 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}"
"${SDL2_INCLUDE_DIRS}"
)

# 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/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
"${SDL2_LIBRARIES}"
"${OPENGL_LIBRARIES}"
"${Boost_LIBRARIES}"
"${CAIRO_LIBRARIES}"
"${FREETYPE_LIBRARIES}"
"${ZLIB_LIBRARIES}"
"${GLEW_LIBRARIES}"
"${SDL2_TTF_LIBRARIES}"
)

# END Linker config
Loading

0 comments on commit 0400135

Please sign in to comment.