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

disable cmake compiler check language=None #4276

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions conans/client/generators/cmake_common.py
Expand Up @@ -397,6 +397,10 @@ def generate_targets_section(dependencies):
endfunction()

function(conan_check_compiler)
if(CONAN_DISABLE_CHECK_COMPILER)
conan_message(STATUS "WARN: Disabled conan compiler checks")
return()
endif()
if(NOT DEFINED CMAKE_CXX_COMPILER_ID)
Copy link
Contributor

@SSE4 SSE4 Jan 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we also have to check ENABLED_LANGUAGES property (obviously, after the CONAN_DISABLE_CHECK_COMPILER check)

(to obtain a list use get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES))

and execute checks only if it has C or CXX in the list (potentially, also Objective-C and Objective-C++?),

otherwise skip (no language at all / Fortran / D / Rust / Go / C# / Whatever else)

see also:
https://cmake.org/cmake/help/v3.3/command/project.htm
https://cmake.org/cmake/help/v3.3/prop_gbl/ENABLED_LANGUAGES.html

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that if someone is using conan for those languages, they are already setting CONAN_DISABLE_CHECK_COMPILER. And if for some other reason the language is not set, maybe it is better to raise an error early.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, raising an error might be a good strategy in this case.

if(DEFINED CMAKE_C_COMPILER_ID)
conan_message(STATUS "This project seems to be plain C, using '${CMAKE_C_COMPILER_ID}' compiler")
Expand All @@ -406,10 +410,6 @@ def generate_targets_section(dependencies):
message(FATAL_ERROR "This project seems to be plain C, but no compiler defined")
endif()
endif()
if(CONAN_DISABLE_CHECK_COMPILER)
conan_message(STATUS "WARN: Disabled conan compiler checks")
return()
endif()
if(NOT CMAKE_CXX_COMPILER_ID AND NOT CMAKE_C_COMPILER_ID)
# This use case happens when compiler is not identified by CMake, but the compilers are there and work
conan_message(STATUS "*** WARN: CMake was not able to identify a C or C++ compiler ***")
Expand Down
26 changes: 26 additions & 0 deletions conans/test/functional/generators/cmake_test.py
Expand Up @@ -9,6 +9,32 @@

class CMakeGeneratorTest(unittest.TestCase):

def test_no_check_compiler(self):
# https://github.com/conan-io/conan/issues/4268
file_content = '''from conans import ConanFile, CMake

class ConanFileToolsTest(ConanFile):
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
'''

cmakelists = '''cmake_minimum_required(VERSION 2.8)
PROJECT(conanzlib LANGUAGES NONE)
set(CONAN_DISABLE_CHECK_COMPILER TRUE)

include(conanbuildinfo.cmake)
CONAN_BASIC_SETUP()
'''
client = TestClient()
client.save({"conanfile.py": file_content,
"CMakeLists.txt": cmakelists})

client.run('install .')
client.run('build .')

@attr('slow')
def no_output_test(self):
client = TestClient()
Expand Down
8 changes: 1 addition & 7 deletions conans/test/functional/old/libcxx_setting_test.py
Expand Up @@ -39,15 +39,9 @@ def package(self):
'''


def nowintest(func):
if platform.system() == "Windows":
func.__test__ = False
return func


class LibcxxSettingTest(unittest.TestCase):

@nowintest
@unittest.skipIf(platform.system() == "Windows", "Not in Windows")
def test_declared_stdlib_and_passed(self):
client = TestClient()
client.save({"conanfile.py": file_content,
Expand Down