Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Windows build to CMake #414

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/pr-unit-tests-static-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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 }}"

- name: Build Anura
run: msbuild /p:StopOnFirstFailure=true anura.sln

- name: temp show
run: dir
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/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/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/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
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"sdl2-image",
"sdl2-mixer",
"sdl2-ttf",
"libuuid",
{"name": "libuuid", "platform": "linux"},
"libwebp",
"harfbuzz",
"libjpeg-turbo",
Expand Down
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
Loading