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

new test for new CMakeDeps shared linking #17437

Open
wants to merge 2 commits into
base: develop2
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ def test_libs_transitive(self, transitive_libraries, shared):
assert "Conan: Target declared imported STATIC library 'matrix::matrix'" in c.out
assert "Conan: Target declared imported STATIC library 'engine::engine'" in c.out

# if not using cmake >= 3.23 the intermediate gamelib_test linkage fail
@pytest.mark.tool("cmake", "3.23")
def test_multilevel_shared(self):
# TODO: make this shared fixtures in conftest for multi-level shared testing
c = TestClient(default_server_user=True)
Expand All @@ -230,6 +232,26 @@ def test_multilevel_shared(self):

c.save({}, clean_first=True)
c.run("new cmake_lib -d name=gamelib -d version=0.1 -d requires=engine/0.1")
cmake = textwrap.dedent("""\
cmake_minimum_required(VERSION 3.15)
project(gamelib CXX)

find_package(engine CONFIG REQUIRED)

add_library(gamelib src/gamelib.cpp)
target_include_directories(gamelib PUBLIC include)
target_link_libraries(gamelib PRIVATE engine::engine)

add_executable(gamelib_test src/gamelib_test.cpp)
target_link_libraries(gamelib_test PRIVATE gamelib)

set_target_properties(gamelib PROPERTIES PUBLIC_HEADER "include/gamelib.h")
install(TARGETS gamelib)
""")
# Testing that a local test executable links correctly with the new CMakeDeps
# It fails with the old CMakeDeps
c.save({"CMakeLists.txt": cmake,
"src/gamelib_test.cpp": '#include "gamelib.h"\nint main() { gamelib(); }'})
c.run(f"create . -o *:shared=True -c tools.cmake.cmakedeps:new={new_value}")

c.save({}, clean_first=True)
Expand Down
Loading