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:
variables:
# Build config
BUILD_TYPE: Release
BUILD_PROCESSES: "" # Empty string: builds all processes
BUILD_PROCESSES: "ON" # or OFF or ;-separated list of processes
BUILD_TESTS: "true"
BUILD_CTEST: "true"
CPU_TARGET: ivybridge # envinf2 has oldest cpu
CPU_TARGET: ivybridge # envinf1 has oldest cpu
workflow:
rules:
......
......@@ -8,19 +8,14 @@ ogs_add_library(ApplicationsLib ${LIB_SOURCES})
target_link_libraries(
ApplicationsLib
PUBLIC BaseLib GeoLib NumLib
PRIVATE CMakeInfoLib
MathLib
MeshLib
MeshGeoToolsLib
PRIVATE CMakeInfoLib MathLib MeshLib MeshGeoToolsLib
$<$<BOOL:${OGS_USE_PYTHON}>:pybind11::pybind11>
$<$<BOOL:${OGS_USE_PETSC}>:petsc>
)
if(OGS_BUILD_CLI OR OGS_BUILD_UTILS OR OGS_BUILD_TESTING)
target_link_libraries(
ApplicationsLib
PUBLIC Processes
PRIVATE ParameterLib ProcessLib
ApplicationsLib PUBLIC Processes PRIVATE ParameterLib ProcessLib
)
elseif(OGS_BUILD_GUI)
target_link_libraries(ApplicationsLib PRIVATE nlohmann_json::nlohmann_json)
......@@ -36,12 +31,10 @@ target_compile_definitions(
)
# Set cpp definitions if the cmake option is enabled for the given process.
foreach(process ${_processes_list})
if(OGS_BUILD_PROCESS_${process})
string(TOUPPER "OGS_BUILD_PROCESS_${process}" EnableProcess)
set_property(
TARGET ApplicationsLib APPEND PROPERTY COMPILE_DEFINITIONS
${EnableProcess}
)
endif()
foreach(process ${_enabled_processes})
string(TOUPPER "OGS_BUILD_PROCESS_${process}" EnableProcess)
set_property(
TARGET ApplicationsLib APPEND PROPERTY COMPILE_DEFINITIONS
${EnableProcess}
)
endforeach()
# Collect the process libraries in interface library
add_library(Processes INTERFACE)
foreach(process ${_processes_list})
if(OGS_BUILD_PROCESS_${process})
add_subdirectory(${process})
target_link_libraries(Processes INTERFACE ${process})
set_target_properties(
${process} PROPERTIES JOB_POOL_COMPILE heavy_tasks
)
endif()
foreach(process ${_enabled_processes})
add_subdirectory(${process})
target_link_libraries(Processes INTERFACE ${process})
set_target_properties(${process} PROPERTIES JOB_POOL_COMPILE heavy_tasks)
endforeach()
get_source_files(SOURCES)
......
......@@ -28,44 +28,47 @@ set(_processes_list
TwoPhaseFlowWithPrho
)
# Add a cmake option for each process.
foreach(process ${_processes_list})
option(OGS_BUILD_PROCESS_${process} "Build the ${process} process." ON)
endforeach()
set(OGS_BUILD_PROCESSES ""
set(OGS_BUILD_PROCESSES ON
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)
set(OGS_BUILD_PROCESSES OFF "" CACHE STRING "" FORCE)
message(
STATUS
"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"
" too with -DOGS_BUILD_PROCESSES=\"\"!"
" too with -DOGS_BUILD_PROCESSES=ON!"
)
endif()
if(NOT "${OGS_BUILD_PROCESSES}" STREQUAL "")
if(${OGS_BUILD_PROCESSES})
foreach(process ${OGS_BUILD_PROCESSES})
if(NOT "${process}" IN_LIST _processes_list)
message(
FATAL_ERROR
"${process} given in OGS_BUILD_PROCESSES is "
"not a valid process name! Valid names are ${_processes_list}"
)
endif()
endforeach()
message(STATUS "Enabled processes:")
if("${OGS_BUILD_PROCESSES}" STREQUAL "ON" OR "${OGS_BUILD_PROCESSES}" STREQUAL
"OFF"
)
if(OGS_BUILD_PROCESSES)
message(STATUS "All processes enabled.")
set(_enabled_processes ${_processes_list})
else()
message(STATUS "All processes disabled.")
unset(_enabled_processes)
endif()
foreach(process ${_processes_list})
if("${process}" IN_LIST OGS_BUILD_PROCESSES)
set(OGS_BUILD_PROCESS_${process} ON CACHE BOOL "" FORCE)
message(STATUS " ${process}")
else()
set(OGS_BUILD_PROCESS_${process} OFF CACHE BOOL "" FORCE)
else()
foreach(process ${OGS_BUILD_PROCESSES})
if(NOT "${process}" IN_LIST _processes_list)
message(
FATAL_ERROR
"${process} given in OGS_BUILD_PROCESSES is "
"not a valid process name! Valid names are ${_processes_list}"
)
endif()
endforeach()
set(_enabled_processes ${OGS_BUILD_PROCESSES})
message(STATUS "Enabled processes: ${OGS_BUILD_PROCESSES}")
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