Skip to content
Snippets Groups Projects
Commit 738086e3 authored by Lars Bilke's avatar Lars Bilke Committed by Dmitri Naumov
Browse files

[cmake] Refactored (and fixed) processes setup logic.

Before:

One could use the CMake variables `OGS_BUILD_PROCESSES` or
`OGS_BUILD_PROCESS_XYZ` but behavior was not consistent when switching
back and forth and using both methods. Also building multiple
processes via `OGS_BUILD_PROCESSES` was broken.

Changed:

- Removed `OGS_BUILD_PROCESS_XYZ` options.
- Use `OGS_BUILD_PROCESSES` with the following values:
  - ON  -> All processes are built.
  - OFF -> Disable all processes.
  - Select a single process by name, e.g. `TH2M`.
  - Give a ;-separated list of processes, e.g. '"THM;TH2M"'
- `OGS_BUILD_PROCESSES` can be set via ccmake or cmake-gui with a
  convenient dropdown, although setting multiple processes can only be
  done via the cli!
parent 9f94c547
No related branches found
No related tags found
No related merge requests found
...@@ -8,10 +8,10 @@ stages: ...@@ -8,10 +8,10 @@ stages:
variables: variables:
# Build config # Build config
BUILD_TYPE: Release BUILD_TYPE: Release
BUILD_PROCESSES: "" # Empty string: builds all processes BUILD_PROCESSES: "ON" # or OFF or ;-separated list of processes
BUILD_TESTS: "true" BUILD_TESTS: "true"
BUILD_CTEST: "true" BUILD_CTEST: "true"
CPU_TARGET: ivybridge # envinf2 has oldest cpu CPU_TARGET: ivybridge # envinf1 has oldest cpu
workflow: workflow:
rules: rules:
......
...@@ -8,19 +8,14 @@ ogs_add_library(ApplicationsLib ${LIB_SOURCES}) ...@@ -8,19 +8,14 @@ ogs_add_library(ApplicationsLib ${LIB_SOURCES})
target_link_libraries( target_link_libraries(
ApplicationsLib ApplicationsLib
PUBLIC BaseLib GeoLib NumLib PUBLIC BaseLib GeoLib NumLib
PRIVATE CMakeInfoLib PRIVATE CMakeInfoLib MathLib MeshLib MeshGeoToolsLib
MathLib
MeshLib
MeshGeoToolsLib
$<$<BOOL:${OGS_USE_PYTHON}>:pybind11::pybind11> $<$<BOOL:${OGS_USE_PYTHON}>:pybind11::pybind11>
$<$<BOOL:${OGS_USE_PETSC}>:petsc> $<$<BOOL:${OGS_USE_PETSC}>:petsc>
) )
if(OGS_BUILD_CLI OR OGS_BUILD_UTILS OR OGS_BUILD_TESTING) if(OGS_BUILD_CLI OR OGS_BUILD_UTILS OR OGS_BUILD_TESTING)
target_link_libraries( target_link_libraries(
ApplicationsLib ApplicationsLib PUBLIC Processes PRIVATE ParameterLib ProcessLib
PUBLIC Processes
PRIVATE ParameterLib ProcessLib
) )
elseif(OGS_BUILD_GUI) elseif(OGS_BUILD_GUI)
target_link_libraries(ApplicationsLib PRIVATE nlohmann_json::nlohmann_json) target_link_libraries(ApplicationsLib PRIVATE nlohmann_json::nlohmann_json)
...@@ -36,12 +31,10 @@ target_compile_definitions( ...@@ -36,12 +31,10 @@ target_compile_definitions(
) )
# Set cpp definitions if the cmake option is enabled for the given process. # Set cpp definitions if the cmake option is enabled for the given process.
foreach(process ${_processes_list}) foreach(process ${_enabled_processes})
if(OGS_BUILD_PROCESS_${process}) string(TOUPPER "OGS_BUILD_PROCESS_${process}" EnableProcess)
string(TOUPPER "OGS_BUILD_PROCESS_${process}" EnableProcess) set_property(
set_property( TARGET ApplicationsLib APPEND PROPERTY COMPILE_DEFINITIONS
TARGET ApplicationsLib APPEND PROPERTY COMPILE_DEFINITIONS ${EnableProcess}
${EnableProcess} )
)
endif()
endforeach() endforeach()
# Collect the process libraries in interface library # Collect the process libraries in interface library
add_library(Processes INTERFACE) add_library(Processes INTERFACE)
foreach(process ${_processes_list}) foreach(process ${_enabled_processes})
if(OGS_BUILD_PROCESS_${process}) add_subdirectory(${process})
add_subdirectory(${process}) target_link_libraries(Processes INTERFACE ${process})
target_link_libraries(Processes INTERFACE ${process}) set_target_properties(${process} PROPERTIES JOB_POOL_COMPILE heavy_tasks)
set_target_properties(
${process} PROPERTIES JOB_POOL_COMPILE heavy_tasks
)
endif()
endforeach() endforeach()
get_source_files(SOURCES) get_source_files(SOURCES)
......
...@@ -28,44 +28,47 @@ set(_processes_list ...@@ -28,44 +28,47 @@ set(_processes_list
TwoPhaseFlowWithPrho TwoPhaseFlowWithPrho
) )
# Add a cmake option for each process. set(OGS_BUILD_PROCESSES ON
foreach(process ${_processes_list})
option(OGS_BUILD_PROCESS_${process} "Build the ${process} process." ON)
endforeach()
set(OGS_BUILD_PROCESSES ""
CACHE STRING "Semicolon-separated list of processes to build" CACHE STRING "Semicolon-separated list of processes to build"
) )
# Drop-down (cmake-gui), cycle-through list (ccmake) for easiere interactive
# selection. For enabling multiple selected processes cmake usage via cli is
# required!
set_property(
CACHE OGS_BUILD_PROCESSES PROPERTY STRINGS ON OFF ${_processes_list}
)
if(NOT OGS_BUILD_CLI) if(NOT OGS_BUILD_CLI)
set(OGS_BUILD_PROCESSES OFF "" CACHE STRING "" FORCE) set(OGS_BUILD_PROCESSES OFF "" CACHE STRING "" FORCE)
message( message(
STATUS STATUS
"ATTENTION: OGS_BUILD_CLI=OFF -> OGS_BUILD_PROCESSES is set to OFF too.\n" "ATTENTION: OGS_BUILD_CLI=OFF -> OGS_BUILD_PROCESSES is set to OFF too.\n"
" If cli is switched on again, remember to switch processes back to on \n" " If cli is switched on again, remember to switch processes back to on \n"
" too with -DOGS_BUILD_PROCESSES=\"\"!" " too with -DOGS_BUILD_PROCESSES=ON!"
) )
endif() endif()
if(NOT "${OGS_BUILD_PROCESSES}" STREQUAL "")
if(${OGS_BUILD_PROCESSES}) if("${OGS_BUILD_PROCESSES}" STREQUAL "ON" OR "${OGS_BUILD_PROCESSES}" STREQUAL
foreach(process ${OGS_BUILD_PROCESSES}) "OFF"
if(NOT "${process}" IN_LIST _processes_list) )
message( if(OGS_BUILD_PROCESSES)
FATAL_ERROR message(STATUS "All processes enabled.")
"${process} given in OGS_BUILD_PROCESSES is " set(_enabled_processes ${_processes_list})
"not a valid process name! Valid names are ${_processes_list}"
)
endif()
endforeach()
message(STATUS "Enabled processes:")
else() else()
message(STATUS "All processes disabled.") message(STATUS "All processes disabled.")
unset(_enabled_processes)
endif() endif()
foreach(process ${_processes_list}) else()
if("${process}" IN_LIST OGS_BUILD_PROCESSES) foreach(process ${OGS_BUILD_PROCESSES})
set(OGS_BUILD_PROCESS_${process} ON CACHE BOOL "" FORCE) if(NOT "${process}" IN_LIST _processes_list)
message(STATUS " ${process}") message(
else() FATAL_ERROR
set(OGS_BUILD_PROCESS_${process} OFF CACHE BOOL "" FORCE) "${process} given in OGS_BUILD_PROCESSES is "
"not a valid process name! Valid names are ${_processes_list}"
)
endif() endif()
endforeach() endforeach()
set(_enabled_processes ${OGS_BUILD_PROCESSES})
message(STATUS "Enabled processes: ${OGS_BUILD_PROCESSES}")
endif() endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment