-
Notifications
You must be signed in to change notification settings - Fork 1.1k
WIP - test to show failing build on Linux when --sysroot is passed
#19574
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
Draft
jcar87
wants to merge
9
commits into
conan-io:develop2
Choose a base branch
from
jcar87:lcc/feature/cmakedeps-meson-rpath-link
base: develop2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7820cd4
add test to check cmake handling of -rpath/-rpath-link
jcar87 7b3cb09
f
jcar87 9c1567f
add additional test (fails on both CMakeDeps and CMakeConfigDeps)
jcar87 f4ba8a7
meson_lib: add requires
jcar87 fb36f17
add test for meson trainsitive rpath
jcar87 8efbb84
CMakeToolchain: add optional -rpath-link block
jcar87 77fde4a
MesonToolchain: add a way to add -rpath-link to all host lib dirs
jcar87 ac9fe92
cmake
jcar87 b7b5af5
add_rpath_link: use single conf for both toolchains, expose configura…
jcar87 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
244 changes: 244 additions & 0 deletions
244
test/functional/toolchains/cmake/test_cmake_transitive_rpath.py
This file contains hidden or 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,244 @@ | ||
| import platform | ||
| import textwrap | ||
| import pytest | ||
|
|
||
| from conan.test.utils.mocks import ConanFileMock | ||
| from conan.tools.env.environment import environment_wrap_command | ||
| from conan.test.utils.test_files import temp_folder | ||
| from conan.test.utils.tools import TestClient | ||
|
|
||
| @pytest.mark.skipif(platform.system() != "Linux", reason="Linux/gcc required for -rpath/-rpath-link testing") | ||
| @pytest.mark.tool("cmake", "3.27") | ||
| @pytest.mark.parametrize("use_cmake_config_deps", [True, False]) | ||
| def test_cmake_sysroot_transitive_rpath(use_cmake_config_deps): | ||
| c = TestClient() | ||
|
|
||
|
|
||
| extra_profile = textwrap.dedent(""" | ||
| [conf] | ||
| tools.build:sysroot=/path/to/nowhere | ||
| """) | ||
|
|
||
| # Avoid using any C or C++ standard functionality, so that we can "redirect" the sysroot | ||
| # to an empty or non-existing directory | ||
| foo_h = textwrap.dedent(""" | ||
| #pragma once | ||
| int foo(int x, int y); | ||
| """) | ||
| foo_cpp = textwrap.dedent(""" | ||
| #include "foo.h" | ||
| int foo(int x, int y) { | ||
| return x + y; | ||
| } | ||
| """) | ||
| foo_test = textwrap.dedent(""" | ||
| #include "foo.h" | ||
| int main() { return foo(2, 3) == 5 ? 0 : 1; } | ||
| """) | ||
| bar_h = textwrap.dedent(""" | ||
| #pragma once | ||
| int bar(int x, int y); | ||
| """) | ||
| bar_cpp = textwrap.dedent(""" | ||
| #include "bar.h" | ||
| #include "foo.h" | ||
| int bar(int x, int y) { | ||
| return foo(x, y) * 2; | ||
| } | ||
| """) | ||
| bar_test = textwrap.dedent(""" | ||
| #include "bar.h" | ||
| int main() { return bar(2, 3) == 10 ? 0 : 1; } | ||
| """) | ||
|
|
||
| c.save({"extra_profile": extra_profile}) | ||
| extra_conf = "-c tools.cmake.cmakedeps:new=will_break_next" if use_cmake_config_deps else "" | ||
| if not use_cmake_config_deps: | ||
| # CMakeConfigDeps does not fail, so nothing extra is needed | ||
| # this is only needed to cover the case of CMakeDeps | ||
| extra_conf += " -c tools.cmake.cmaketoolchain:add_rpath_link=True" | ||
| with c.chdir("foo"): | ||
| c.run("new cmake_lib -d name=foo -d version=0.1") | ||
| c.save({"include/foo.h": foo_h, | ||
| "src/foo.cpp": foo_cpp, | ||
| "test_package/src/example.cpp": foo_test}) | ||
| c.run(f"create . -o '*:shared=True' -pr=default -pr=../extra_profile {extra_conf}") | ||
|
|
||
| with c.chdir("bar"): | ||
| c.run("new cmake_lib -d name=bar -d version=0.1 -d requires=foo/0.1") | ||
| c.save({"include/bar.h": bar_h, | ||
| "src/bar.cpp": bar_cpp, | ||
| "test_package/src/example.cpp": bar_test}) | ||
| # skip test package, which fails with CMakeToolchain+CMakeDeps | ||
| c.run(f"create . -o '*:shared=True' -tf= -pr=default -pr=../extra_profile {extra_conf}") | ||
| with c.chdir("app"): | ||
| c.run("new cmake_exe -d name=app -d version=0.1 -d requires=bar/0.1") | ||
| c.save({"src/main.cpp": bar_test, | ||
| "src/app.cpp": ""}) | ||
| c.run(f"create . -o '*:shared=True' -pr=default -pr=../extra_profile {extra_conf}") | ||
|
|
||
|
|
||
|
|
||
| @pytest.mark.skipif(platform.system() != "Linux", reason="Linux/gcc required for -rpath/-rpath-link testing") | ||
| @pytest.mark.tool("cmake", "3.27") | ||
| @pytest.mark.parametrize("use_cmake_config_deps", [True, False]) | ||
| def test_cmake_transitive_rpath_private_internal(use_cmake_config_deps): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the test for CMakeConfigDeps issue with the package interface target usage. |
||
| c = TestClient() | ||
|
|
||
| foo_h = textwrap.dedent(""" | ||
| #pragma once | ||
| int foo(int x, int y); | ||
| """) | ||
| foo_cpp = textwrap.dedent(""" | ||
| #include "foo.h" | ||
| int foo(int x, int y) { | ||
| return x + y; | ||
| } | ||
| """) | ||
| bar_h = textwrap.dedent(""" | ||
| #pragma once | ||
| int bar(int x, int y); | ||
| """) | ||
| bar_cpp = textwrap.dedent(""" | ||
| #include "bar.h" | ||
| #include "foo.h" | ||
| int bar(int x, int y) { | ||
| return foo(x, y) * 2; | ||
| } | ||
| """) | ||
|
|
||
| foobar_cmakelists = textwrap.dedent(""" | ||
| cmake_minimum_required(VERSION 3.15) | ||
| project(foobar CXX) | ||
|
|
||
| add_library(foo src/foo.cpp) | ||
| target_include_directories(foo PUBLIC include) | ||
| set_target_properties(foo PROPERTIES PUBLIC_HEADER "include/foo.h") | ||
|
|
||
| add_library(bar src/bar.cpp) | ||
| target_include_directories(bar PUBLIC include) | ||
| set_target_properties(bar PROPERTIES PUBLIC_HEADER "include/bar.h") | ||
| target_link_libraries(bar PRIVATE foo) | ||
|
|
||
| install(TARGETS foo bar) | ||
| """) | ||
|
|
||
| foobar_conanfile = textwrap.dedent(""" | ||
| from conan import ConanFile | ||
| from conan.tools.cmake import CMake, cmake_layout | ||
|
|
||
|
|
||
| class foobarRecipe(ConanFile): | ||
| name = "foobar" | ||
| version = "1.0" | ||
| package_type = "library" | ||
| settings = "os", "compiler", "build_type", "arch" | ||
| options = {"shared": [True, False]} | ||
| default_options = {"shared": True} | ||
|
|
||
| exports_sources = "CMakeLists.txt", "src/*", "include/*" | ||
|
|
||
| generators = "CMakeDeps", "CMakeToolchain" | ||
|
|
||
| def layout(self): | ||
| cmake_layout(self) | ||
|
|
||
| def build(self): | ||
| cmake = CMake(self) | ||
| cmake.configure() | ||
| cmake.build() | ||
|
|
||
| def package(self): | ||
| cmake = CMake(self) | ||
| cmake.install() | ||
|
|
||
| def package_info(self): | ||
| self.cpp_info.components["foo"].libs = ["foo"] | ||
| self.cpp_info.components["bar"].libs = ["bar"] | ||
| self.cpp_info.components["bar"].requires = ["foo"] | ||
| """) | ||
|
|
||
| consumer_conanfile = textwrap.dedent(""" | ||
| from conan import ConanFile | ||
| from conan.tools.cmake import CMake, cmake_layout | ||
|
|
||
| class consumerRecipe(ConanFile): | ||
| name = "consumer" | ||
| version = "1.0" | ||
| package_type = "library" | ||
| settings = "os", "compiler", "build_type", "arch" | ||
| options = {"shared": [True, False]} | ||
| default_options = {"shared": True} | ||
| generators = "CMakeDeps", "CMakeToolchain" | ||
| exports_sources = "CMakeLists.txt", "src/*", "include/*" | ||
|
|
||
| def layout(self): | ||
| cmake_layout(self) | ||
|
|
||
| def requirements(self): | ||
| self.requires("foobar/1.0") | ||
|
|
||
| def build(self): | ||
| cmake = CMake(self) | ||
| cmake.configure() | ||
| cmake.build() | ||
|
|
||
| def package(self): | ||
| cmake = CMake(self) | ||
| cmake.install() | ||
|
|
||
| def package_info(self): | ||
| self.cpp_info.libs = ["consumer"] | ||
| """) | ||
|
|
||
| consumer_cmakelists = textwrap.dedent(""" | ||
| cmake_minimum_required(VERSION 3.15) | ||
| project(consumer CXX) | ||
|
|
||
| find_package(foobar CONFIG REQUIRED) | ||
|
|
||
| add_library(consumer src/consumer.cpp) | ||
| target_include_directories(consumer PUBLIC include) | ||
| target_link_libraries(consumer PRIVATE ${foobar_LIBRARIES}) # foobar_LIBRARIES is foobar::foobar | ||
| set_target_properties(consumer PROPERTIES PUBLIC_HEADER "include/consumer.h") | ||
| install(TARGETS consumer) | ||
|
|
||
| add_executable(my_app src/my_app.cpp) | ||
| target_link_libraries(my_app PRIVATE consumer) | ||
| """) | ||
|
|
||
| consumer_cpp = textwrap.dedent(""" | ||
| #include "consumer.h" | ||
| #include "bar.h" | ||
| int consumer(int x, int y) {return bar(x, y) * 2;} | ||
| """) | ||
|
|
||
| consumer_h = textwrap.dedent(""" | ||
| #pragma once | ||
| int consumer(int x, int y); | ||
| """) | ||
|
|
||
| my_app_cpp = textwrap.dedent(""" | ||
| #include "consumer.h" | ||
| int main() { return consumer(2, 3) == 20 ? 0 : 1; } | ||
| """) | ||
|
|
||
| extra_conf = "-c tools.cmake.cmakedeps:new=will_break_next" if use_cmake_config_deps else "" | ||
| extra_conf += " -c tools.cmake.cmaketoolchain:add_rpath_link=True" # removing this should break the test | ||
|
|
||
| with c.chdir("foobar"): | ||
| c.save({"include/foo.h": foo_h, | ||
| "include/bar.h": bar_h, | ||
| "src/foo.cpp": foo_cpp, | ||
| "src/bar.cpp": bar_cpp, | ||
| "CMakeLists.txt": foobar_cmakelists, | ||
| "conanfile.py": foobar_conanfile}) | ||
| c.run(f"create . {extra_conf} ") | ||
|
|
||
| with c.chdir("consumer"): | ||
| c.save({"src/consumer.cpp": consumer_cpp, | ||
| "include/consumer.h": consumer_h, | ||
| "src/my_app.cpp": my_app_cpp, | ||
| "CMakeLists.txt": consumer_cmakelists, | ||
| "conanfile.py": consumer_conanfile}) | ||
| c.run(f"create . {extra_conf}") | ||
Oops, something went wrong.
Oops, something went wrong.
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.
I need to visually check where and how these flags are passed - but it does work with path with spaces, since that's what the test is using