Skip to content

Commit 5442afa

Browse files
committed
FindKML: Add compiler check
1 parent ea4befd commit 5442afa

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

cmake/FindKML.cmake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,26 @@ if(DEFINED ENV{KML_ROOT})
7474
endif()
7575
list(APPEND _kml_prefix_hints /usr/local/kml)
7676

77+
# Check if an explicitly selected compiler-specific KML prefix matches the compiler.
78+
set(_kml_explicit_root "${KML_ROOT}")
79+
if(NOT _kml_explicit_root AND DEFINED ENV{KML_ROOT})
80+
set(_kml_explicit_root "$ENV{KML_ROOT}")
81+
endif()
82+
get_filename_component(_kml_root_name "${_kml_explicit_root}" NAME)
83+
if(_kml_root_name STREQUAL "gcc")
84+
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
85+
message(FATAL_ERROR
86+
"KML_ROOT points to the GCC KML bundle, but the C++ compiler is "
87+
"${CMAKE_CXX_COMPILER_ID}.")
88+
endif()
89+
elseif(_kml_root_name STREQUAL "bisheng")
90+
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
91+
message(FATAL_ERROR
92+
"KML_ROOT points to the BiShengLLVM KML bundle, but the C++ compiler is "
93+
"${CMAKE_CXX_COMPILER_ID}.")
94+
endif()
95+
endif()
96+
7797
find_path(KML_INCLUDE_DIR
7898
NAMES kblas.h klapack.h kscalapack.h
7999
HINTS ${_kml_prefix_hints}

0 commit comments

Comments
 (0)