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

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions conan/internal/model/cpp_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ def _lib_match_by_glob(dir_, filename):
if matches:
return matches


def _lib_match_by_regex(dir_, pattern):
ret = set()
# pattern is a regex compiled pattern, so let's iterate each file to find the library
Expand All @@ -515,7 +514,6 @@ def _lib_match_by_regex(dir_, pattern):
ret.add(full_path)
return list(ret)


def _find_matching(dirs, pattern):
for d in dirs:
if not os.path.exists(d):
Expand Down
24 changes: 24 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")
@pytest.mark.parametrize("shared", [False, True])
def test_multilevel(self, shared):
# TODO: make this shared fixtures in conftest for multi-level shared testing
Expand All @@ -231,6 +233,28 @@ def test_multilevel(self, shared):

c.save({}, clean_first=True)
c.run("new cmake_lib -d name=gamelib -d version=0.1 -d requires=engine/0.1")

# This specific CMake fails for shared libraries with old CMakeDeps in Linux
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={shared} -c tools.cmake.cmakedeps:new={new_value}")

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