Skip to content

Instantly share code, notes, and snippets.

@uilianries
Created March 3, 2022 17:42
Show Gist options
  • Save uilianries/f3deab6dfb2e37e6068ab261feb51708 to your computer and use it in GitHub Desktop.
Save uilianries/f3deab6dfb2e37e6068ab261feb51708 to your computer and use it in GitHub Desktop.
Conan - Export cmake targets correctly
from conans import ConanFile
class FoobarConan(ConanFile):
def package_info(self):
self.cpp_info.filenames["cmake_find_package"] = "FooBar"
self.cpp_info.filenames["cmake_find_package_multi"] = "FooBar"
self.cpp_info.names["cmake_find_package"] = "Foo"
self.cpp_info.names["cmake_find_package_multi"] = "Foo"
self.cpp_info.components["Foo"].libs = ["foobar"]
self.cpp_info.components["Foo"].names["cmake_find_package"] = "Foobar"
self.cpp_info.components["Foo"].names["cmake_find_package_multi"] = "bar"
self.cpp_info.set_property("cmake_file_name", "FooBar")
self.cpp_info.set_property("cmake_target_name", "FooBar")
self.cpp_info.set_property("cmake_module_target_name", "Foo::bar")
self.cpp_info.libs = ["foobar"]
# FooBarConfig.cmake -> Foo::bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment