forked from projectchrono/chrono
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify FindBlaze.cmake and FindSpectra.cmake to also allow finding in…
…stallked Blaze and Spectra, respectively
- Loading branch information
Showing
6 changed files
with
160 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,85 @@ | ||
# 2025-02-18 (Radu) modified to assume Blaze newer than 3.2 => no boost dependency | ||
# Find Blaze | ||
# | ||
# This script requires one of the following input variables: | ||
# - blaze_DIR: directory containing the Blaze package configuration script | ||
# - blaze_INCLUDE_DIR: directory containing the subdirectory 'blaze/' | ||
# | ||
# This script provides the following outputs: | ||
# - blaze_FOUND: a boolean variable indicating whether the library was found | ||
# - blaze::blaze: imported target | ||
|
||
# ----- Blaze library ----- | ||
set(Blaze_ROOT_TEMP ${Blaze_ROOT}) | ||
if(blaze_INCLUDE_DIR) | ||
|
||
find_path(Blaze_ROOT NAMES blaze/Blaze.h PATHS ${Blaze_ROOT_TEMP} "/usr/include" "/usr/local/include") | ||
if (NOT Blaze_ROOT) | ||
message("WARNING Cannot find '<Blaze_ROOT>/blaze/system/Version.h'. Properly set Blaze_ROOT.") | ||
if(EXISTS "${blaze_INCLUDE_DIR}/blaze/system/Version.h") | ||
if(NOT TARGET blaze::blaze) | ||
add_library(blaze::blaze INTERFACE IMPORTED) | ||
set_target_properties(blaze::blaze PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${blaze_INCLUDE_DIR}") | ||
endif() | ||
set(blaze_FOUND TRUE) | ||
if(NOT Blaze_FIND_QUIETLY) | ||
message(STATUS "Found 'blaze/system/Version.h' in provided blaze_INCLUDE_DIR=${blaze_INCLUDE_DIR}") | ||
endif() | ||
else() | ||
set(blaze_FOUND FALSE) | ||
if(NOT Blaze_FIND_QUIETLY) | ||
message(STATUS "Could not find 'blaze/system/Version.h' in the provided blaze_INCLUDE_DIR=${blaze_INCLUDE_DIR}") | ||
endif() | ||
endif() | ||
|
||
else() | ||
|
||
find_package(blaze NO_MODULE) | ||
|
||
if(blaze_FOUND) | ||
get_target_property(blaze_INCLUDE_DIR blaze::blaze INTERFACE_INCLUDE_DIRECTORIES) | ||
if(NOT Blaze_FIND_QUIETLY) | ||
message(STATUS "Blaze found through config script") | ||
endif() | ||
endif() | ||
|
||
endif() | ||
|
||
# Check Blaze version | ||
|
||
if(NOT blaze_FOUND) | ||
return() | ||
endif() | ||
|
||
# Extract Blaze version | ||
find_file(Blaze_VERSION_FILENAME "Version.h" PATHS "${Blaze_ROOT}/blaze/system") | ||
mark_as_advanced(FORCE Blaze_VERSION_FILENAME) | ||
if(Blaze_VERSION_FILENAME) | ||
file(READ ${Blaze_VERSION_FILENAME} Blaze_VERSION_FILE) | ||
find_file(blaze_VERSION_FILENAME "Version.h" PATHS "${blaze_INCLUDE_DIR}/blaze/system") | ||
mark_as_advanced(FORCE blaze_VERSION_FILENAME) | ||
|
||
if(blaze_VERSION_FILENAME) | ||
|
||
file(READ ${blaze_VERSION_FILENAME} Blaze_VERSION_FILE) | ||
|
||
string(REGEX MATCH "#define BLAZE_MAJOR_VERSION ([0-9]*)" _Blaze_MAJOR_VERSION ${Blaze_VERSION_FILE}) | ||
set(Blaze_MAJOR_VERSION ${CMAKE_MATCH_1}) | ||
set(blaze_MAJOR_VERSION ${CMAKE_MATCH_1}) | ||
string(REGEX MATCH "#define BLAZE_MINOR_VERSION ([0-9]*)" _Blaze_MINOR_VERSION ${Blaze_VERSION_FILE}) | ||
set(Blaze_MINOR_VERSION ${CMAKE_MATCH_1}) | ||
set(Blaze_VERSION "${Blaze_MAJOR_VERSION}.${Blaze_MINOR_VERSION}") | ||
set(blaze_MINOR_VERSION ${CMAKE_MATCH_1}) | ||
set(blaze_VERSION "${blaze_MAJOR_VERSION}.${blaze_MINOR_VERSION}") | ||
|
||
if(NOT Blaze_FIND_QUIETLY) | ||
message(STATUS "Blaze version file: ${Blaze_VERSION_FILENAME}") | ||
message(STATUS "Blaze version: ${Blaze_VERSION}") | ||
message(STATUS "Blaze version file: ${blaze_VERSION_FILENAME}") | ||
message(STATUS "Blaze version: ${blaze_VERSION}") | ||
endif() | ||
|
||
if (blaze_VERSION VERSION_LESS "3.2") | ||
set(blaze_FOUND FALSE) | ||
if(NOT Blaze_FIND_QUIETLY) | ||
mesage(STATUS "Blaze version older than 3.2.") | ||
endif() | ||
return() | ||
endif() | ||
set(Blaze_FOUND TRUE) | ||
|
||
else() | ||
message("WARNING Cannot find '<Blaze_ROOT>/blaze/system/Version.h'. Properly set Blaze_ROOT.") | ||
endif() | ||
|
||
# ----- BOOST -- required only for older versions of Blaze ----- | ||
set(blaze_FOUND FALSE) | ||
|
||
if(NOT Blaze_FIND_QUIETLY) | ||
message(STATUS "Cannot find header 'blaze/system/Version.h'") | ||
endif() | ||
|
||
if (Blaze_VERSION VERSION_LESS "3.2") | ||
mesage("WARNING: Blaze newer than 3.2 required. Blaze support disabled.") | ||
set(Blaze_FOUND FALSE) | ||
return() | ||
endif() | ||
|
||
# Create Blaze::Blaze target | ||
if (Blaze_ROOT AND NOT TARGET Blaze::Blaze) | ||
add_library(Blaze::Blaze INTERFACE IMPORTED) | ||
set_target_properties(Blaze::Blaze PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "${Blaze_ROOT}") | ||
endif() | ||
|
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 |
---|---|---|
@@ -1,35 +1,42 @@ | ||
|
||
#------------------------------------------------------------------------------- | ||
# Find Spectra | ||
# ATTENTION: Spectra library (https://github.com/yixuan/spectra) has its own spectra-config.cmake | ||
# but needs to be installed; we provide an easier way | ||
|
||
# This find script requires the following input variables: | ||
# - Spectra_INCLUDE_DIR: shall contain the subdirectory named 'Spectra' | ||
# This find script provides the following output variables/targets: | ||
# - Spectra_FOUND: a boolean indicating whether the library was found | ||
# | ||
# This script requires one of the following input variables: | ||
# - spectra_DIR: directory containing the Spectra package configuration script | ||
# - spectra_INCLUDE_DIR: directory containing the subdirectory 'Spectra/' | ||
# | ||
# This script provides the following outputs: | ||
# - spectra_FOUND: a boolean variable indicating whether the library was found | ||
# - Spectra::Spectra: imported target | ||
|
||
set(Spectra_FOUND TRUE) | ||
|
||
find_path(Spectra_INCLUDE_DIR_INTERNAL NAMES SymEigsBase.h PATHS "${Spectra_INCLUDE_DIR}/Spectra" NO_CACHE) | ||
mark_as_advanced(Spectra_INCLUDE_DIR_INTERNAL) | ||
|
||
if (NOT Spectra_INCLUDE_DIR_INTERNAL) | ||
message(NOTICE "Could not find '${Spectra_INCLUDE_DIR}/Spectra/SymEigsBase.h'. Set Spectra_INCLUDE_DIR to a folder containing the subfolder 'Spectra'.") | ||
return() | ||
endif() | ||
if(spectra_INCLUDE_DIR) | ||
|
||
if(EXISTS "${spectra_INCLUDE_DIR}/Spectra/KrylovSchurGEigsSolver.h") | ||
if(NOT TARGET Spectra::Spectra) | ||
add_library(Spectra::Spectra INTERFACE IMPORTED) | ||
set_target_properties(Spectra::Spectra PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${spectra_INCLUDE_DIR}") | ||
if(MSVC) | ||
set_property(TARGET Spectra::Spectra PROPERTY INTERFACE_COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:CXX>:/bigobj>) | ||
endif() | ||
endif() | ||
set(spectra_FOUND TRUE) | ||
if(NOT Spectra_FIND_QUIETLY) | ||
message(STATUS "Found 'Spectra/KrylovSchurGEigsSolver.h' in provided spectra_INCLUDE_DIR=${spectra_INCLUDE_DIR}") | ||
endif() | ||
else() | ||
set(spectra_FOUND FALSE) | ||
if(NOT Spectra_FIND_QUIETLY) | ||
message(STATUS "Could not find 'Spectra/KrylovSchurGEigsSolver.h' in the provided spectra_INCLUDE_DIR=${spectra_INCLUDE_DIR}") | ||
endif() | ||
endif() | ||
|
||
set(Spectra_FOUND TRUE) | ||
else() | ||
|
||
if(Spectra_FOUND AND NOT TARGET Spectra::Spectra) | ||
add_library(Spectra::Spectra INTERFACE IMPORTED) | ||
set_target_properties(Spectra::Spectra PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "${Spectra_INCLUDE_DIR}") | ||
if(MSVC) | ||
set_property(TARGET Spectra::Spectra PROPERTY | ||
INTERFACE_COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:CXX>:/bigobj>) | ||
find_package(spectra NO_MODULE) | ||
if(spectra_FOUND) | ||
get_target_property(spectra_INCLUDE_DIR Spectra::Spectra INTERFACE_INCLUDE_DIRECTORIES) | ||
if(NOT Spectra_FIND_QUIETLY) | ||
message(STATUS "Spectra found through config script") | ||
endif() | ||
endif() | ||
|
||
endif() | ||
|
||
endif() |
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
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