Skip to content

Commit fea2fa9

Browse files
committed
Changed detection of Clang compiler to make it more robust across different OS-es
1 parent 9cbb553 commit fea2fa9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ set(FLANN_VERSION 1.8.0)
1212
DISSECT_VERSION()
1313
GET_OS_INFO()
1414

15-
if ( "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}" MATCHES ".*clang")
15+
# CMAKE_C_COMPILER_ID and CMAKE_CXX_COMPILER_ID are documented as internal variables subject to
16+
# change at: http://www.cmake.org/cmake/help/v2.8.8/cmake.html#variable:CMAKE_LANG_COMPILER_ID
17+
# however currently this seems the most robust way to detect the presence of the Clang compiler
18+
if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
1619
set(CMAKE_COMPILER_IS_CLANG 1)
1720
endif ()
1821

19-
if ( "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang")
22+
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
2023
set(CMAKE_COMPILER_IS_CLANGXX 1)
2124
endif ()
2225

23-
2426
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
2527

2628
# Add an "uninstall" target

0 commit comments

Comments
 (0)