Conversation
The generated `openPMD.pc` ignored `openPMD_INSTALL_*DIR` and the
actual install prefix. Now it follows the real install layout:
- use `openPMD_INSTALL_{BIN,LIB,INCLUDE}DIR`, keep absolute dirs
- substitute `prefix` at install time (`cmake --install --prefix`)
- `exec_prefix=${prefix}` (was `${prefix}/bin`), add `bindir`
- derive `openPMD_INSTALL_CMAKEDIR` and the default
`openPMD_INSTALL_PYTHONDIR` from `openPMD_INSTALL_LIBDIR`
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`openPMD` requires C++17 and links MPI publicly (public headers include `mpi.h` and call MPI functions), but `openPMD.pc` provided neither. - `Cflags`: add the C++17 flag and the MPI compile options, definitions and include directories - `Libs`: add the MPI link flags and libraries - escape arguments in `Libs`/`Cflags` and quote the directory variables, so paths with spaces (e.g., MS-MPI) work - docs: mention the flags and the `-std` flag order Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Review fixes for the generated `openPMD.pc`: - C++ standard flag: move from `Cflags` to the new `cxxstd` variable, since it overrode newer standards of consumers (e.g., CMake's `pkg_check_modules(IMPORTED_TARGET)`) and broke C sources - escape the install prefix and directories instead of quoting them, which broke prefixes with spaces under pkg-config's define-prefix - absolute `prefix` for a relative `cmake --install --prefix` - MPI libraries as `-L`/`-l`: CMake's FindPkgConfig places plain paths before the object files, which fails to link with `--as-needed` - do not escape multi-argument link items, e.g., `-framework X` - drop openPMD's own MPI C++ binding skip defines from `Cflags` - no duplicate MPI flags with `--static` or `openPMD_MPI_LINK_C` - docs: `cxxstd` variable, builds with MPI compiler wrappers Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The generated
openPMD.pcdid not follow the actual install layout and lacked the public usage requirements ofopenPMD.Install directories
openPMD_INSTALL_{BIN,LIB,INCLUDE}DIR, keep absolute dirs (e.g., Nix) as they areprefixat install time: honorscmake --install --prefix(also relative) andDESTDIRexec_prefix=${prefix}(was${prefix}/bin), addbindiropenPMD_INSTALL_CMAKEDIRand the defaultopenPMD_INSTALL_PYTHONDIRfromopenPMD_INSTALL_LIBDIRPublic usage requirements
Cflags; MPI link flags and libraries inLibs(public headers includempi.hand call MPI functions)cxxstdwith the C++ standard flag:pkg-config --variable=cxxstd openPMD(e.g.,-std=c++17)#, quotes)Details: behavior changes, design, testing, known limitations
Behavior changes (changelog):
pkg-config --variable=exec_prefix openPMDnow returns the prefix (GNU/pkg-config convention); use the newbindirfor the CLI tools.cxxstdvariable. The flag is intentionally not inCflags: it would override newer standards requested by consumers, e.g., CMake'spkg_check_modules(IMPORTED_TARGET)puts it after the target's own-std=c++20, and it breaks C sources.Bugs fixed (reproduced before the change):
-DopenPMD_INSTALL_LIBDIR=lib64 -DopenPMD_INSTALL_INCLUDEDIR=include/openpmdinstalled there, but the.pcpointed tolibandinclude.CMAKE_INSTALL_LIBDIRproducedlibdir=${prefix}//abs/lib.GNUInstallDirsis not included, soCMAKE_INSTALL_LIBDIRis typically empty andlibdir=${prefix}/resulted (code inspection, not tested on Windows). Same for the default Python install dir (/site-packages).openPMD_INSTALL_LIBDIRset, the CMake package config still went to${CMAKE_INSTALL_LIBDIR}/cmake/openPMD..pcflags alone failed withmpi.h: No such file or directory.Design:
string(REPLACE)ininstall(CODE)rather than a secondconfigure_file, so dependency paths are not rescanned for@VAR@. The install code setscmake_policy(VERSION 3.22), since install scripts run with policies unset (CMP0053 would expand@VAR@).prefixinstead of a relocatable${pcfiledir}-relative one: the latter breaks when only the.pcfile is symlinked elsewhere. Package managers (conda, Spack) rewrite absolute prefixes when relocating.MPI::MPI_<lang>target properties contain generator expressions ($<HOST_LINK:SHELL:...>,$<COMPILE_LANG_AND_ID:...>). Shared MPI libraries are written as-L<dir> -l<name>, since FindPkgConfig places plain paths before the object files, which fails to link with--as-needed. TheMPICH_SKIP_MPICXX/OMPI_SKIP_MPICXX/_MPICC_Hdefines are only for building openPMD itself and are filtered, as for CMake consumers.PUBLICoptions (/bigobj,/Zc:__cplusplus) are not added: public headers do not use__cplusplus.Tested (Linux, real build + install; pkgconf 1.8.1 and pkg-config 0.29.2, each with and without define-prefix;
pkgconf --validateok):--prefix <other>, relative--prefixfrom another directory, trailing slash, prefix with a space and#,DESTDIR,lib64+ custom includedir, absolute lib/include dirs, unchanged re-install isUp-to-date. A consumer compiled, linked and ran using only the.pcflags.openPMD::Series(..., MPI_COMM_WORLD)compiled with plaing++(notmpicxx),-std=c++14followed bycxxstd, linked and ran on 2 ranks. Controls fail as expected: previous flags (mpi.hnot found),-std=c++14withoutcxxstd.pkg_check_modules(IMPORTED_TARGET)consumer withCXX_STANDARD 20and-Wl,--as-needed: compiles as C++20 only, links and runs on 2 ranks; control with plain MPI library paths fails withundefined reference to symbol 'MPI_Init'.openPMD_MPI_LINK_C=ONand--static: no duplicate MPI flags. Unit tests for the escape/link helpers (including-framework Xkept as is).Known limitations, not addressed here:
mpicxx, CrayCC), FindMPI reports no MPI flags; consumers need the same wrapper (documented).--define-prefix(default in e.g. conda-forge's pkg-config) guesses the prefix as two levels above the.pcfile, which is wrong for multiarch libdirs such aslib/x86_64-linux-gnu. This affects every package (verified with Debian'szlib.pc).-Wl,-rpath,<MPI prefix>/lib, as withmpicxxand CMake'sMPI::MPI_CXX: anotherlibopenPMDin that prefix can shadow the intended one. Seen in testing with a conda env shipping openPMD-api 0.17.1 (also via conda'sLDFLAGS).--variable=prefix/libdir/... show the escaping backslashes (as with define-prefix).${and$$in paths are not escaped. pkgconf 1.8.1 does not re-escape spaces on output for arguments other than-I/-L.Libs.privatedoes not list the libraries of imported targets (e.g., ADIOS2, HDF5) themselves, and FindHDF5'sdebug/optimizedkeywords can leak into it.🤖 Generated with Claude Code