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 b223a3a
Show file tree
Hide file tree
Showing 14 changed files with 4,384 additions and 464 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pr-smoketest-debian.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ 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:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/pr-smoketest-fedora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ 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"
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pr-smoketest-opensuse-leap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ jobs:
fail-fast: false
matrix:
suse:
# 15.3 is the oldest openSUSE Leap with a new enough glm
- "15.3"
# 15.2 is the oldest openSUSE Leap with a new enough clang
- "15.4"
- "15.5"
compiler:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-unit-tests-dynamic-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ 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:
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
88 changes: 88 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# 3.12 added add_compile_definitions
cmake_minimum_required(VERSION 3.12)

# 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(Boost REQUIRED)
find_package(Freetype 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"
"${Boost_INCLUDE_DIRS}"
"${FREETYPE_INCLUDE_DIRS}"
"${SDL2_INCLUDE_DIRS}"
)

# Configure compiler flags

# Good things, to keep

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

# Set c++ standard to c++0x
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")

# 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")

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

# Configure linking against system provided libraries
target_link_libraries(
anura
LINK_PUBLIC
"${Boost_LIBRARIES}"
"${FREETYPE_LIBRARIES}"
"${SDL2_LIBRARIES}"
)
Loading

0 comments on commit b223a3a

Please sign in to comment.