Skip to content

Create symbolic link during install#5277

Merged
ax3l merged 2 commits intoAMReX-Codes:developmentfrom
nischild:fix-symbolic-link-creation
Apr 10, 2026
Merged

Create symbolic link during install#5277
ax3l merged 2 commits intoAMReX-Codes:developmentfrom
nischild:fix-symbolic-link-creation

Conversation

@nischild
Copy link
Copy Markdown
Contributor

@nischild nischild commented Apr 8, 2026

Summary

Setting the install directory in the CMake install step gives an error in the creation of the symlink for libamrex.a.
The proposed fix creates the path for the symlink during the install step, allowing to change CMAKE_INSTALL_PREFIX in the install step.

Basically the fix moves the creation of the path-variable into cmake_install.cmake.
The previous version created the path in CMake configure step and the link during the CMake install step.

Reproducer

git clone https://github.com/AMReX-Codes/amrex.git
cmake -S . -B build
cmake --build build
cmake --install build --prefix install

Gives the error

CMake Error at build/cmake_install.cmake:420 (file):                                                                                                                                                                                                         
  file Copy failed: No such file or directory     

@WeiqunZhang
Copy link
Copy Markdown
Member

See also #4775 Are the two related?

@WeiqunZhang WeiqunZhang requested a review from ax3l April 8, 2026 16:48
@nischild
Copy link
Copy Markdown
Contributor Author

nischild commented Apr 9, 2026

Thanks for pointing out the MR.
Yes, it will also solve the above bug.
Are there any plans to merge #4775 for the coming releases of AMReX?

@ax3l
Copy link
Copy Markdown
Member

ax3l commented Apr 10, 2026

After a quick test: Your patch fixes the cmake --install --prefix ... failure.

I added one more fix for staged installs, which are commonly used by package builders and installers. I was not super aware of that workflow either and found it as an issue w/ Codex: DESTDIR is used where the install is written into a temporary root first instead of directly into the final location. For example:

DESTDIR=/tmp/amrex-stage cmake --install build --prefix /usr/local

That should place everything under: /tmp/amrex-stage/usr/local/...

Before the follow-up, the normal AMReX install rules did that correctly, but the legacy libamrex.a symlink step still tried to create the link under /usr/local/... instead of inside the staged tree. So packaging installs could fail, or produce an incomplete staged install.

The follow-up makes the legacy symlink behave like the rest of the install, and it also records that link in install_manifest.txt.

@ax3l ax3l enabled auto-merge (squash) April 10, 2026 06:50
@ax3l ax3l mentioned this pull request Apr 10, 2026
6 tasks
@ax3l ax3l merged commit e52fef9 into AMReX-Codes:development Apr 10, 2026
76 of 77 checks passed
ax3l added a commit that referenced this pull request Apr 10, 2026
## Summary

Cover `--prefix` and `DESTDIR` stage in the CMake install smoke test.

## Additional background

Was also reported in #4775

- [x] merge `development` after the fix in #5277 was merged

## Checklist

The proposed changes:
- [ ] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants