Created
May 2, 2024 13:21
-
-
Save elkuno213/3c629ae2290eca347c815c012ca2c19c to your computer and use it in GitHub Desktop.
Some CMake modules
This file contains hidden or 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
# Hints: | |
# - set Eigen3_ROOT to the installation prefix of Eigen3. | |
# - append the installation prefix of Eigen3 to CMAKE_PREFIX_PATH. | |
# Results: | |
# - Eigen3_FOUND | |
# - Eigen3::Eigen | |
# - Eigen3_INCLUDE_DIRS | |
# - Eigen3_VERSION | |
find_path(Eigen3_INCLUDE_DIR | |
NAMES signature_of_eigen3_matrix_library | |
PATH_SUFFIXES eigen3 eigen | |
HINTS "${Eigen3_ROOT}/include/eigen3" | |
"${CMAKE_PREFIX_PATH}/include/eigen3" | |
"/usr/include/eigen3" | |
"/usr/local/include/eigen3" | |
DOC "The include directory of the Eigen3 library" | |
) | |
mark_as_advanced(Eigen3_INCLUDE_DIR) | |
if(Eigen3_INCLUDE_DIR) | |
file( | |
STRINGS "${Eigen3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _Eigen3_version_lines | |
REGEX "#define[ \t]+EIGEN_(WORLD|MAJOR|MINOR)_VERSION" | |
) | |
string(REGEX REPLACE ".*EIGEN_WORLD_VERSION *\([0-9]*\).*" "\\1" _Eigen3_version_world "${_Eigen3_version_lines}") | |
string(REGEX REPLACE ".*EIGEN_MAJOR_VERSION *\([0-9]*\).*" "\\1" _Eigen3_version_major "${_Eigen3_version_lines}") | |
string(REGEX REPLACE ".*EIGEN_MINOR_VERSION *\([0-9]*\).*" "\\1" _Eigen3_version_minor "${_Eigen3_version_lines}") | |
set(Eigen3_VERSION "${_Eigen3_version_world}.${_Eigen3_version_major}.${_Eigen3_version_minor}") | |
unset(_Eigen3_version_world) | |
unset(_Eigen3_version_major) | |
unset(_Eigen3_version_minor) | |
unset(_Eigen3_version_lines) | |
endif() | |
include(FindPackageHandleStandardArgs) | |
find_package_handle_standard_args(Eigen3 | |
REQUIRED_VARS Eigen3_INCLUDE_DIR | |
VERSION_VAR Eigen3_VERSION | |
) | |
if(Eigen3_FOUND) | |
set(Eigen3_INCLUDE_DIRS "${Eigen3_INCLUDE_DIR}") | |
if(NOT TARGET Eigen3::Eigen) | |
add_library(Eigen3::Eigen INTERFACE IMPORTED) | |
set_target_properties(Eigen3::Eigen PROPERTIES | |
INTERFACE_INCLUDE_DIRECTORIES "${Eigen3_INCLUDE_DIR}" | |
) | |
endif() | |
endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment