Skip to content
Merged
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
8 changes: 7 additions & 1 deletion src/cppboot/generate/cmake_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,17 @@ def _src_cmake(ctx: _Context) -> str:

def _version_src_cmake(ctx: _Context) -> str:
if ctx.with_modules:
# BASE_DIRS must include the generated .cppm path; CMake rejects FILE_SET
# members outside the set's base directories (often defaults to this dir).
return f"""\
# version component (C++20 module) — generated from cmake/version.cppm.in + VERSION.
# Generated unit lives under the build tree; BASE_DIRS must cover that path.
target_sources(${{PROJECT_NAME}}_lib
PUBLIC
FILE_SET CXX_MODULES FILES
FILE_SET CXX_MODULES
BASE_DIRS
${{{ctx.macro}_GENERATED_DIR}}
FILES
${{{ctx.macro}_GENERATED_DIR}}/version.cppm
)
"""
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ def test_modules_layout(tmp_root: Path) -> None:
assert not (root / "cmake" / "version.hpp.in").exists()
cmake = (root / "CMakeLists.txt").read_text(encoding="utf-8")
assert "3.28" in cmake
version_cmake = (root / "src" / "version" / "CMakeLists.txt").read_text(encoding="utf-8")
assert "FILE_SET CXX_MODULES" in version_cmake
assert "BASE_DIRS" in version_cmake
assert "version.cppm" in version_cmake
main = (root / "src" / "main.cpp").read_text(encoding="utf-8")
assert "import " in main
assert "#include" not in main or "CLI" in main # CLI11 still classic header


def test_shared_library(tmp_root: Path) -> None:
Expand Down
Loading