Skip to content
Snippets Groups Projects
Commit fc438846 authored by Christoph Lehmann's avatar Christoph Lehmann
Browse files

Merge branch 'cmake-processes' into 'master'

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

See merge request ogs/ogs!3983
parents 9f94c547 b06bb1f9
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()
...@@ -214,9 +214,7 @@ add_subdirectory(MeshLib) ...@@ -214,9 +214,7 @@ add_subdirectory(MeshLib)
add_subdirectory(MeshGeoToolsLib) add_subdirectory(MeshGeoToolsLib)
add_subdirectory(NumLib) add_subdirectory(NumLib)
if(OGS_BUILD_PROCESS_ComponentTransport if(_build_chemistry_lib)
OR OGS_BUILD_PROCESS_RichardsComponentTransport
)
add_subdirectory(ChemistryLib) add_subdirectory(ChemistryLib)
endif() endif()
...@@ -274,3 +272,5 @@ include(scripts/cmake/MarkVariablesAdvanced.cmake) ...@@ -274,3 +272,5 @@ include(scripts/cmake/MarkVariablesAdvanced.cmake)
unset(PRE_INSTALL_RUN CACHE) unset(PRE_INSTALL_RUN CACHE)
include(Features) include(Features)
printEnabledProcesses()
# 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)
......
...@@ -47,7 +47,7 @@ if(OGS_BUILD_SWMM) ...@@ -47,7 +47,7 @@ if(OGS_BUILD_SWMM)
append_source_files(TEST_SOURCES FileIO_SWMM) append_source_files(TEST_SOURCES FileIO_SWMM)
endif() endif()
if(OGS_BUILD_PROCESS_ComponentTransport) if(TARGET ComponentTransport)
append_source_files(TEST_SOURCES ProcessLib/ComponentTransport) append_source_files(TEST_SOURCES ProcessLib/ComponentTransport)
endif() endif()
......
...@@ -99,9 +99,7 @@ if(OGS_USE_PYTHON) ...@@ -99,9 +99,7 @@ if(OGS_USE_PYTHON)
) )
endif() endif()
if(OGS_BUILD_PROCESS_ComponentTransport if(_build_chemistry_lib)
OR OGS_BUILD_PROCESS_RichardsComponentTransport
)
CPMAddPackage( CPMAddPackage(
NAME iphreeqc NAME iphreeqc
GITHUB_REPOSITORY ufz/iphreeqc GITHUB_REPOSITORY ufz/iphreeqc
......
...@@ -28,25 +28,33 @@ set(_processes_list ...@@ -28,25 +28,33 @@ set(_processes_list
TwoPhaseFlowWithPrho TwoPhaseFlowWithPrho
) )
# Add a cmake option for each process.
foreach(process ${_processes_list}) foreach(process ${_processes_list})
option(OGS_BUILD_PROCESS_${process} "Build the ${process} process." ON) option(OGS_BUILD_PROCESS_${process} "Build process ${process}" ON)
if(OGS_BUILD_PROCESS_${process})
list(APPEND _enabled_processes ${process})
endif()
endforeach() endforeach()
set(OGS_BUILD_PROCESSES ""
CACHE STRING "Semicolon-separated list of processes to build"
)
if(NOT OGS_BUILD_CLI) if(NOT OGS_BUILD_CLI)
set(OGS_BUILD_PROCESSES OFF "" CACHE STRING "" FORCE) set(OGS_BUILD_PROCESSES OFF)
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(DEFINED CACHE{OGS_BUILD_PROCESSES})
if("${OGS_BUILD_PROCESSES}" STREQUAL "ON" OR "${OGS_BUILD_PROCESSES}"
STREQUAL "OFF"
)
if(OGS_BUILD_PROCESSES)
set(_enabled_processes ${_processes_list})
else()
unset(_enabled_processes)
endif()
else()
foreach(process ${OGS_BUILD_PROCESSES}) foreach(process ${OGS_BUILD_PROCESSES})
if(NOT "${process}" IN_LIST _processes_list) if(NOT "${process}" IN_LIST _processes_list)
message( message(
...@@ -56,16 +64,39 @@ if(NOT "${OGS_BUILD_PROCESSES}" STREQUAL "") ...@@ -56,16 +64,39 @@ if(NOT "${OGS_BUILD_PROCESSES}" STREQUAL "")
) )
endif() endif()
endforeach() endforeach()
message(STATUS "Enabled processes:") set(_enabled_processes ${OGS_BUILD_PROCESSES})
else()
message(STATUS "All processes disabled.")
endif() endif()
foreach(process ${_processes_list}) foreach(process ${_processes_list})
if("${process}" IN_LIST OGS_BUILD_PROCESSES) if(${process} IN_LIST _enabled_processes)
set(OGS_BUILD_PROCESS_${process} ON CACHE BOOL "" FORCE) set(OGS_BUILD_PROCESS_${process} ON CACHE BOOL "" FORCE)
message(STATUS " ${process}")
else() else()
set(OGS_BUILD_PROCESS_${process} OFF CACHE BOOL "" FORCE) set(OGS_BUILD_PROCESS_${process} OFF CACHE BOOL "" FORCE)
endif() endif()
endforeach() endforeach()
unset(OGS_BUILD_PROCESSES CACHE)
endif() endif()
if("RichardsComponentTransport" IN_LIST _enabled_processes
OR "ComponentTransport" IN_LIST _enabled_processes
)
set(_build_chemistry_lib ON)
endif()
# Print summary of enabled processes.
function(printEnabledProcesses)
list(LENGTH _enabled_processes num_enabled_processes)
list(LENGTH _processes_list num_processes_list)
if(${num_enabled_processes} EQUAL 0)
message(STATUS "All processes have been disabled!\n")
return()
endif()
if(${num_processes_list} EQUAL ${num_enabled_processes})
message(STATUS "All processes have been enabled.\n")
return()
endif()
message(STATUS "The following processes have been enabled:\n")
foreach(process ${_enabled_processes})
message(" * ${process}")
endforeach()
message("")
endfunction()
...@@ -17,13 +17,13 @@ Some of these options are enabled by default ("*Defaults* to *ON*") otherwise th ...@@ -17,13 +17,13 @@ Some of these options are enabled by default ("*Defaults* to *ON*") otherwise th
CMake switches to enable / disable parts of OGS. CMake switches to enable / disable parts of OGS.
- `OGS_BUILD_CLI` - Builds the simulator. *Defaults* to *ON*. If set to *OFF* all processes are also disabled. - `OGS_BUILD_CLI` - Builds the simulator. *Defaults* to *ON*. If set to *OFF* all processes are also disabled (see variable `OGS_BUILD_PROCESSES` below).
- `OGS_BUILD_GUI` - Builds the Data Explorer. *Defaults* to *OFF*. - `OGS_BUILD_GUI` - Builds the Data Explorer. *Defaults* to *OFF*.
- `OGS_BUILD_TESTING` - Builds the test executables. *Defaults* to *ON*. - `OGS_BUILD_TESTING` - Builds the test executables. *Defaults* to *ON*.
- `OGS_BUILD_UTILS` - Builds several utilities. - `OGS_BUILD_UTILS` - Builds several utilities.
- `OGS_BUILD_PROCESS_X` - For enabling/disabling compilation of process `X`. - `OGS_BUILD_PROCESS_X` - For enabling/disabling compilation of process `X`.
Run the CMake-Gui to see a list of processes. Run the CMake-Gui / ccmake to see a list of processes.
- `OGS_BUILD_PROCESSES` - A `;`-separated list specifying processes to build. *Defaults* to an *empty string*. This will alter the `OGS_BUILD_PROCESS_X`-options. For e.g. building just the two processes `HT` and `LIE`: `-DOGS_BUILD_PROCESSES="HT;LIE"`. Setting this variable back to an empty string **does not reset** the `OGS_BUILD_PROCESS_X`-options. You can also set it to *OFF* to disable all processes. - `OGS_BUILD_PROCESSES` - A `;`-separated list specifying processes to build, e.g. `-DOGS_BUILD_PROCESSES="HT;LIE"`. Can be set to *ON* which means all processes are built or can be set to *OFF* to disable all processes. **Attention:** Setting this variable overrides individual `OGS_BUILD_PROCESS_X`-variables! This option is mainly used for CI and automation. Also the value of this variable is not cached.
### Debugging ### Debugging
......
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