Skip to content

Modernize CMake build system with target-based dependencies and FetchContent fallback#5

Open
Copilot wants to merge 3 commits intomasterfrom
copilot/refactor-cmake-to-idiomatic
Open

Modernize CMake build system with target-based dependencies and FetchContent fallback#5
Copilot wants to merge 3 commits intomasterfrom
copilot/refactor-cmake-to-idiomatic

Conversation

Copy link

Copilot AI commented Jan 31, 2026

The CMakeLists.txt had accumulated complexity from platform-specific workarounds and used legacy CMake patterns (global variables, FILE(GLOB), include_directories()). This refactors to modern, idiomatic CMake 3.16+.

Core Changes

  • Target-based build options: Compile flags encapsulated in Ygor::CompileOptions and Ygor::SanitizerOptions INTERFACE libraries
  • Proper transitive dependencies: Ygor::ygor exports include paths and links, downstream projects just target_link_libraries(app PRIVATE Ygor::ygor)
  • FetchContent fallback: Eigen auto-downloads if not found locally (controllable via FETCHCONTENT_FALLBACK)
  • Graceful degradation: Missing optional dependencies disable themselves with status message instead of failing

CMake Package Export

Installed library now provides proper CMake package config:

find_package(Ygor REQUIRED)
target_link_libraries(myapp PRIVATE Ygor::ygor)

Cross-Compilation Support

Added toolchain files in cmake/toolchains/:

  • mingw-w64-x86_64.cmake - Windows
  • macos-x86_64.cmake - macOS via osxcross
  • aarch64-linux-gnu.cmake / armv7-linux-gnueabihf.cmake - ARM
  • musl-linux.cmake - Alpine/embedded

Other Improvements

  • Explicit source listing replaces FILE(GLOB)
  • Library versioning (SOVERSION)
  • Fixed MEMORY_CONSTRAINED_BUILD to preserve Debug assertions
  • Generator expressions for config-specific flags

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • gitlab.com
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED s-through=-lgcc_/home/REDACTED/work/Ygor/Ygor/src s-th�� d/src --local /x86_64-linux-gnx86_64-linux-gnu ples.cc.o (dns block)
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED git conf�� USE_LINUX_SYS=1 --64 --local (dns block)
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED make conf�� d/src --local p/bin/as ding CXX object as ect CMakeFiles/c-I (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 31, 2026 03:38
…Content fallback

Co-authored-by: hdclark <934858+hdclark@users.noreply.github.com>
…d fix MEMORY_CONSTRAINED_BUILD

Co-authored-by: hdclark <934858+hdclark@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor CMake files to modern idiomatic style Modernize CMake build system with target-based dependencies and FetchContent fallback Jan 31, 2026
Copilot AI requested a review from hdclark January 31, 2026 03:41
@hdclark hdclark marked this pull request as ready for review January 31, 2026 04:18
@hdclark
Copy link
Owner

hdclark commented Jan 31, 2026

@copilot please review this pull request

Copy link
Author

Copilot AI commented Jan 31, 2026

@copilot please review this pull request

I've performed a self-review of this PR. Here's a summary:

Verified working:

  • Build succeeds with GCC 13.3 (Release mode)
  • Static and shared library builds work correctly
  • Installation produces proper CMake package config files
  • Downstream find_package(Ygor) works as expected

Key changes:

  • Bumped CMake minimum to 3.16 for FetchContent
  • INTERFACE libraries encapsulate compile/sanitizer options
  • FILE(GLOB) replaced with explicit source listing
  • FetchContent fallback for Eigen (gracefully disabled if network unavailable)
  • Toolchain files for cross-compilation (MinGW, macOS, ARM, musl)

Areas to verify:

  1. The toolchain files are examples and may need adjustment for specific environments
  2. FetchContent URL hash for Eigen should be verified if updating to newer versions
  3. Some existing platform-specific quirks may need re-testing on those platforms

Build verified in commit df91603.

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