Skip to content

Commit

Permalink
Merge pull request #339 from OpenWaterAnalytics/hotfix-interim
Browse files Browse the repository at this point in the history
Making OpenMP optional on Apple
  • Loading branch information
michaeltryby authored Jun 7, 2021
2 parents a5a137d + 740724c commit 3f79b60
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 41 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-2016, ubuntu-16.04, macos-latest]
os: [windows-2016, ubuntu-16.04, macos-10.15]
requirements: [requirements-swmm.txt]
include:
- os: windows-2016
sys_pkgs: choco install boost-msvc-14.1
generator: Visual Studio 15 2017 Win64
experimental: true
script_extension: cmd
Expand All @@ -40,7 +41,9 @@ jobs:
run:
shell: cmd
working-directory: ./ci-tools/windows

- os: ubuntu-16.04
sys_pkgs: sudo apt install libboost-dev libboost-all-dev
generator: "Unix Makefiles"
experimental: true
script_extension: sh
Expand All @@ -51,7 +54,9 @@ jobs:
run:
shell: bash
working-directory: ./ci-tools/linux
- os: macos-latest

- os: macos-10.15
sys_pkgs: brew install libomp boost
generator: Xcode
experimental: true
ci_tools_path: ci-tools/darwin
Expand Down Expand Up @@ -81,8 +86,13 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Clone ci-tools repo
uses: actions/checkout@v2
with:
submodules: recursive
repository: OpenWaterAnalytics/ci-tools
ref: master
path: ci-tools

- name: Setup python
uses: actions/setup-python@v2
Expand All @@ -94,11 +104,8 @@ jobs:
python -m pip install --upgrade pip
python -m pip install -r ${{ matrix.requirements }}
- name: Install Darwin requirements
if: ${{ contains(matrix.os, 'macos') }}
run: |
brew install libomp
brew install boost
- name: Install required system packages
run: ${{ matrix.sys_pkgs }}

- name: Build and unit test
run: |
Expand All @@ -110,7 +117,7 @@ jobs:
- name: Before reg test
run: |
./before-nrtest.${{ matrix.script_extension }}
./before-nrtest.${{ matrix.script_extension }} v1.0.3-dev
- name: Run reg test
run: |
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "ci-tools"]
path = ci-tools
url = https://github.com/OpenWaterAnalytics/ci-tools.git
12 changes: 4 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# CMakeLists.txt - CMake configuration file for swmm-solver
#
# Created: July 11, 2019
# Updated: May 29, 2020
# Updated: May 19, 2021
#
# Author: Michael E. Tryby
# US EPA ORD/CESER
Expand Down Expand Up @@ -61,14 +61,10 @@ if(BUILD_TESTS)
endif()


# Pass var up the project tree
if(APPLE)
set(EXTERN_LIB_PATH ${EXTERN_LIB_PATH} PARENT_SCOPE)
endif()


# Create install rules for vcruntime.dll, msvcp.dll, vcomp.dll etc.
set(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
if(OpenMP_FOUND)
set(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
endif()
include(InstallRequiredSystemLibraries)


Expand Down
1 change: 0 additions & 1 deletion ci-tools
Submodule ci-tools deleted from 98e969
30 changes: 10 additions & 20 deletions src/solver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
# CMakeLists.txt - CMake configuration file for swmm-solver/library
#
# Created: Jul 11, 2019
# Updated: Mar 5, 2020
# Updated: May 19, 2021
#
# Author: Michael E. Tryby
# US EPA ORD/CESER
#


find_package(OpenMP REQUIRED)
find_package(OpenMP
OPTIONAL_COMPONENTS
C
)


# configure file groups
Expand Down Expand Up @@ -55,6 +58,9 @@ target_compile_options(swmm5
"$<$<CONFIG:Release>:/fp:fast>"
"$<$<CONFIG:Release>:/Zi>"
">"
$<$<C_COMPILER_ID:AppleClang>:
$<$<STREQUAL:"${CMAKE_GENERATOR}","Ninja">:-O3>
>
)

target_link_options(swmm5
Expand All @@ -67,7 +73,8 @@ target_link_options(swmm5
target_link_libraries(swmm5
PUBLIC
$<$<NOT:$<BOOL:$<C_COMPILER_ID:MSVC>>>:m>
$<$<BOOL:OpenMP_C_FOUND>:OpenMP::OpenMP_C>
$<$<BOOL:${OpenMP_C_FOUND}>:OpenMP::OpenMP_C>
$<$<BOOL:${OpenMP_AVAILABLE}>:omp>
)

target_include_directories(swmm5
Expand Down Expand Up @@ -102,23 +109,6 @@ install(
)


# TODO: Figure out why this doesn't work for package target
# When building on MacOS relocate libomp to install package
if(APPLE)
get_filename_component(EXTERN_LIB_PATH ${OpenMP_libomp_LIBRARY} REALPATH)

install(
FILES
${EXTERN_LIB_PATH}
DESTINATION
${CMAKE_INSTALL_PREFIX}/extern
)

# Pass the var up the project tree
set(EXTERN_LIB_PATH ${EXTERN_LIB_PATH} PARENT_SCOPE)
endif()


# copy swmm5 to build tree for testing
add_custom_command(TARGET swmm5 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
Expand Down

0 comments on commit 3f79b60

Please sign in to comment.