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
Feature/clang #9477
Merged
Merged
Feature/clang #9477
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ec5f477
wip
memsharded 1be9a2f
improving test conf
memsharded 686a13a
fixing some tests
memsharded abd3ef4
wip
memsharded 6f7d314
wip
memsharded ae9e98a
docs
memsharded cafa181
wip
memsharded 20f71f4
wip
memsharded cb98d71
wip
memsharded cdae664
wip
memsharded aa5931e
fixing test
memsharded 7c0dfd1
remove unused markers
memsharded a7decb5
wip
memsharded 408aa63
enable meson
memsharded 695e22d
removing meson version check
memsharded 887d81e
wip
memsharded af11ba7
test to see if we break something
memsharded 9648031
fix visual_studio tests
memsharded da79e51
merged
memsharded f23fdd8
wip
memsharded ad3b2ef
merged develop
memsharded bc549a7
wip
memsharded File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
conans/test/functional/toolchains/cmake/test_cmake_toolchain_win_clang.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import platform | ||
import textwrap | ||
|
||
import pytest | ||
|
||
from conans.test.assets.cmake import gen_cmakelists | ||
from conans.test.assets.sources import gen_function_cpp | ||
from conans.test.utils.tools import TestClient | ||
from conans.util.files import save | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
c = TestClient() | ||
save(c.cache.new_config_path, "tools.env.virtualenv:auto_use=True") | ||
clang_profile = textwrap.dedent(""" | ||
[settings] | ||
os=Windows | ||
arch=x86_64 | ||
build_type=Release | ||
compiler=clang | ||
compiler.version=12 | ||
|
||
[buildenv] | ||
CC=clang | ||
CXX=clang++ | ||
RC=clang | ||
""") | ||
conanfile = textwrap.dedent(""" | ||
import os | ||
from conans import ConanFile | ||
from conan.tools.cmake import CMake | ||
from conan.tools.layout import cmake_layout | ||
class Pkg(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
exports_sources = "*" | ||
generators = "CMakeToolchain" | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
cmd = os.path.join(self.cpp.build.bindirs[0], "my_app") | ||
self.run(cmd, env=["conanrunenv"]) | ||
""") | ||
c.save({"conanfile.py": conanfile, | ||
"clang": clang_profile, | ||
"src/CMakeLists.txt": gen_cmakelists(appname="my_app", appsources=["main.cpp"]), | ||
"src/main.cpp": gen_function_cpp(name="main")}) | ||
return c | ||
|
||
|
||
@pytest.mark.tool_cmake | ||
@pytest.mark.tool_mingw64 | ||
@pytest.mark.tool_clang(version="12") | ||
@pytest.mark.skipif(platform.system() != "Windows", reason="requires Win") | ||
def test_clang(client): | ||
client.run("create . pkg/0.1@ -pr=clang") | ||
# clang compilations in Windows will use MinGW Makefiles by default | ||
assert 'cmake -G "MinGW Makefiles"' in client.out | ||
assert "main __clang_major__12" in client.out | ||
# Check this! Clang compiler in Windows is reporting MSC_VER and MSVC_LANG! | ||
assert "main _MSC_VER19" in client.out | ||
assert "main _MSVC_LANG2014" in client.out | ||
|
||
|
||
@pytest.mark.tool_cmake | ||
@pytest.mark.tool_clang(version="12") | ||
@pytest.mark.skipif(platform.system() != "Windows", reason="requires Win") | ||
def test_clang_cmake_ninja(client): | ||
client.run("create . pkg/0.1@ -pr=clang -c tools.cmake.cmaketoolchain:generator=Ninja") | ||
assert 'cmake -G "Ninja"' in client.out | ||
assert "main __clang_major__12" in client.out | ||
# Check this! Clang compiler in Windows is reporting MSC_VER and MSVC_LANG! | ||
assert "main _MSC_VER19" in client.out | ||
assert "main _MSVC_LANG2014" in client.out | ||
|
||
|
||
@pytest.mark.tool_cmake | ||
@pytest.mark.tool_visual_studio(version="16") # With Clang distributed in VS! | ||
@pytest.mark.skipif(platform.system() != "Windows", reason="requires Win") | ||
def test_clang_cmake_visual(client): | ||
clang_profile = textwrap.dedent(""" | ||
[settings] | ||
os=Windows | ||
arch=x86_64 | ||
build_type=Release | ||
compiler=clang | ||
compiler.version=11 | ||
""") | ||
# TODO: Clang version is unused, it can change, still 11 from inside VS is used | ||
client.save({"clang": clang_profile}) | ||
client.run("create . pkg/0.1@ -pr=clang " | ||
'-c tools.cmake.cmaketoolchain:generator="Visual Studio 16"') | ||
assert 'cmake -G "Visual Studio 16"' in client.out | ||
assert "main __clang_major__11" in client.out | ||
# Check this! Clang compiler in Windows is reporting MSC_VER and MSVC_LANG! | ||
assert "main _MSC_VER19" in client.out | ||
assert "main _MSVC_LANG2014" in client.out |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why cannot we use other generators such as
cmake
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the CMake generator. You need to select one of the CMake supported ones:
MinGW Makefiles
,Visual Studio XX YYYY
, etc.Also,
CMakeToolchain
will only support theCMakeDeps
generator (based on find_package()), but not the legacycmake
,cmake_find_package[_multi]
, becase these later ones will be removed in 2.0.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I got it, thank you.