Skip to content

build(cmake): modernize build system and dependency management#262

Open
tategotoazarasi wants to merge 7 commits intoParadoxGameConverters:fetchcontentfrom
tategotoazarasi:master
Open

build(cmake): modernize build system and dependency management#262
tategotoazarasi wants to merge 7 commits intoParadoxGameConverters:fetchcontentfrom
tategotoazarasi:master

Conversation

@tategotoazarasi
Copy link

This PR refactors the entire build system to move away from bundled git submodules in favor of a hybrid approach using find_package, FetchContent, and vcpkg. It also unifies cross-platform build logic and resolves linking errors on Windows.

Build System & Dependencies

  • cmake: bumped minimum version to 3.25 to support modern dependency handling.
  • deps: removed bundled external/ libraries (wxWidgets, commonItems, SQLiteCpp) in favor of system packages or FetchContent.
  • deps: added vcpkg.json and vcpkg-configuration.json for manifest-mode dependency management.
  • sqlite: forced SQLiteCpp to be fetched from source to prevent ABI mismatches (DLL/Static runtime) and C++ standard conflicts on Windows.
  • wxwidgets: updated discovery logic to prioritize Config mode targets (wx::core, wx::net) over legacy variables.
  • curl: added PkgConfig fallback for Linux systems.

Windows & Platform Fixes

  • fix(windows): added WIN32 flag to add_executable. This ensures the linker correctly locates the WinMain entry point provided by wxWidgets, fixing LNK2019 errors.
  • fix(build): replaced usage of CMAKE_SOURCE_DIR with CMAKE_CURRENT_SOURCE_DIR to ensure correct path resolution when the project is consumed as a submodule.
  • refactor: removed Copy_Files.sh and replaced it with unified cmake -E copy post-build commands, resolving build failures on Linux when paths differed from expectations.

CI/CD

  • ci: bumped actions/checkout to v6.

BREAKING CHANGE: The external/ directory has been removed. The build process now requires an internet connection during the initial configuration to download dependencies via FetchContent or VCPKG. Legacy build scripts (Copy_Files.sh) have been removed; resources are now copied automatically by CMake post-build events.

tategotoazarasi and others added 7 commits November 18, 2025 22:02
Upgrade CMake minimum requirement to 3.25 and refactor dependency
resolution logic.
- Implement `find_package` with `FetchContent` fallback for `SQLiteCpp`,
  `CURL`, `wxWidgets`, and `commonItems`.
- Add `PkgConfig` support for locating `libcurl` on Linux and manually
  define the `CURL::libcurl` target if missing.
- Standardize C++23 settings via CMake properties instead of flags.
- Use target-based linking semantics for all dependencies.
- Refactor platform-specific source selection and post-build copy commands.
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…verters#260)

Bumps [external/commonItems](https://github.com/ParadoxGameConverters/commonItems) from `df4ab8e` to `b67c85f`.
- [Commits](ParadoxGameConverters/commonItems@df4ab8e...b67c85f)

---
updated-dependencies:
- dependency-name: external/commonItems
  dependency-version: b67c85f0d26396cb98981a732365a27df0e2bc98
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
The Windows build was failing with multiple linker errors due to entry
point mismatches and ABI incompatibilities with pre-built VCPKG libraries.

Changes:
- Add `WIN32` to `add_executable`. This ensures the linker uses the
  Windows subsystem, correctly locating the `WinMain` entry point provided
  by wxWidgets instead of looking for `main`.
- Force `SQLiteCpp` to build from source via `FetchContent` instead of
  using the VCPKG package. This resolves `LNK2019` errors for
  `SQLite::Database` caused by C++ standard mismatches (specifically
  regarding C++23 and `std::filesystem` support).
- Update `wxWidgets` discovery to correctly prioritize imported targets
  (Config mode) over legacy variables, ensuring better VCPKG compatibility.
- Update `CMakePresets.json` to inject the VCPKG toolchain file from the
  environment variables and simplify the build directory structure.
The build configuration previously relied on `CMAKE_SOURCE_DIR`, which
caused path resolution errors when the project was included as a
dependency (e.g., via FetchContent) in another project. Additionally,
link errors occurred due to mismatched SQLiteCpp configurations and
missing Windows subsystem flags.

Changes:
- Use `CMAKE_CURRENT_SOURCE_DIR` and `PROJECT_SOURCE_DIR` for source
  globbing and resource copying. This ensures paths resolve correctly
  regardless of the project hierarchy.
- Force `SQLiteCpp` to be fetched from source. This prevents linking
  against VCPKG's DLL version, which caused ABI mismatches regarding
  C++23 and `std::filesystem` support.
- Add `WIN32` to `add_executable`. This forces the linker to use the
  `/SUBSYSTEM:WINDOWS` flag, resolving entry point errors (missing
  `WinMain`) when linking with wxWidgets.
The Linux build previously relied on `Copy_Files.sh`, which contained
hardcoded relative paths that caused build failures when the project was
included as a submodule (e.g., via FetchContent).

This change removes the platform-specific shell script execution and
standardizes the post-build step to use `cmake -E copy` commands for all
operating systems. This ensures resources are correctly deployed to the
runtime output directory regardless of the build structure.

Signed-off-by: Zhiheng Wang <Z.Wang252@liverpool.ac.uk>
Copy link
Member

@Zemurin Zemurin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert on build systems, and as a complete layman I can offer only this:

  • With the removal of external folder the VS project doesn't build anymore.
  • Opening cmake project in Vs leads to this:
image

As a result I don't see how this approach to modernization is supposed to work on windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants