Skip to content

CMake: grunk/version.hpp is not found when grunk is used via FetchContent/add_subdirectory #306

Closed

Description

@joergbrech

Summary

The CMake build cannot be used for static builds, for Emscripten, or via FetchContent/add_subdirectory without workarounds.

Update: item 1 (static / BUILD_SHARED_LIBS) is withdrawn. A grunk::state must only be driven by one runtime, so two copies of grunk's code operating on one state are not allowed, and static linking is therefore deliberately not supported. Only item 2 remains.

1. Hard-coded SHARED: add_library(grunk SHARED ...), grunk_recipe and the plugin library are always shared ... (withdrawn, see above)
2. grunk/version.hpp is not found when grunk is a sub-project. It is generated into grunk's own binary dir (${CMAKE_CURRENT_BINARY_DIR} of grunk/), but the include directories use $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>. In a standalone build both are the same; with FetchContent_MakeAvailable(grunk) the compile fails:

grunk/recipe.hpp:15:10: fatal error: grunk/version.hpp: No such file or directory

${PROJECT_BINARY_DIR} would be correct. In addition grunk/grunk.hpp includes the bare "version.hpp", which needs <build>/grunk on the include path too.

Workaround we use: include_directories(${FETCHCONTENT_BASE_DIR}/grunk-build) before FetchContent_MakeAvailable(grunk), and for WebAssembly a hand-written target.

Environment: grunk main (8af34a7, 0.5.0), parametric 0.3.5, sol2 3.5.0, Lua 5.4.8, GCC 15.3 (conda-forge), Linux x86-64; WebAssembly: Emscripten 3.1.58.
(Found while building a prototype GUI/viewer on top of grunk.)

Activity

  1. added
    bug
    on Oct 1, 2026
  2. self-assigned this
    on Oct 2, 2026
  3. added a commit that references this issue on Oct 2, 2026
    69c0f7a
  4. changed the title [-]CMake: libraries are hard-coded SHARED and grunk/version.hpp is not found when used via FetchContent/add_subdirectory[/-] [+]CMake: grunk/version.hpp is not found when grunk is used via FetchContent/add_subdirectory[/+] on Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions