Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wheel building with scikit build core #3087

Open
wants to merge 112 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 104 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
e9101ab
draft scikit build core wheel
shimwell Jul 19, 2024
e857f45
renamed executable
shimwell Jul 19, 2024
61b7035
linking libopenmc with openmc in cmakelists
jon-proximafusion Jul 19, 2024
12cb43d
Merge branch 'scikit_build_core_wheel' of github.com:shimwell/openmc …
jon-proximafusion Jul 19, 2024
2541d50
updated docs for pip install that compiles
jon-proximafusion Jul 19, 2024
f15e80f
pip install with cmake args in ci
jon-proximafusion Jul 23, 2024
3c98d8a
added missing ,
jon-proximafusion Jul 23, 2024
0aafd44
no need for manual creation of build dir
jon-proximafusion Jul 23, 2024
12b4221
[skip ci] merged develop
shimwell Jul 26, 2024
9ef3beb
[skip ci] adding apt packages for read the docs
shimwell Jul 26, 2024
40ceaad
[skip ci] trying ubuntu 22.04
shimwell Jul 26, 2024
2c8cf71
[skip ci] added missing s
shimwell Jul 26, 2024
4c0075f
adding gha actions
shimwell Jul 26, 2024
4de0d94
upper case ON for cmake args
shimwell Jul 26, 2024
688d688
added quotes to cmake args
shimwell Jul 26, 2024
07a4dcd
keeping same filename
shimwell Jul 26, 2024
9253977
running just pytest
shimwell Jul 26, 2024
1f01694
[skip ci] corrected cmake arg passing example
shimwell Jul 26, 2024
6850217
added diagnosis prints
shimwell Jul 27, 2024
a601de8
Merge branch 'scikit_build_core_wheel' of github.com:shimwell/openmc …
shimwell Jul 27, 2024
97a3f22
removed 2nd pip install which was overwritting
shimwell Jul 27, 2024
3ae207d
Merge branch 'develop' into scikit_build_core_wheel
shimwell Aug 14, 2024
e40cf3b
merge in develop
shimwell Aug 14, 2024
0213392
matching simulation results from ci
jon-proximafusion Aug 14, 2024
6e3e47e
using debug instead of on for DCMAKE_BUILD_TYPE
shimwell Sep 12, 2024
b4b4e3a
scikit-build-core added
ahnaf-tahmid-chowdhury Sep 17, 2024
79ae016
Add rpath
ahnaf-tahmid-chowdhury Sep 20, 2024
394b0f9
Install by scikit-build-core
ahnaf-tahmid-chowdhury Sep 24, 2024
12aec22
update python install doc
ahnaf-tahmid-chowdhury Sep 24, 2024
564cb5f
add support for dev mode
ahnaf-tahmid-chowdhury Sep 24, 2024
1f1faca
update dev doc with skbuild support
ahnaf-tahmid-chowdhury Sep 24, 2024
f4e0faa
Merge branch 'openmc-dev:develop' into scikit_build_core_wheel
shimwell Sep 24, 2024
f88e5ef
Merge branch 'scikit-build-core' into scikit_build_core_wheel
ahnaf-tahmid-chowdhury Sep 24, 2024
f114265
back to -j4 for make
jon-proximafusion Sep 25, 2024
c577d50
adding cmake args to pip install command
jon-proximafusion Sep 25, 2024
ec7e11f
[skip ci] cmake args actual openmc options
jon-proximafusion Sep 25, 2024
03a6744
add manylinux docker
ahnaf-tahmid-chowdhury Sep 30, 2024
556adbb
add gcc and mpi build
ahnaf-tahmid-chowdhury Sep 30, 2024
ef1ca2f
Add openmc options and add more docs
ahnaf-tahmid-chowdhury Sep 30, 2024
ead096d
install openmpi on openmpi stage
ahnaf-tahmid-chowdhury Sep 30, 2024
8a7362e
add /usr/local/lib64 to path
ahnaf-tahmid-chowdhury Sep 30, 2024
9985fab
add workflow
ahnaf-tahmid-chowdhury Sep 30, 2024
65ae22c
remove setup.py
ahnaf-tahmid-chowdhury Sep 30, 2024
ac5648c
remove test stage
ahnaf-tahmid-chowdhury Oct 1, 2024
db8265f
add pypi
ahnaf-tahmid-chowdhury Oct 1, 2024
a205ef7
move python deps to last
ahnaf-tahmid-chowdhury Oct 1, 2024
7036ec6
fix pytest-cov issue
ahnaf-tahmid-chowdhury Oct 2, 2024
1d8e951
fix pytest-cov issue
ahnaf-tahmid-chowdhury Oct 2, 2024
0043634
no need abi
ahnaf-tahmid-chowdhury Oct 2, 2024
9e65e4a
fix path
ahnaf-tahmid-chowdhury Oct 2, 2024
1985003
move openmc to src
ahnaf-tahmid-chowdhury Oct 3, 2024
303f596
no need to copy lib to openmc
ahnaf-tahmid-chowdhury Oct 3, 2024
1813d6e
remove BUILD_EXAMPLES
ahnaf-tahmid-chowdhury Oct 3, 2024
2cbce3b
python deps stage
ahnaf-tahmid-chowdhury Oct 3, 2024
a88e926
Merge remote-tracking branch 'upstream/develop' into scikit_build_cor…
ahnaf-tahmid-chowdhury Oct 3, 2024
d588670
pip install numpy
ahnaf-tahmid-chowdhury Oct 3, 2024
4b08da7
fail-fast: false
ahnaf-tahmid-chowdhury Oct 3, 2024
db2bb3f
sdist.include = ["src/openmc/**"]
ahnaf-tahmid-chowdhury Oct 3, 2024
63e1b26
set DATAROOTDIR
ahnaf-tahmid-chowdhury Oct 4, 2024
cbca837
add vendor packages
ahnaf-tahmid-chowdhury Oct 4, 2024
995c840
add more dirs
ahnaf-tahmid-chowdhury Oct 4, 2024
d68bac5
CMAKE_INSTALL_DATADIR
ahnaf-tahmid-chowdhury Oct 4, 2024
07126a0
no need OpenMCTargets for skbuild
ahnaf-tahmid-chowdhury Oct 5, 2024
bf0f400
install rpath if var is defined
ahnaf-tahmid-chowdhury Oct 5, 2024
12acf73
eval $(ncrystal-config --setup)
ahnaf-tahmid-chowdhury Oct 5, 2024
bf334ce
sdist include *.h5
ahnaf-tahmid-chowdhury Oct 8, 2024
e3398a4
Merge remote-tracking branch 'upstream/develop' into scikit_build_cor…
ahnaf-tahmid-chowdhury Oct 8, 2024
4e69397
setup openmc lib for skbuild
ahnaf-tahmid-chowdhury Oct 17, 2024
4a69b09
prepare for merge
ahnaf-tahmid-chowdhury Oct 17, 2024
3b80c4c
Merge remote-tracking branch 'upstream/develop' into scikit_build_cor…
ahnaf-tahmid-chowdhury Oct 17, 2024
d0740ce
move openmc to src again
ahnaf-tahmid-chowdhury Oct 17, 2024
fbda530
update lib paths
ahnaf-tahmid-chowdhury Oct 17, 2024
0d3f6f2
add include
ahnaf-tahmid-chowdhury Oct 18, 2024
15e34f9
Merge remote-tracking branch 'upstream/develop' into scikit_build_cor…
ahnaf-tahmid-chowdhury Oct 19, 2024
af0f1d5
add openmc.in
ahnaf-tahmid-chowdhury Oct 19, 2024
e2802f3
use OpenMC targets
ahnaf-tahmid-chowdhury Oct 19, 2024
db1d8d1
install source version
ahnaf-tahmid-chowdhury Oct 19, 2024
7a0a56d
add SKBUILDScripts.cmake
ahnaf-tahmid-chowdhury Oct 20, 2024
8dabae4
update get_core_path
ahnaf-tahmid-chowdhury Oct 20, 2024
b8f634c
add /usr/local/lib/ to lib path
ahnaf-tahmid-chowdhury Oct 20, 2024
73cd266
remove file openmc_exec
ahnaf-tahmid-chowdhury Oct 20, 2024
ea6fab9
remove openmc_exec
ahnaf-tahmid-chowdhury Oct 20, 2024
e519189
Allow CMAKE_INSTALL_RPATH_USE_LINK_PATH
ahnaf-tahmid-chowdhury Oct 20, 2024
32d96e2
renamed to GenerateScript.cmake
ahnaf-tahmid-chowdhury Oct 20, 2024
f52ff64
remove SKBUILDScripts
ahnaf-tahmid-chowdhury Oct 20, 2024
d1f8ae3
revert
ahnaf-tahmid-chowdhury Oct 22, 2024
ddb6c96
update to 1.8
ahnaf-tahmid-chowdhury Oct 22, 2024
c1bcb8c
reduced diff
jon-proximafusion Nov 8, 2024
f7441af
Merge branch 'develop' into scikit_build_core_wheel
jon-proximafusion Nov 8, 2024
6065c69
reducing diff
jon-proximafusion Nov 8, 2024
2217521
prepare for merge
ahnaf-tahmid-chowdhury Nov 27, 2024
26c0367
Merge remote-tracking branch 'upstream/develop' into scikit_build_cor…
ahnaf-tahmid-chowdhury Nov 27, 2024
48b0ee5
mv openmc to src
ahnaf-tahmid-chowdhury Nov 27, 2024
6e8d1af
do not ignore .h5
ahnaf-tahmid-chowdhury Nov 27, 2024
b2abffb
make test
ahnaf-tahmid-chowdhury Nov 30, 2024
3ede515
Exclude src/openmc
ahnaf-tahmid-chowdhury Dec 2, 2024
1806f76
move openmc to python dir
ahnaf-tahmid-chowdhury Dec 3, 2024
d80e7df
python/openmc -> openmc
ahnaf-tahmid-chowdhury Dec 12, 2024
c760abf
Merge remote-tracking branch 'upstream/develop' into scikit_build_cor…
ahnaf-tahmid-chowdhury Dec 12, 2024
79e789b
openmc -> python/openmc
ahnaf-tahmid-chowdhury Dec 12, 2024
97eec30
add load the library from the installed module
ahnaf-tahmid-chowdhury Dec 13, 2024
97b26d0
python/openmc -> openmc
ahnaf-tahmid-chowdhury Dec 13, 2024
aeef2d6
python/openmc -> openmc
ahnaf-tahmid-chowdhury Dec 13, 2024
b0995b8
add fallback
ahnaf-tahmid-chowdhury Dec 13, 2024
e4878ae
rm openmc
ahnaf-tahmid-chowdhury Dec 13, 2024
d1a06fe
Add OPENMC_CORE_BASE_PATH
ahnaf-tahmid-chowdhury Dec 13, 2024
024855a
remove extra check
ahnaf-tahmid-chowdhury Dec 13, 2024
cc1ccfc
run tests on temp dir
ahnaf-tahmid-chowdhury Dec 16, 2024
98698bd
mv openmc python/openmc
ahnaf-tahmid-chowdhury Dec 17, 2024
3317476
rename openmc
ahnaf-tahmid-chowdhury Dec 18, 2024
34a6396
Merge branch 'develop' into scikit_build_core_wheel
jon-proximafusion Jan 9, 2025
e7a8165
fix merge
ahnaf-tahmid-chowdhury Jan 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jobs:
run: |
echo "OPENMC_CROSS_SECTIONS=$HOME/nndc_hdf5/cross_sections.xml" >> $GITHUB_ENV
echo "OPENMC_ENDF_DATA=$HOME/endf-b-vii.1" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV

