Skip to content

Commit

Permalink
Merge branch 'mfront-build' into 'master'
Browse files Browse the repository at this point in the history
[CMake,MFront] Build behaviours lib externally via mfront executable.

See merge request ogs/ogs!4680
  • Loading branch information
endJunction committed Jul 20, 2023
2 parents 56ca45e + d7be25e commit 67bbb0f
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 23 deletions.
88 changes: 66 additions & 22 deletions MaterialLib/SolidModels/MFront/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,21 @@ set(SOURCES

ogs_add_library(MaterialLib_SolidModels_MFront ${SOURCES})

mfront_behaviours_check_library(
OgsMFrontBehaviour
target_link_libraries(
MaterialLib_SolidModels_MFront PUBLIC BaseLib NumLib MFrontGenericInterface
Boost::boost PRIVATE MathLib MeshLib
ParameterLib
)
target_include_directories(
MaterialLib_SolidModels_MFront PUBLIC ThirdParty/MGIS/include
)
target_compile_definitions(
MaterialLib_SolidModels_MFront PRIVATE OGS_USE_MFRONT
)
install(TARGETS MFrontGenericInterface)

# Setup / build mfront behaviours lib
set(_mfront_behaviours
BDT
DruckerPrager
GuentherSalzer
Expand All @@ -32,23 +45,54 @@ mfront_behaviours_check_library(
ThermoPoroElasticity
)

target_link_libraries(
MaterialLib_SolidModels_MFront PUBLIC BaseLib NumLib MFrontGenericInterface
OgsMFrontBehaviour Boost::boost
PRIVATE MathLib MeshLib ParameterLib
)

# Disable warnings for generated OgsMFrontBehaviour
target_compile_options(
OgsMFrontBehaviour PRIVATE $<$<CXX_COMPILER_ID:Clang,AppleClang,GNU>:-w>
$<$<CXX_COMPILER_ID:MSVC>:/W0>
)

target_include_directories(
MaterialLib_SolidModels_MFront PUBLIC ThirdParty/MGIS/include
)
target_compile_definitions(
MaterialLib_SolidModels_MFront PRIVATE OGS_USE_MFRONT
)

install(TARGETS MFrontGenericInterface OgsMFrontBehaviour)
if(OGS_BUILD_WHEEL)
# Build behaviours lib with mfront executable
foreach(behaviour ${_mfront_behaviours})
list(APPEND _mfront_behaviour_files
"${CMAKE_CURRENT_SOURCE_DIR}/${behaviour}.mfront"
)
endforeach()
set(_generated_mfront_lib
${CMAKE_CURRENT_BINARY_DIR}/src/libBehaviour${CMAKE_SHARED_LIBRARY_SUFFIX}
)
set(_copied_mfront_lib
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libOgsMFrontBehaviour${CMAKE_SHARED_LIBRARY_SUFFIX}
)
add_custom_command(
OUTPUT ${_copied_mfront_lib}
COMMAND
${CMAKE_COMMAND} -E env PATH="${TFELHOME}/bin:$ENV{PATH}" mfront
--interface=generic --silent-build=true # suppresses output
# (compiler warnings), does
# not work?
--obuild ${_mfront_behaviour_files} # TODO: check for debug?
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_generated_mfront_lib}
${_copied_mfront_lib}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND_EXPAND_LISTS
DEPENDS ${_mfront_behaviour_files}
)
add_custom_target(
InternalOgsMFrontBehaviour ALL DEPENDS ${_copied_mfront_lib}
)
add_library(OgsMFrontBehaviour SHARED IMPORTED)
set_target_properties(
OgsMFrontBehaviour PROPERTIES IMPORTED_LOCATION ${_copied_mfront_lib}
IMPORTED_NO_SONAME TRUE
)
install(FILES ${_copied_mfront_lib} TYPE LIB)
else()
# Build behaviours lib as part of ogs' build process
mfront_behaviours_check_library(OgsMFrontBehaviour ${_mfront_behaviours})
# ------------------------------ ATTENTION --------------------------------
# Disable warnings for generated OgsMFrontBehaviour. To enable warnings
# comment out the following target_compile_options()-statement:
target_compile_options(
OgsMFrontBehaviour PRIVATE $<$<CXX_COMPILER_ID:Clang,AppleClang,GNU>:-w>
$<$<CXX_COMPILER_ID:MSVC>:/W0>
)
target_link_libraries(
MaterialLib_SolidModels_MFront PUBLIC OgsMFrontBehaviour
)
install(TARGETS OgsMFrontBehaviour)
endif()
16 changes: 16 additions & 0 deletions scripts/ci/jobs/build-wheels.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
stages:
- build
- release
- test

workflow:
rules:
Expand All @@ -23,6 +24,7 @@ workflow:

include:
- local: "scripts/ci/extends/*.yml"
- local: "scripts/ci/jobs/jupyter.yml"

.wheels_template: &wheels_template
stage: build
Expand Down Expand Up @@ -74,3 +76,17 @@ publish wheels:
${PYPI_REPO}
${PYPI_AUTH}
wheelhouse/*
test notebooks via wheel:
stage: test
needs: ["build wheels linux"]
rules:
- when: manual
before_script:
- cd Tests/Data
- python3.10 -m venv --upgrade-deps .venv
- source .venv/bin/activate
- pip install -r requirements.txt
- pip install --force-reinstall -r requirements-gmsh-nox.txt
- pip install -r requirements-dev.txt
- pip install ${CI_PROJECT_DIR}/wheelhouse/ogs-*-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
3 changes: 2 additions & 1 deletion scripts/ci/jobs/jupyter.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
test notebooks via wheel:
stage: build
tags: [envinf23, shell]
script:
before_script:
- cd Tests/Data
- python -m venv --upgrade-deps .venv
- source .venv/bin/activate
- pip install -r requirements.txt
- pip install --force-reinstall -r requirements-gmsh-nox.txt
- pip install -r requirements-dev.txt
- pip install -r requirements-ogs.txt
script:
# TODO:
# - better timeout
# - run in parallel
Expand Down

0 comments on commit 67bbb0f

Please sign in to comment.