Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 7e916ad

Browse files
author
michalbiesek
committed
Fix Clang detection
- use CMAKE_CXX_COMPILER_VERSION/CMAKE_C[XX]_COMPILER_ID for setting compiler conditions - fixes #1090
1 parent 1db710e commit 7e916ad

2 files changed

Lines changed: 4 additions & 13 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,6 @@ elseif(NOT VALGRIND_FOUND)
154154
message(WARNING "Valgrind not found. Valgrind tests will not be performed.")
155155
endif()
156156

157-
# Find Clang
158-
find_program(CLANG NAMES clang)
159-
if(CLANG)
160-
message(STATUS "Found clang: ${CLANG} (version: ${CLANG_VERSION})")
161-
else()
162-
message(STATUS "clang not found")
163-
endif()
164-
165157
if(BUILD_TESTS OR BUILD_EXAMPLES OR BUILD_BENCHMARKS)
166158
# Find libpmem and libpmemobj (PMDK libraries)
167159
if(PKG_CONFIG_FOUND)
@@ -174,10 +166,9 @@ if(BUILD_TESTS OR BUILD_EXAMPLES OR BUILD_BENCHMARKS)
174166

175167
# Some tests and examples require clang >= 8.0, because of the bug
176168
# (https://bugs.llvm.org/show_bug.cgi?id=28280), which is fixed in clang v8.0.
177-
set(CLANG_REQUIRED_BY_DESTRUCTOR_REFERENCE_BUG "8.0")
178-
if(CLANG)
179-
get_program_version_major_minor(${CLANG} CLANG_VERSION)
180-
if(CLANG_VERSION VERSION_LESS CLANG_REQUIRED_BY_DESTRUCTOR_REFERENCE_BUG)
169+
170+
if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang" AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
171+
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0")
181172
set(CLANG_DESTRUCTOR_REFERENCE_BUG_PRESENT 1)
182173
endif()
183174
endif()

tests/ctest_helpers.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ endfunction()
139139
# Function to build test with atomic
140140
function(build_test_atomic name)
141141
build_test(${name} ${ARGN})
142-
if(CLANG)
142+
if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang" AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
143143
target_link_libraries(${name} atomic)
144144
endif()
145145
endfunction()

0 commit comments

Comments
 (0)