Skip to content

Commit 1a6bc53

Browse files
authored
setup.py: Extra CMake Arg Control (#1199)
* `setup.py`: Extra CMake Arg Control * EMSCRIPTEN: Skip Py Extension
1 parent 37a5de1 commit 1a6bc53

4 files changed

Lines changed: 22 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,12 @@ if(openPMD_HAVE_PYTHON)
686686
endif()
687687
unset(_USE_PY_LTO)
688688

689-
pybind11_extension(openPMD.py)
689+
if(EMSCRIPTEN)
690+
set_target_properties(openPMD.py PROPERTIES
691+
PREFIX "")
692+
else()
693+
pybind11_extension(openPMD.py)
694+
endif()
690695
pybind11_strip(openPMD.py)
691696

692697
set_target_properties(openPMD.py PROPERTIES CXX_VISIBILITY_PRESET "hidden"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ export CMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF
212212
python3 -m pip install openpmd-api --no-binary openpmd-api
213213
```
214214

215+
Additional CMake options can be passed via individual environment variables, which need to be prefixed with `openPMD_CMAKE_`.
216+
215217
### From Source
216218

217219
[![Source Use Case](https://img.shields.io/badge/use_case-development-brightgreen)](https://cmake.org)

docs/source/install/install.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ For some exotic architectures and compilers, you might need to disable a compile
115115
# optional: --user
116116
python3 -m pip install openpmd-api --no-binary openpmd-api
117117
118+
Additional CMake options can be passed via individual environment variables, which need to be prefixed with ``openPMD_CMAKE_``.
119+
118120
.. _install-cmake:
119121

120122
.. only:: html

setup.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def build_extension(self, ext):
7979
# just as well win32 & cygwin (although Windows has no RPaths)
8080
cmake_args.append('-DCMAKE_INSTALL_RPATH=$ORIGIN')
8181

82+
cmake_args += extra_cmake_args
83+
8284
cfg = 'Debug' if self.debug else 'Release'
8385
build_args = ['--config', cfg]
8486

@@ -139,6 +141,16 @@ def build_extension(self, ext):
139141
CMAKE_INTERPROCEDURAL_OPTIMIZATION = os.environ.get(
140142
'CMAKE_INTERPROCEDURAL_OPTIMIZATION', None)
141143

144+
# extra CMake arguments
145+
extra_cmake_args = []
146+
for k, v in os.environ.items():
147+
extra_cmake_args_prefix = "openPMD_CMAKE_"
148+
if k.startswith(extra_cmake_args_prefix) and \
149+
len(k) > len(extra_cmake_args_prefix):
150+
extra_cmake_args.append("-D{0}={1}".format(
151+
k[len(extra_cmake_args_prefix):],
152+
v))
153+
142154
# https://cmake.org/cmake/help/v3.0/command/if.html
143155
if openPMD_USE_MPI.upper() in ['1', 'ON', 'TRUE', 'YES']:
144156
openPMD_USE_MPI = "ON"

0 commit comments

Comments
 (0)