Skip to content
Draft
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
8 changes: 7 additions & 1 deletion conan/cps/cps.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, component_type=None):
self.definitions = {}
self.requires = []
self.link_requires = []
self.dyld_requires = []
self.location = None
self.link_location = None
self.link_languages = []
Expand All @@ -50,6 +51,8 @@ def serialize(self):
component["requires"] = self.requires
if self.link_requires:
component["link_requires"] = self.link_requires
if self.dyld_requires:
component["dyld_requires"] = self.dyld_requires
if self.includes:
component["includes"] = [x.replace("\\", "/") for x in self.includes]
if self.definitions:
Expand All @@ -70,6 +73,7 @@ def deserialize(data):
comp.type = CPSComponentType(data.get("type"))
comp.requires = data.get("requires", [])
comp.link_requires = data.get("link_requires", [])
comp.dyld_requires = data.get("dyld_requires", [])
comp.includes = data.get("includes", [])
comp.definitions = data.get("definitions", {})
comp.location = data.get("location")
Expand Down Expand Up @@ -130,6 +134,7 @@ def update(self, conf, conf_def):
self.location = self.location or conf_def.get("location")
self.link_location = self.link_location or conf_def.get("link_location")
self.link_libraries = self.link_libraries or conf_def.get("link_libraries")
self.dyld_requires = self.dyld_requires or conf_def.get("dyld_requires", [])


class CPS:
Expand Down Expand Up @@ -275,7 +280,8 @@ def definitions(defs):
elif comp.location:
location = comp.location
lib_location(location, cpp_comp)
requires = comp.link_requires + comp.requires
# TODO: Conan is using requires for everything, this could be an issue later?
requires = comp.link_requires + comp.requires + comp.dyld_requires
for r in requires:
cpp_comp.requires.append(r[1:] if r.startswith(":") else r.replace(":", "::"))
cpp_comp.system_libs = comp.link_libraries
Expand Down
25 changes: 8 additions & 17 deletions test/functional/toolchains/cmake/test_cps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import platform
import shutil
import textwrap

Expand Down Expand Up @@ -54,7 +53,7 @@ def package_info(self):
cmake = textwrap.dedent("""\
set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CXX_ABI_COMPILED 1)
cmake_minimum_required(VERSION 4.2)
cmake_minimum_required(VERSION 4.3)
project(mypkg CXX)

add_library(mypkg src/mypkg.cpp)
Expand Down Expand Up @@ -82,7 +81,7 @@ def package_info(self):
test_cmake = textwrap.dedent("""\
set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CXX_ABI_COMPILED 1)
cmake_minimum_required(VERSION 4.2)
cmake_minimum_required(VERSION 4.3)
project(PackageTest CXX)

find_package(mypkg CONFIG REQUIRED)
Expand Down Expand Up @@ -184,11 +183,9 @@ def package_info(self):
cmake = textwrap.dedent("""\
set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CXX_ABI_COMPILED 1)
cmake_minimum_required(VERSION 4.2)
cmake_minimum_required(VERSION 4.3)
project(mypkg CXX)

set(CMAKE_EXPERIMENTAL_EXPORT_PACKAGE_INFO "b80be207-778e-46ba-8080-b23bba22639e")

# First library: core
add_library(mypkg_core src/mypkg_core.cpp)
target_include_directories(mypkg_core PUBLIC
Expand Down Expand Up @@ -218,7 +215,7 @@ def package_info(self):
test_package_cmake = textwrap.dedent("""\
set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CXX_ABI_COMPILED 1)
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 4.3)
project(PackageTest CXX)

find_package(mypkg CONFIG REQUIRED)
Expand Down Expand Up @@ -297,8 +294,6 @@ def test(self):
@pytest.mark.tool("cmake", "4.3")
@pytest.mark.parametrize("kind", ["static_public", "static_private", "shared_private"])
def test_cps_components_requires(kind):
if kind == "shared_private" and platform.system() == "Linux":
pytest.skip("CPS still doesn't support this case")
c = TestClient()
conanfile = textwrap.dedent("""\
from conan import ConanFile
Expand Down Expand Up @@ -346,11 +341,9 @@ def package_info(self):
cmake = textwrap.dedent("""\
set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CXX_ABI_COMPILED 1)
cmake_minimum_required(VERSION 4.2)
cmake_minimum_required(VERSION 4.3)
project({name} LANGUAGES CXX VERSION 0.1)

set(CMAKE_EXPERIMENTAL_EXPORT_PACKAGE_INFO "b80be207-778e-46ba-8080-b23bba22639e")

{find}
# First library: core
add_library({name}_core src/{name}_core.cpp)
Expand Down Expand Up @@ -392,7 +385,7 @@ def package_info(self):
test_package_cmake = textwrap.dedent("""\
set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CXX_ABI_COMPILED 1)
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 4.3)
project(PackageTest CXX)

find_package({name} CONFIG REQUIRED)
Expand Down Expand Up @@ -553,11 +546,9 @@ def package_info(self):
cmake = textwrap.dedent("""\
set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CXX_ABI_COMPILED 1)
cmake_minimum_required(VERSION 4.2)
cmake_minimum_required(VERSION 4.3)
project(mypkg CXX)

set(CMAKE_EXPERIMENTAL_EXPORT_PACKAGE_INFO "b80be207-778e-46ba-8080-b23bba22639e")

add_library(mypkg src/mypkg.cpp)
target_include_directories(mypkg PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Expand Down Expand Up @@ -588,7 +579,7 @@ def package_info(self):
test_cmake = textwrap.dedent("""\
set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CXX_ABI_COMPILED 1)
cmake_minimum_required(VERSION 4.2)
cmake_minimum_required(VERSION 4.3)
project(PackageTest CXX)

find_package(potato CONFIG REQUIRED)
Expand Down
Loading