SLINT_TARGET_SOURCES sets target_include_directories using a generator expression
Some checks failed
CI / node_test (macos-14) (push) Has been cancelled
CI / miri (push) Has been cancelled
autofix.ci / format_fix (push) Has been cancelled
autofix.ci / lint_typecheck (push) Has been cancelled
CI / files-changed (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / wasm (push) Has been cancelled
CI / wasm_demo (push) Has been cancelled
CI / tree-sitter (push) Has been cancelled
CI / node_test (ubuntu-22.04) (push) Has been cancelled
CI / node_test (windows-2022) (push) Has been cancelled
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, macos-14, stable) (push) Has been cancelled
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, 1.85) (push) Has been cancelled
CI / python_test (macos-14) (push) Has been cancelled
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Has been cancelled
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Has been cancelled
CI / build_and_test (ubuntu-22.04, 1.85) (push) Has been cancelled
CI / build_and_test (ubuntu-22.04, nightly) (push) Has been cancelled
CI / python_test (ubuntu-22.04) (push) Has been cancelled
CI / python_test (windows-2022) (push) Has been cancelled
CI / cpp_test_driver (macos-13) (push) Has been cancelled
CI / cpp_test_driver (ubuntu-22.04) (push) Has been cancelled
CI / mcu-embassy (push) Has been cancelled
CI / cpp_test_driver (windows-2022) (push) Has been cancelled
CI / cpp_cmake (macos-14, 1.85) (push) Has been cancelled
CI / cpp_cmake (ubuntu-22.04, stable) (push) Has been cancelled
CI / cpp_cmake (windows-2022, nightly) (push) Has been cancelled
CI / ffi_32bit_build (push) Has been cancelled
CI / cpp_package_test (push) Has been cancelled
CI / vsce_build_test (push) Has been cancelled
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Has been cancelled
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Has been cancelled
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Has been cancelled
CI / updater_test (0.3.0) (push) Has been cancelled
CI / fmt_test (push) Has been cancelled
CI / esp-idf-quick (push) Has been cancelled
CI / android (push) Has been cancelled
CI / test-figma-inspector (push) Has been cancelled

This ensures that the binary directory path isn't exposed in the
target's `INTERFACE_INCLUDE_DIRECTORIES`.

This prevents CMake errors when we `install` a target with generated
Slint sources in the include directory:

```
[cmake] CMake Error in slint/cpp/CMakeLists.txt:
[cmake]   Target "slint-demo-cpp" INTERFACE_INCLUDE_DIRECTORIES property contains
[cmake]   path:
[cmake]
[cmake]     "/path/to/build/slint/cpp"
[cmake]
[cmake]   which is prefixed in the build directory.
```
This commit is contained in:
Nathan Collins 2025-06-25 13:13:54 +00:00 committed by Simon Hausmann
parent 68b46276af
commit ff0d450778

View file

@ -91,5 +91,5 @@ function(SLINT_TARGET_SOURCES target)
target_sources(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${_SLINT_BASE_NAME}.h ${cpp_files})
endforeach()
target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(${target} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
endfunction()