Skip to content

Commit

Permalink
Merge pull request #10 from USEPA/triplet_build
Browse files Browse the repository at this point in the history
Triplet build
  • Loading branch information
cbuahin authored Nov 27, 2023
2 parents e2a296c + 8230e1f commit b053ac0
Show file tree
Hide file tree
Showing 63 changed files with 489 additions and 1,251 deletions.
86 changes: 58 additions & 28 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,80 @@
name: Build and Test MSX
on:
push:
branches: [ master, triplet ]
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
name: Build, Unit Testing, and Regression Testing
environment: testing
env:
BuildVersion: 2.0.0
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
include:
- os: windows-latest
cmake_generator: -G "Visual Studio 17 2022" -A "x64"
continue-on-error: false
alias: win64
- os: ubuntu-latest
cmake_generator: -G "Unix Makefiles"
continue-on-error: false
alias: Linux
- os: macos-latest
cmake_generator: -G "Xcode"
continue-on-error: false
alias: Darwin
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.continue-on-error }}
environment: testing
# defaults:
# run:
# shell: ${{ matrix.defaults.run.shell }}
# working-directory: ${{ matrix.defaults.run.working-directory }}


steps:
- uses: actions/checkout@v3
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: true

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
- name: Build OpenMP Binaries for MacOS via Homebrew
if: ${{ matrix.os == 'macos-latest' }}
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
brew reinstall --build-from-source --formula ./shell/apple/libomp.rb
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
- name: Build
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only
# required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
run: |
cmake -B build ${{ matrix.cmake_generator }} .
cmake --build build --config Release --target package
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
- name: Run Example on Windows
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only
# required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
if: ${{ matrix.os == 'windows-latest' }}
run: |
./build/_CPack_Packages/${{ matrix.alias }}/ZIP/EPANETMSX-${{ env.BuildVersion }}-${{ matrix.alias }}/bin/runepanetmsx ./Examples/example.inp ./Examples/example.msx ./Examples/example.rpt ./Examples/example.out
- name: Run Example on Linux and MacOS
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only
# required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
if: ${{ matrix.os != 'windows-latest' }}
run: |
chmod +x ./build/_CPack_Packages/${{ matrix.alias }}/ZIP/EPANETMSX-${{ env.BuildVersion }}-${{ matrix.alias }}/bin/runepanet
chmod +x ./build/_CPack_Packages/${{ matrix.alias }}/ZIP/EPANETMSX-${{ env.BuildVersion }}-${{ matrix.alias }}/bin/runepanetmsx
./build/_CPack_Packages/${{ matrix.alias }}/ZIP/EPANETMSX-${{ env.BuildVersion }}-${{ matrix.alias }}/bin/runepanetmsx ./Examples/example.inp ./Examples/example.msx ./Examples/example.rpt ./Examples/example.out
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
- name: Upload artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: build-test-artifacts
path: |
build/*.zip
build/*.tar.gz
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "EPANET2.2"]
path = EPANET2.2
url = https://github.com/USEPA/EPANET2.2.git
branch = master
Binary file removed Bin/epanet2.dll
Binary file not shown.
Binary file removed Bin/epanetmsx.dll
Binary file not shown.
Binary file removed Bin/runepanetmsx.exe
Binary file not shown.
7 changes: 0 additions & 7 deletions Bin/runvc.bat

This file was deleted.

Binary file removed Bin/vcomp140.dll
Binary file not shown.
89 changes: 51 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,51 +1,64 @@
#
# CMakeLists.txt - CMake configuration file for EPANETMSX 2.0
#
# Created: Nov 13, 2023
# Modified: Nov 13, 2023
#
# Author: Caleb Buahin
# US EPA ORD/CESER
#


cmake_minimum_required(VERSION 3.9)

project(EPANETMSX LANGUAGES C)
if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
message(FATAL_ERROR "In-source builds are disabled.")
endif()

project(
"EPANETMSX"
VERSION 2.0.0
DESCRIPTION "Multi-species extension for EPANET"
LANGUAGES C CXX
)

# Append local dir to module search path
#list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# Add building the command line executable from the run directory
add_subdirectory(run)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

# Sets default install prefix when cmakecache is initialized for first time
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "..." FORCE)
endif()


# Sets the output directory for executables and libraries.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(TOOL_DIST "bin")
set(INCLUDE_DIST "include")
set(LIBRARY_DIST "lib")
set(CONFIG_DIST "cmake")

# Sets the position independent code property for all targets
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)

IF (APPLE)
set(INSTALL_NAME_DIR @executable_path/../lib)
set(CMAKE_MACOSX_RPATH 1)
ENDIF (APPLE)

IF (MSVC)
set(CMAKE_C_FLAGS_RELEASE "/GL")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -MT)
ENDIF (MSVC)

# configure file groups
file(GLOB MSX_SOURCES RELATIVE ${PROJECT_SOURCE_DIR} Src/*.c Src/*.h Include/epanet2.h Include/epanetmsx.h)
list(REMOVE_ITEM MSX_SOURCES Src/msxmain.c)

# the shared library
find_package(OpenMP REQUIRED)
IF(MSVC AND "${CMAKE_VS_PLATFORM_NAME}" MATCHES "(Win32)")
message(" ************************************")
message(" Configuring with msx.def mapping")
message(" ************************************")
find_library(EPANET_LIB epanet2 NAMES epanet2 PATHS ${PROJECT_SOURCE_DIR}/include/x86 NO_DEFAULT_PATH)
add_library(epanetmsx SHARED ${MSX_SOURCES} ${PROJECT_SOURCE_DIR}/include/epanetmsx.def)
set_source_files_properties(${PROJECT_SOURCE_DIR}/include/msx.def PROPERTIES_HEADER_FILE_ONLY TRUE)
target_link_libraries(epanetmsx ${EPANET_LIB} OpenMP::OpenMP_C)
ELSE(TRUE)
find_library(EPANET_LIB epanet2 NAMES epanet2 PATHS ${PROJECT_SOURCE_DIR}/include/x64 NO_DEFAULT_PATH)
add_library(epanetmsx SHARED ${MSX_SOURCES})
target_link_libraries(epanetmsx ${EPANET_LIB} OpenMP::OpenMP_C)
ENDIF(MSVC AND "${CMAKE_VS_PLATFORM_NAME}" MATCHES "(Win32)")

target_include_directories(epanetmsx PUBLIC ${PROJECT_SOURCE_DIR}/include)

# option(BUILD_TESTS "Build component tests (requires Boost)" OFF)
option(BUILD_DEF "Builds library with def file interface" OFF)

# Added option to statically link libraries to address GitHub
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)

add_subdirectory(EPANET2.2/SRC_engines)

add_subdirectory(src/solver)

add_subdirectory(src/run)

set(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)

# Configure CPack driven installer package
set(CPACK_GENERATOR "ZIP;TGZ")
set(CPACK_PACKAGE_VENDOR "US_EPA")
set(CPACK_ARCHIVE_FILE_NAME "epanet-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")

include(CPack)
1 change: 1 addition & 0 deletions EPANET2.2
Submodule EPANET2.2 added at 35040b
Loading

0 comments on commit b053ac0

Please sign in to comment.