- name: Apt dependencies
shell: bash
Expand Down
111 changes: 111 additions & 0 deletions .github/workflows/docker-publish-manylinux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Build & Publish Manylinux Images

on:
# allows us to run workflows manually
workflow_dispatch:
push:
paths:
- "tools/ci/manylinux.dockerfile"
- ".github/workflows/docker-publish-manylinux.yml"

jobs:
build-dependency-and-test-img:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
manylinux_image: [
manylinux_2_28_x86_64
]
compiler: [
gcc,
openmpi
]

name: Installing Dependencies, Building OpenMC and running tests
steps:
- name: default environment
run: |
echo "tag-latest-on-default=false" >> "$GITHUB_ENV"

- name: condition on trigger parameters
if: ${{ github.repository_owner == 'openmc-dev' && github.ref == 'refs/heads/develop' }}
run: |
echo "tag-latest-on-default=true" >> "$GITHUB_ENV"

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout repository
uses: actions/checkout@v3

- name: Configure docker image tag
run: |
image_base_tag=ghcr.io/${{ github.repository_owner }}/
image_base_tag+=openmc-${{ matrix.manylinux_image }}
image_base_tag+=-${{ matrix.compiler}}
echo "image_base_tag=${image_base_tag}" >> "$GITHUB_ENV"

