Skip to content

Commit b694be6

Browse files
authored
Improve SCOTCH handling in CMake (#3705)
* Refine CMake/SCOTCH handling * Tidy
1 parent e842cb3 commit b694be6

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

cpp/CMakeLists.txt

+18-17
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ set_package_properties(
237237
# Check for MPI
238238
find_package(MPI 3 REQUIRED)
239239

240-
find_package(spdlog REQUIRED)
241240
# ------------------------------------------------------------------------------
242241
# Compiler flags
243242

@@ -290,8 +289,8 @@ endif()
290289
# ------------------------------------------------------------------------------
291290
# Find required packages
292291

293-
# pugixml
294292
find_package(pugixml REQUIRED)
293+
find_package(spdlog REQUIRED)
295294

296295
# Note: When updating Boost version, also update DOLFINXConfig.cmake.in
297296
if(DEFINED ENV{BOOST_ROOT} OR DEFINED BOOST_ROOT)
@@ -464,29 +463,31 @@ elseif(_REQUIRE_SLEPC AND NOT PETSC_FOUND)
464463
)
465464
endif()
466465

467-
if(DOLFINX_ENABLE_SCOTCH)
466+
if(DOLFINX_ENABLE_SCOTCH AND _REQUIRE_SCOTCH)
467+
find_package(
468+
SCOTCH REQUIRED CONFIG HINTS $ENV{PETSC_DIR}/$ENV{PETSC_ARCH}
469+
$ENV{PETSC_DIR}
470+
)
471+
elseif(DOLFINX_ENABLE_SCOTCH)
468472
find_package(
469473
SCOTCH CONFIG HINTS $ENV{PETSC_DIR}/$ENV{PETSC_ARCH} $ENV{PETSC_DIR}
470474
)
471-
if(TARGET SCOTCH::scotch AND NOT TARGET SCOTCH::ptscotch)
472-
message(
473-
STATUS "SCOTCH found, but not PT-SCOTCH (parallel). Not enabling SCOTCH."
474-
)
475-
set(SCOTCH_FOUND FALSE)
476-
endif()
475+
endif()
477476

478-
if(SCOTCH_FOUND)
479-
message(
480-
STATUS
481-
"Found PT-SCOTCH version ${SCOTCH_VERSION}, include dir: ${SCOTCH_INCLUDE_DIR}, lib dir: ${SCOTCH_LIBRARY_DIR}"
482-
)
477+
if(TARGET SCOTCH::scotch AND NOT TARGET SCOTCH::ptscotch)
478+
message(
479+
STATUS "SCOTCH found, but not PT-SCOTCH (parallel). Not enabling SCOTCH."
480+
)
481+
set(SCOTCH_FOUND FALSE)
482+
if(_REQUIRE_SCOTCH AND NOT SCOTCH_FOUND)
483+
message(FATAL_ERROR "SCOTCH requested, but not found.")
483484
endif()
484485
endif()
485486

486-
if(_REQUIRE_SCOTCH AND NOT SCOTCH_FOUND)
487+
if(SCOTCH_FOUND)
487488
message(
488-
FATAL_ERROR
489-
"SCOTCH requested, but not found."
489+
STATUS
490+
"Found PT-SCOTCH version ${SCOTCH_VERSION}, include dir: ${SCOTCH_INCLUDE_DIR}, lib dir: ${SCOTCH_LIBRARY_DIR}"
490491
)
491492
endif()
492493

0 commit comments

Comments
 (0)