Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip cmake compiler checks when toolset declared #5348

Merged
merged 1 commit into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions conans/client/generators/cmake_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,19 @@ def generate_targets_section(dependencies):

function(check_compiler_version)
conan_split_version(${CMAKE_CXX_COMPILER_VERSION} VERSION_MAJOR VERSION_MINOR)
if(DEFINED CONAN_SETTINGS_COMPILER_TOOLSET)
conan_message(STATUS "Conan: Skipping compiler check: Declared 'compiler.toolset'")
return()
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
# MSVC_VERSION is defined since 2.8.2 at least
# https://cmake.org/cmake/help/v2.8.2/cmake.html#variable:MSVC_VERSION
# https://cmake.org/cmake/help/v3.14/variable/MSVC_VERSION.html
if(
# 1920-1929 = VS 16.0 (v142 toolset)
(CONAN_COMPILER_VERSION STREQUAL "16" AND NOT((MSVC_VERSION GREATER 1919) AND (MSVC_VERSION LESS 1930))) OR
# 1910-1919 = VS 15.0 (v140 and v141 toolsets)
(CONAN_COMPILER_VERSION STREQUAL "15" AND NOT((MSVC_VERSION GREATER_EQUAL 1900) AND (MSVC_VERSION LESS 1920))) OR
# 1910-1919 = VS 15.0 (v141 toolset)
(CONAN_COMPILER_VERSION STREQUAL "15" AND NOT((MSVC_VERSION GREATER 1909) AND (MSVC_VERSION LESS 1920))) OR
# 1900 = VS 14.0 (v140 toolset)
(CONAN_COMPILER_VERSION STREQUAL "14" AND NOT(MSVC_VERSION EQUAL 1900)) OR
# 1800 = VS 12.0 (v120 toolset)
Expand Down
31 changes: 31 additions & 0 deletions conans/test/functional/generators/cmake_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import platform
import unittest

from nose.plugins.attrib import attr
Expand Down Expand Up @@ -35,6 +36,36 @@ def build(self):
client.run('install .')
client.run('build .')

@attr("slow")
@unittest.skipUnless(platform.system() == "Windows", "Requires MSBuild")
def skip_check_if_toolset_test(self):
file_content = '''from conans import ConanFile, CMake

class ConanFileToolsTest(ConanFile):
generators = "cmake"
exports_sources = "CMakeLists.txt"
settings = "os", "arch", "compiler"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
'''
client = TestClient()
cmakelists = '''
set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CXX_ABI_COMPILED 1)
PROJECT(Hello)
cmake_minimum_required(VERSION 2.8)
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
CONAN_BASIC_SETUP()
'''
client.save({"conanfile.py": file_content,
"CMakeLists.txt": cmakelists})
client.run("create . lib/1.0@user/channel -s compiler='Visual Studio' -s compiler.toolset=v140")
self.assertIn("Conan: Skipping compiler check: Declared 'compiler.toolset'", client.out)


@attr('slow')
def no_output_test(self):
client = TestClient()
Expand Down