- name: Installing Dependencies in Docker image
uses: firehed/[email protected]
with:
repository: ${{ env.image_base_tag }}
stages: base, dependencies, python-dependencies
server-stage: openmc
quiet: false
parallel: true
tag-latest-on-default: ${{ env.tag-latest-on-default }}
dockerfile: tools/ci/manylinux.dockerfile
build-args: >
MANYLINUX_IMAGE=${{ matrix.manylinux_image }},
COMPILER=${{ matrix.compiler }}
push_stable_ci_img:
needs: [build-dependency-and-test-img]
runs-on: ubuntu-latest

strategy:
matrix:
manylinux_image: [
manylinux_2_28_x86_64
]
compiler: [
gcc,
openmpi
]

name: Pushing final images
steps:
- name: Log in to the Container registry
if: ${{ github.repository_owner == 'openmc-dev' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Configure docker image tag
if: ${{ github.repository_owner == 'openmc-dev' }}
run: |
image_base_tag=ghcr.io/${{ github.repository_owner }}/
image_base_tag+=openmc-${{ matrix.manylinux_image }}
image_base_tag+=-${{ matrix.compiler}}
echo "image_base_tag=${image_base_tag}" >> "$GITHUB_ENV"

- name: Push Image as latest img
if: ${{ github.repository_owner == 'openmc-dev' && github.ref == 'refs/heads/develop' }}
uses: akhilerm/[email protected]
with:
src: ${{ env.image_base_tag }}/openmc:latest
dst: ${{ env.image_base_tag }}:latest

- name: Push Image as latest img
if: ${{ github.repository_owner == 'openmc-dev' && github.ref == 'refs/heads/develop' }}
uses: akhilerm/[email protected]
with:
src: ${{ env.image_base_tag }}:latest
dst: ${{ env.image_base_tag }}:stable
57 changes: 57 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish wheels to PyPI

on:
# allows running workflows manually
workflow_dispatch:

release:
types: [published]

jobs:
main:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: manylinux_x86_64
- os: macos-13
arch: macosx_x86_64
- os: macos-14
arch: macosx_arm64

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: "cp*-${{ matrix.arch }}"
CIBW_ARCHS_LINUX: "x86_64"
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/${{ github.repository_owner }}/openmc-manylinux_2_28_x86_64-gcc/python-dependencies:latest
CIBW_ARCHS_MACOS: "native"
CIBW_BEFORE_BUILD_MACOS: |
brew install llvm cmake xtensor hdf5 python libomp libpng
CIBW_ENVIRONMENT_MACOS: >
MACOSX_DEPLOYMENT_TARGET=${{ matrix.os == 'macos-14' && '14.0' || '13.0' }}
DYLD_LIBRARY_PATH=/usr/local/opt/gcc/lib/gcc/current/:$DYLD_LIBRARY_PATH
CXX=$(brew --prefix llvm)/bin/clang++
HDF5_ROOT=$(brew --prefix hdf5)
CIBW_BUILD_FRONTEND: "build"
with:
package-dir: openmc
output-dir: wheelhouse
config-file: "{package}/pyproject.toml"

- name: Publish package to PyPI
if: success()
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload wheelhouse/*.whl
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ results_test.dat
# Test
.pytest_cache/

# HDF5 files
*.h5

# Build files
src/CMakeCache.txt
src/CMakeFiles/
Expand Down
7 changes: 6 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
version: 2

build:
os: "ubuntu-20.04"
os: "ubuntu-22.04"
tools:
python: "3.10"
apt_packages:
- g++
- cmake
- libhdf5-dev
- libpng-dev

sphinx:
configuration: docs/source/conf.py
Expand Down
118 changes: 92 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(openmc C CXX)

# Set version numbers
Expand Down Expand Up @@ -36,6 +36,17 @@ option(OPENMC_USE_MCPL "Enable MCPL"
option(OPENMC_USE_NCRYSTAL "Enable support for NCrystal scattering" OFF)
option(OPENMC_USE_UWUW "Enable UWUW" OFF)

message(STATUS "OPENMC_USE_OPENMP ${OPENMC_USE_OPENMP}")
message(STATUS "OPENMC_BUILD_TESTS ${OPENMC_BUILD_TESTS}")
message(STATUS "OPENMC_ENABLE_PROFILE ${OPENMC_ENABLE_PROFILE}")
message(STATUS "OPENMC_ENABLE_COVERAGE ${OPENMC_ENABLE_COVERAGE}")
message(STATUS "OPENMC_USE_DAGMC ${OPENMC_USE_DAGMC}")
message(STATUS "OPENMC_USE_LIBMESH ${OPENMC_USE_LIBMESH}")
message(STATUS "OPENMC_USE_MPI ${OPENMC_USE_MPI}")
message(STATUS "OPENMC_USE_MCPL ${OPENMC_USE_MCPL}")
message(STATUS "OPENMC_USE_NCRYSTAL ${OPENMC_USE_NCRYSTAL}")
message(STATUS "OPENMC_USE_UWUW ${OPENMC_USE_UWUW}")

# Warnings for deprecated options
shimwell marked this conversation as resolved.
Show resolved Hide resolved
foreach(OLD_OPT IN ITEMS "openmp" "profile" "coverage" "dagmc" "libmesh")
if(DEFINED ${OLD_OPT})
Expand Down Expand Up @@ -67,6 +78,9 @@ foreach(OLD_BLD in ITEMS "debug" "optimize")
endif()
endforeach()

# Include the GenerateScript.cmake file
include(cmake/GenerateScript.cmake)

#===============================================================================
# Set a default build configuration if not explicitly specified
#===============================================================================
Expand Down Expand Up @@ -310,23 +324,48 @@ include(GNUInstallDirs)
# installed one in CMAKE_INSTALL_PREFIX. Ref:
# https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling

# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)

# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
if(SKBUILD)
# By default, scikit-build will install everything to ${SKBUILD_PLATLIB_DIR}/openmc
# Install include and bin directories to ${SKBUILD_PLATLIB_DIR}/openmc/SKBUILD_SUBDIR
set(SKBUILD_SUBDIR core/)
set(CMAKE_INSTALL_BINDIR ${SKBUILD_SUBDIR}${CMAKE_INSTALL_BINDIR})
set(CMAKE_INSTALL_INCLUDEDIR ${SKBUILD_SUBDIR}${CMAKE_INSTALL_INCLUDEDIR})
set(CMAKE_INSTALL_DATADIR ${SKBUILD_DATA_DIR}/${CMAKE_INSTALL_DATADIR})
set(CMAKE_INSTALL_DOCDIR ${SKBUILD_DATA_DIR}/${CMAKE_INSTALL_DOCDIR})
set(CMAKE_INSTALL_INFODIR ${SKBUILD_DATA_DIR}/${CMAKE_INSTALL_INFODIR})
set(CMAKE_INSTALL_MANDIR ${SKBUILD_DATA_DIR}/${CMAKE_INSTALL_MANDIR})
set(CMAKE_INSTALL_LOCALEDIR ${SKBUILD_DATA_DIR}/${CMAKE_INSTALL_LOCALEDIR})
set(CMAKE_INSTALL_LOCALSTATEDIR ${SKBUILD_DATA_DIR}/${CMAKE_INSTALL_LOCALSTATEDIR})
set(CMAKE_INSTALL_RUNSTATEDIR ${SKBUILD_DATA_DIR}/${CMAKE_INSTALL_RUNSTATEDIR})

# Set RPATH
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
set(OPENMC_LIBRARY_RPATH "@loader_path")
set(OPENMC_BINARY_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}")
elseif(UNIX)
set(OPENMC_LIBRARY_RPATH "$ORIGIN")
set(OPENMC_BINARY_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
endif()
else()
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

# the RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
# the RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
endif()
endif()

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#===============================================================================
# libopenmc
#===============================================================================
Expand Down Expand Up @@ -465,14 +504,22 @@ endif()

target_include_directories(libopenmc
PUBLIC
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
${HDF5_INCLUDE_DIRS}
)

# Set compile flags
target_compile_options(libopenmc PRIVATE ${cxxflags})

if(OPENMC_LIBRARY_RPATH)
set_target_properties(
libopenmc
PROPERTIES
INSTALL_RPATH "${OPENMC_LIBRARY_RPATH}"
)
endif()

# Add include directory for configured version file
target_include_directories(libopenmc
PUBLIC $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
Expand Down Expand Up @@ -581,15 +628,16 @@ target_compile_features(openmc PUBLIC cxx_std_17)
target_compile_features(libopenmc PUBLIC cxx_std_17)
set_target_properties(openmc libopenmc PROPERTIES CXX_EXTENSIONS OFF)

#===============================================================================
# Python package
#===============================================================================
generate_and_install_python_script(openmc)

add_custom_command(TARGET libopenmc POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:libopenmc>
${CMAKE_CURRENT_SOURCE_DIR}/openmc/lib/$<TARGET_FILE_NAME:libopenmc>
COMMENT "Copying libopenmc to Python module directory")
# Set rpath for openmc executable
if(OPENMC_BINARY_RPATH)
set_target_properties(
openmc
PROPERTIES
INSTALL_RPATH "${OPENMC_BINARY_RPATH}"
)
endif()

#===============================================================================
# Install executable, scripts, manpage, license
Expand All @@ -598,17 +646,35 @@ add_custom_command(TARGET libopenmc POST_BUILD
configure_file(cmake/OpenMCConfig.cmake.in "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake" @ONLY)
configure_file(cmake/OpenMCConfigVersion.cmake.in "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake" @ONLY)

set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/OpenMC)
if(SKBUILD)
set(INSTALL_CONFIGDIR ${SKBUILD_DATA_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/OpenMC)
else()
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/OpenMC)
endif()

install(TARGETS openmc libopenmc
EXPORT openmc-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${SKBUILD_SUBDIR}${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${SKBUILD_SUBDIR}${CMAKE_INSTALL_LIBDIR}
)

set(INSTALL_TARGETDIR ${SKBUILD_SUBDIR}${CMAKE_INSTALL_LIBDIR}/cmake/OpenMC)
install(EXPORT openmc-targets
FILE OpenMCTargets.cmake
NAMESPACE OpenMC::
DESTINATION ${INSTALL_CONFIGDIR})
DESTINATION ${INSTALL_TARGETDIR}
)

# Collect scripts
file(GLOB SCRIPTS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/*")

# Install scripts to bin directory
if(SKBUILD)
install(PROGRAMS ${SCRIPTS} DESTINATION ${SKBUILD_SCRIPTS_DIR})
else()
install(PROGRAMS ${SCRIPTS} DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

install(FILES
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake"
Expand Down
Loading
Loading