Skip to content

Commit

Permalink
Port Windows build to CMake.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rotonen committed Dec 21, 2024
1 parent 96f7a52 commit 4b02cbc
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 3,163 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/pr-unit-tests-static-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Unit Tests / Required / Static / Windows
on:
pull_request:
merge_group:

jobs:
build:
name: Build and Test on Windows
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
build-type:
- Release
- Debug
steps:
- name: Checkout Anura
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
fetch-depth: 0

- name: Set MSBuild Up
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0

- name: Set ccache Up
uses: hendrikmuhs/ccache-action@ed74d11c0b343532753ecead8a951bb09bb34bc9 # v1.2.14
with:
key: unit-tests-windows-${{ matrix.build-type }}

- name: Build Prep Anura
run: |
cmake buildsystem\windows-static -D CMAKE_BUILD_TYPE="${{ matrix.build-type }}"
138 changes: 138 additions & 0 deletions buildsystem/windows-static/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# BEGIN CMake setup

# 3.12 added add_compile_definitions
cmake_minimum_required(VERSION 3.12)

# Default to debug builds
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()

# Use vcpkg for dependencies
set(VCPKG_MANIFEST_DIR "${CMAKE_BINARY_DIR}")
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_BINARY_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")

# Default to using LTO for Release builds
if (CMAKE_BUILD_TYPE MATCHES Release)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

# 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_BINARY_DIR}/src/*.cpp"
"${CMAKE_BINARY_DIR}/src/hex/*.cpp"
"${CMAKE_BINARY_DIR}/src/imgui/imgui_draw.cpp"
"${CMAKE_BINARY_DIR}/src/imgui/imgui_tables.cpp"
"${CMAKE_BINARY_DIR}/src/imgui/imgui_widgets.cpp"
"${CMAKE_BINARY_DIR}/src/imgui/imgui.cpp"
"${CMAKE_BINARY_DIR}/src/imgui_additions/*.cpp"
"${CMAKE_BINARY_DIR}/src/kre/*.cpp"
"${CMAKE_BINARY_DIR}/src/svg/*.cpp"
"${CMAKE_BINARY_DIR}/src/tiled/*.cpp"
"${CMAKE_BINARY_DIR}/src/treetree/*.cpp"
"${CMAKE_BINARY_DIR}/src/xhtml/*.cpp"
)

# Configure compiling against vcpkg provided libraries
# XXX - At the moment (2023-08) we have no idea of the upper and lower bounds
# XXX - At the moment (2023-08) we have no idea of the full minimal set
find_package(Threads REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem locale regex system)
find_package(ZLIB REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
find_package(Freetype REQUIRED)
find_package(GLM REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_mixer REQUIRED)
find_package(SDL2_ttf REQUIRED)
find_package(Ogg REQUIRED)
find_package(Vorbis REQUIRED)
find_package(harfbuzz CONFIG REQUIRED)
find_package(WebP CONFIG REQUIRED)
find_package(unofficial-lerc CONFIG REQUIRED)
find_package(zstd CONFIG REQUIRED)

# Add the headers
include_directories(
"${CMAKE_BINARY_DIR}/src"
"${CMAKE_BINARY_DIR}/src/hex"
"${CMAKE_BINARY_DIR}/src/imgui"
"${CMAKE_BINARY_DIR}/src/imgui_additions"
"${CMAKE_BINARY_DIR}/src/kre"
"${CMAKE_BINARY_DIR}/src/svg"
"${CMAKE_BINARY_DIR}/src/tiled"
"${CMAKE_BINARY_DIR}/src/treetree"
"${CMAKE_BINARY_DIR}/src/xhtml"
"${CMAKE_BINARY_DIR}/vcpkg_installed/x64-windows-static/include"
)

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

if (CMAKE_BUILD_TYPE MATCHES Debug)
# Debug builds need to be debuggable
set(VCPKG_TARGET_TRIPLET x64-windows-static-dbg)
set(VCPKG_BUILD_TYPE debug)
link_directories("${CMAKE_BINARY_DIR}/vcpkg_installed/x64-windows-static-dbg/debug/lib")
endif()

if (CMAKE_BUILD_TYPE MATCHES Release)
# Optimize release builds
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
set(VCPKG_TARGET_TRIPLET x64-windows-static-rel)
set(VCPKG_BUILD_TYPE release)
link_directories("${CMAKE_BINARY_DIR}/vcpkg_installed/x64-windows-static/release/lib")
endif()

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

if (CMAKE_BUILD_TYPE MATCHES Release)
# Turn all things debug, like assertions, off for a release build
add_compile_definitions(NDEBUG)
endif()

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

# END Compiler config

# BEGIN Linker config

# Staticly link dependencies in
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)

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

# END Linker config
10 changes: 0 additions & 10 deletions windows/README.md

This file was deleted.

30 changes: 0 additions & 30 deletions windows/anura.sln

This file was deleted.

Loading

0 comments on commit 4b02cbc

Please sign in to comment.