-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export samurai CMake options (#224)
## Description samurai options are exported so that calling projects can enable/disable them - through the `ccmake` command, - in the `cmake` command line: ```bash cmake -DSAMURAI_[OPTIONNAME]=ON .. ``` - or in the project's `CMakeLists.txt`: ```cmake set(SAMURAI_[OPTIONNAME] On) ``` Examples of options: `SAMURAI_WITH_MPI`, `SAMURAI_WITH_OPENMP`, `SAMURAI_CHECK_NAN`. ## Code of Conduct By submitting this PR, you agree to follow our [Code of Conduct](https://github.com/hpc-maths/samurai/blob/master/docs/CODE_OF_CONDUCT.md) - [x] I agree to follow this project's Code of Conduct
- Loading branch information
Showing
3 changed files
with
83 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
option(SAMURAI_WITH_OPENMP "Enable OpenMP" OFF) | ||
if(${SAMURAI_WITH_OPENMP}) | ||
find_dependency(OpenMP) | ||
if(OpenMP_CXX_FOUND) | ||
target_link_libraries(samurai::samurai INTERFACE OpenMP::OpenMP_CXX) | ||
target_compile_definitions(samurai::samurai INTERFACE SAMURAI_WITH_OPENMP) | ||
else() | ||
message(FATAL_ERROR "OpenMP not found") | ||
endif() | ||
endif() | ||
|
||
|
||
option(SAMURAI_WITH_MPI "Enable MPI" OFF) | ||
if(SAMURAI_WITH_MPI) | ||
if (NOT HDF5_IS_PARALLEL) | ||
message(FATAL_ERROR "HDF5 is not parallel. Please install a parallel version.") | ||
endif() | ||
find_dependency(Boost COMPONENTS serialization mpi) | ||
target_link_libraries(samurai::samurai INTERFACE Boost::serialization Boost::mpi) | ||
target_compile_definitions(samurai::samurai INTERFACE SAMURAI_WITH_MPI) | ||
endif() | ||
|
||
|
||
option(SAMURAI_CHECK_NAN "Check NaN in computations" OFF) | ||
if(SAMURAI_CHECK_NAN) | ||
target_compile_definitions(samurai::samurai INTERFACE SAMURAI_CHECK_NAN) | ||
endif() | ||
|
||
|
||
set(FLUX_CONTAINER_LIST array xtensor) | ||
set(SAMURAI_FLUX_CONTAINER "xtensor" CACHE STRING "Container to store fluxes: ${FLUX_CONTAINER_LIST}") | ||
set_property(CACHE SAMURAI_FLUX_CONTAINER PROPERTY STRINGS ${FLUX_CONTAINER_LIST}) | ||
if(NOT SAMURAI_FLUX_CONTAINER IN_LIST FLUX_CONTAINER_LIST) | ||
message(FATAL_ERROR "SAMURAI_FLUX_CONTAINER must be one of: ${FLUX_CONTAINER_LIST}") | ||
else() | ||
target_compile_definitions(samurai::samurai INTERFACE FLUX_CONTAINER_${FLUX_CONTAINER}) | ||
endif() |