Skip to content

Commit 2adbba1

Browse files
authored
Merge pull request #122 from pyswmm/dev_arm64_omp
2 parents 3fb9b17 + 691e9e9 commit 2adbba1

4 files changed

Lines changed: 82 additions & 14 deletions

File tree

.github/workflows/build_wheel.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ name: Build Wheels
33
# Cross compile wheels only on main branch and tags
44
on:
55
pull_request:
6-
branches:
7-
- master
6+
branches:
7+
- master
88
push:
9-
branches:
9+
branches:
1010
- master
11-
tags:
11+
tags:
1212
- v*
1313
workflow_dispatch:
1414

@@ -44,7 +44,7 @@ jobs:
4444
build_wheels:
4545
runs-on: ${{ matrix.os }}
4646
strategy:
47-
fail-fast: true
47+
fail-fast: false
4848
matrix:
4949
os: [ubuntu-latest, windows-2022, macos-12]
5050
pyver: [cp38, cp39, cp310, cp311]
@@ -59,22 +59,23 @@ jobs:
5959
uses: pypa/cibuildwheel@v2.15.0
6060
with:
6161
package-dir: ./swmm-toolkit
62-
env:
62+
env:
6363
CIBW_TEST_COMMAND: "pytest {package}/tests"
6464
CIBW_BEFORE_TEST: pip install -r {package}/test-requirements.txt
6565
# mac needs ninja to build
6666
CIBW_BEFORE_BUILD_MACOS: brew install ninja
6767
# configure cibuildwheel to build native archs ('auto'), and some emulated ones
6868
CIBW_ARCHS_LINUX: x86_64
69-
CIBW_ARCHS_WINDOWS: AMD64
70-
CIBW_ARCHS_MACOS: x86_64
69+
CIBW_ARCHS_WINDOWS: AMD64
70+
CIBW_ARCHS_MACOS: x86_64
7171
# only build current supported python: https://devguide.python.org/versions/
7272
# don't build pypy or musllinux to save build time. TODO: find a good way to support those archs
7373
CIBW_BUILD: ${{matrix.pyver}}-*
7474
CIBW_SKIP: cp36-* cp37-* cp312-* pp* *-musllinux*
7575
# Will avoid testing on emulated architectures
7676
# Skip trying to test arm64 builds on Intel Macs
7777
CIBW_TEST_SKIP: "*-*linux_{aarch64,ppc64le,s390x} *-macosx_arm64 *-macosx_universal2:arm64"
78+
CIBW_BUILD_VERBOSITY: 1
7879

7980
- uses: actions/upload-artifact@v3
8081
with:
@@ -83,7 +84,7 @@ jobs:
8384
build_cross_wheels:
8485
runs-on: ${{ matrix.os }}
8586
strategy:
86-
fail-fast: true
87+
fail-fast: false
8788
matrix:
8889
os: [ubuntu-latest,macos-12]
8990
pyver: [cp38, cp39, cp310, cp311]
@@ -114,6 +115,7 @@ jobs:
114115
# don't build pypy or musllinux to save build time. TODO: find a good way to support those archs
115116
CIBW_BUILD: ${{matrix.pyver}}-*
116117
CIBW_SKIP: cp36-* cp37-* cp312-* pp* *-musllinux*
118+
CIBW_BUILD_VERBOSITY: 1
117119

118120
- uses: actions/upload-artifact@v3
119121
with:

swmm-toolkit/CMakeLists.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,16 @@ cmake_policy(SET CMP0078 NEW)
3636
cmake_policy(SET CMP0086 NEW)
3737
include(${SWIG_USE_FILE})
3838

39-
find_package(OpenMP
40-
OPTIONAL_COMPONENTS
41-
C
42-
)
39+
# If wheel build on Apple fetch and build OpenMP Library
40+
if (APPLE)
41+
include(./extern/openmp.cmake)
42+
else()
43+
find_package(OpenMP
44+
REQUIRED
45+
OPTIONAL_COMPONENTS
46+
C
47+
)
48+
endif()
4349

4450
# Add project subdirectories
4551
add_subdirectory(swmm-solver)

swmm-toolkit/extern/openmp.cmake

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#
2+
# CMakeLists.txt - CMake configuration file for OpenMP Library on Darwin
3+
#
4+
# Created: Mar 17, 2021
5+
# Updated: May 19, 2021
6+
#
7+
# Author: Michael E. Tryby
8+
# US EPA ORD/CESER
9+
#
10+
# Note:
11+
# Need to build libomp for binary compatibility with Python.
12+
#
13+
# OpenMP library build fails for Xcode generator. Use Ninja or Unix Makefiles
14+
# instead.
15+
#
16+
17+
################################################################################
18+
##################### CMAKELISTS FOR OPENMP LIBRARY ######################
19+
################################################################################
20+
21+
include(FetchContent)
22+
23+
24+
FetchContent_Declare(OpenMP
25+
URL
26+
https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.1/openmp-12.0.1.src.tar.xz
27+
URL_HASH
28+
SHA256=60fe79440eaa9ebf583a6ea7f81501310388c02754dbe7dc210776014d06b091
29+
)
30+
31+
set(OPENMP_STANDALONE_BUILD TRUE)
32+
set(LIBOMP_INSTALL_ALIASES OFF)
33+
34+
FetchContent_MakeAvailable(OpenMP)
35+
set(OpenMP_AVAILABLE TRUE)
36+
37+
38+
target_link_directories(omp
39+
PUBLIC
40+
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/_deps/openmp-build/runtime/src>
41+
$<INSTALL_INTERFACE:${LIBRARY_DIST}>
42+
)
43+
44+
install(TARGETS omp
45+
LIBRARY
46+
DESTINATION
47+
"${LIBRARY_DIST}"
48+
)
49+
50+
if(CMAKE_C_COMPILER_ID MATCHES "Clang\$")
51+
set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp -I${CMAKE_BINARY_DIR}/_deps/openmp-build/runtime/src")
52+
set(OpenMP_C_LIB_NAMES "omp")
53+
set(OpenMP_omp_LIBRARY "${CMAKE_BINARY_DIR}/_deps/openmp-build/runtime/src/libomp.dylib")
54+
endif()
55+
56+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang\$")
57+
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I${CMAKE_BINARY_DIR}/_deps/openmp-build/runtime/src")
58+
set(OpenMP_CXX_LIB_NAMES "omp")
59+
set(OpenMP_omp_LIBRARY "${CMAKE_BINARY_DIR}/_deps/openmp-build/runtime/src/libomp.dylib")
60+
endif()

swmm-toolkit/swmm-solver

0 commit comments

Comments
 (0)