Skip to content

Commit

Permalink
Fixes issue #2285 where Visual Studio users using a clang toolset wou…
Browse files Browse the repository at this point in the history
…ld not be able to compile due to the compiler check failing. (#2287)
  • Loading branch information
mpdelbuono authored and lasote committed Jan 10, 2018
1 parent 5d68446 commit 3e890ba
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions conans/client/generators/cmake_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,23 @@ def generate_targets_section(dependencies):
set(CROSS_BUILDING 1)
endif()
# If using VS, verify toolset
if (CONAN_COMPILER STREQUAL "Visual Studio")
if (CONAN_SETTINGS_COMPILER_TOOLSET MATCHES "LLVM" OR
CONAN_SETTINGS_COMPILER_TOOLSET MATCHES "clang")
set(EXPECTED_CMAKE_CXX_COMPILER_ID "Clang")
else()
set(EXPECTED_CMAKE_CXX_COMPILER_ID "MSVC")
endif()
if (NOT CMAKE_CXX_COMPILER_ID MATCHES ${EXPECTED_CMAKE_CXX_COMPILER_ID})
message(FATAL_ERROR "Incorrect '${CONAN_COMPILER}'. Toolset specifies compiler as '${EXPECTED_CMAKE_CXX_COMPILER_ID}' "
"but CMake detected '${CMAKE_CXX_COMPILER_ID}'")
endif()
# Avoid checks when cross compiling, apple-clang crashes because its APPLE but not apple-clang
# Actually CMake is detecting "clang" when you are using apple-clang, only if CMP0025 is set to NEW will detect apple-clang
if( (CONAN_COMPILER STREQUAL "Visual Studio" AND NOT CMAKE_CXX_COMPILER_ID MATCHES MSVC) OR
(CONAN_COMPILER STREQUAL "gcc" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR
elseif((CONAN_COMPILER STREQUAL "gcc" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR
(CONAN_COMPILER STREQUAL "apple-clang" AND NOT CROSS_BUILDING AND (NOT APPLE OR NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")) OR
(CONAN_COMPILER STREQUAL "clang" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR
(CONAN_COMPILER STREQUAL "sun-cc" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "SunPro") )
Expand Down

0 comments on commit 3e890ba

Please sign in to comment.