build(cmake): make OptiX PTX available to build-tree tests#352
Conversation
- Add a stable build-tree PTX output directory at `${PROJECT_BINARY_DIR}/ptx`
- Copy generated OptiX PTX files into that directory via a `gphox_ptx` target
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fef177cff3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| #define GPHOX_CONFIG_SEARCH_PATHS ".:config:@GPHOX_INSTALL_FULL_DATADIR@/config" | ||
| #define GPHOX_PTX_DIR "@CMAKE_INSTALL_FULL_LIBDIR@" | ||
| #define GPHOX_PTX_SEARCH_PATHS "@GPHOX_BUILD_PTX_DIR@:@CMAKE_INSTALL_FULL_LIBDIR@" |
There was a problem hiding this comment.
Prefer installed PTX for installed binaries
Because this generated header is compiled into gphox for both build-tree and installed artifacts, the absolute @GPHOX_BUILD_PTX_DIR@ is still present after cmake --install. Config::PtxPath searches entries in macro order and returns the first existing file, so installed executables run on the build host will load ${build}/ptx/CSGOptiX7.ptx instead of the installed libdir copy; after a rebuild or multi-config build that can silently use stale or configuration-mismatched PTX. Consider using separate build/install-time paths or ensuring installed artifacts prefer only the install libdir.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR makes generated OptiX PTX discoverable from the build tree (in addition to the install tree), so uninstalled ctest/local workflows can resolve CSGOptiX7.ptx at runtime via Config::PtxPath.
Changes:
- Introduces a build-tree PTX directory (
${PROJECT_BINARY_DIR}/ptx) and adds it to the PTX search path list. - Copies the generated OptiX PTX into the build-tree PTX directory as part of building
CSGOptiX. - Refactors colon-delimited search-path parsing into a shared helper used by both config and PTX lookup.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/config.cpp | Adds generic search-path splitting and updates PTX resolution to search build + install candidates with improved error output. |
| src/config_path.h.in | Replaces single PTX dir macro with a build+install PTX search path macro. |
| CSGOptiX/CMakeLists.txt | Adds a custom target to copy the generated PTX into the build tree and wires it into the library build. |
| CMakeLists.txt | Defines GPHOX_BUILD_PTX_DIR for use by build rules and configured headers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| std::vector<std::string> SplitSearchPaths(std::string_view paths) | ||
| { | ||
| std::vector<std::string> search_paths; | ||
|
|
||
| size_t last = 0; | ||
| size_t next = 0; | ||
| while ((next = paths.find(':', last)) != std::string_view::npos) | ||
| { | ||
| search_paths.push_back(std::string{paths.substr(last, next - last)}); | ||
| last = next + 1; | ||
| } | ||
|
|
||
| search_paths.push_back(std::string{paths.substr(last)}); | ||
| return search_paths; | ||
| } |
There was a problem hiding this comment.
This is true for Windows-style drive-letter paths, but Simphony currently does not support Windows and the existing config search path convention is already Unix-style colon separation. I’m going to keep the current parser scoped to supported platforms for now.
| #define GPHOX_CONFIG_SEARCH_PATHS ".:config:@GPHOX_INSTALL_FULL_DATADIR@/config" | ||
| #define GPHOX_PTX_DIR "@CMAKE_INSTALL_FULL_LIBDIR@" | ||
| #define GPHOX_PTX_SEARCH_PATHS "@CMAKE_INSTALL_FULL_LIBDIR@:@GPHOX_BUILD_PTX_DIR@" |
Make generated OptiX PTX available from the build tree so uninstalled test and development workflows
can resolve
CSGOptiX7.ptx.Motivation
Some
ctesttargets and local build-tree runs instantiate the CSGOptiX pipeline, which requires thegenerated
CSGOptiX7.ptxfile at runtime. Previously, runtime lookup only fell back to the installlibdir, so these workflows required either installing the project first or manually setting
CSGOptiX__optixpath.This PR gives the build tree a stable PTX location and teaches runtime lookup to search it.