Skip to content

CMakeLists.txt proposed fixes for building on Gentoo Linux - #129

Open
Anoncheg1 wants to merge 1 commit into
GothicKit:mainfrom
Anoncheg1:cmakelist-pr
Open

CMakeLists.txt proposed fixes for building on Gentoo Linux #129
Anoncheg1 wants to merge 1 commit into
GothicKit:mainfrom
Anoncheg1:cmakelist-pr

Conversation

@Anoncheg1

@Anoncheg1 Anoncheg1 commented Jul 26, 2026

Copy link
Copy Markdown

Hi! I created Gentoo ebuild file with instruction to compile package from sources.

https://github.com/Anoncheg1/anonch-overlay/blob/main/dev-games/zenkit/zenkit-20251220.ebuild

it is for 2025-12-20 0e3b3f6

I use system Gentoo package instead of built-in:

  • media-libs/glm
  • media-libs/libsquish
  • dev-cpp/doctest

I tested it with working OpenGothic

https://github.com/Anoncheg1/anonch-overlay/blob/main/games-engines/opengothic/opengothic-1.0.3549.ebuild

Here is list of issues and fixes for CMakeLists.txt file. They simplify creation of Gentoo Ebuild. Please consider them to include in main.

ZenKit CMake Improvements for System Packaging

Focus On

  1. System dependency resolution — Replace hardcoded vendor targets with standard find_package() calls for glm, squish, and doctest
  2. Test framework integration — Fix the broken ${doctest_SOURCE_DIR} assumption and provide a static doctest_main.cc
  3. Installation cleanup — Remove obsolete include/phoenix path and stop installing bundled dependency headers

Detailed Description

1. Dependency Management (glm and squish)

Issue: The current CMakeLists.txt hardcodes vendor-specific target names (glm::glm_static) and lacks proper find_package() fallbacks. This completely breaks system packaging on distributions like Gentoo, where libraries are provided by the system package manager rather than built from bundled sources.

Impact: Package maintainers must forcefully overwrite vendor/CMakeLists.txt and use sed to rewrite target names — a fragile and non-portable solution.

Better Approach:

  • Use find_package(glm REQUIRED) and find_package(squish REQUIRED) at the top of the root CMakeLists.txt
  • Link against the standard exported target names (glm::glm, squish) instead of hardcoded static variants
  • If fallback to bundled vendors is still desired, make it conditional: if(NOT TARGET glm::glm) then fall back to add_subdirectory(vendor/...)

Note on squish: Gentoo's media-libs/libsquish installs its header as /usr/include/squish/squish.h (inside a subdirectory). Upstream should either document this expectation or provide a proper CMake config module for squish that sets INTERFACE_INCLUDE_DIRECTORIES correctly.

2. Test Framework Integration (doctest)

Issue: The current code relies on ${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake, which is only defined when doctest is built via FetchContent or add_subdirectory(). When doctest is installed system-wide via a package manager (providing only doctest-config.cmake), this variable is undefined, and the include fails.

Additionally, the current approach dynamically generates a doctest_with_main library via file(WRITE ...) inside CMake, which is non-idiomatic and complicates packaging.

Impact: System-packaged doctest cannot be used without patching.

Better Approach:

  • Use find_package(doctest REQUIRED) to obtain the doctest::doctest imported target
  • Explicitly include the helper module via include("${doctest_DIR}/doctest.cmake") to get the doctest_discover_tests() function. (Note: find_package() alone provides the target but not the helper functions — both steps are required.)
  • Provide a static tests/doctest_main.cc file containing:
    #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
    #include <doctest/doctest.h>
    This eliminates the need for dynamic file generation and follows standard doctest practice.

3. Installation Rules (Obsolete Paths & Bundled Headers)

Issue:

  • The install rule install(DIRECTORY "include/phoenix" TYPE INCLUDE) references a directory that was renamed to zenkit, causing CMake to error or warn during the install phase.
  • The root CMakeLists.txt contains a loop that attempts to install glm headers. Package managers strictly control system headers, and bundled dependencies should not be re-installed.

Impact: Package builds fail or produce warnings; system headers may be duplicated or conflict with the system-provided glm package.

Better Approach:

  • Remove the obsolete install(DIRECTORY "include/phoenix" ...) line entirely.
  • Remove the glm installation loop. Consumers of ZenKit will find_package(glm) themselves if needed.
  • If installation of bundled headers is ever desired, gate it behind an explicit option (e.g., ZK_INSTALL_BUNDLED_DEPS, defaulting to OFF).

@Anoncheg1 Anoncheg1 changed the title CMakeLists.txt fixes for Gentoo Linux Ebuild CMakeLists.txt proposed fixes for building on Gentoo Linux Jul 28, 2026
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.

1 participant