Skip to content

Commit

Permalink
fix builddirs and add vars module to cmake_find_package only (#4772)
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceIm authored Mar 8, 2021
1 parent 8aed0f0 commit 9faa1f8
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions recipes/openssl/1.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from conans.errors import ConanInvalidConfiguration
from conans import ConanFile, AutoToolsBuildEnvironment, tools

required_conan_version = ">=1.33.0"


@total_ordering
class OpenSSLVersion(object):
Expand Down Expand Up @@ -765,12 +767,12 @@ def package(self):
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))

self._create_cmake_module_variables(
os.path.join(self.package_folder, self._module_subfolder, self._module_file)
os.path.join(self.package_folder, self._module_file_rel_path)
)

@staticmethod
def _create_cmake_module_variables(module_file):
content = """\
content = textwrap.dedent("""\
if(DEFINED OpenSSL_FOUND)
set(OPENSSL_FOUND ${OpenSSL_FOUND})
endif()
Expand All @@ -797,25 +799,25 @@ def _create_cmake_module_variables(module_file):
if(DEFINED OpenSSL_VERSION)
set(OPENSSL_VERSION ${OpenSSL_VERSION})
endif()
"""
content = textwrap.dedent(content)
""")
tools.save(module_file, content)

@property
def _module_subfolder(self):
return os.path.join("lib", "cmake")

@property
def _module_file(self):
return "conan-official-{}-variables.cmake".format(self.name)
def _module_file_rel_path(self):
return os.path.join(self._module_subfolder,
"conan-official-{}-variables.cmake".format(self.name))

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "OpenSSL"
self.cpp_info.names["cmake_find_package_multi"] = "OpenSSL"
self.cpp_info.components["ssl"].builddirs = [self._module_subfolder]
self.cpp_info.components["ssl"].build_modules = [os.path.join(self._module_subfolder, self._module_file)]
self.cpp_info.components["crypto"].builddirs = [self._module_subfolder]
self.cpp_info.components["crypto"].build_modules = [os.path.join(self._module_subfolder, self._module_file)]
self.cpp_info.components["ssl"].builddirs.append(self._module_subfolder)
self.cpp_info.components["ssl"].build_modules["cmake_find_package"] = [self._module_file_rel_path]
self.cpp_info.components["crypto"].builddirs.append(self._module_subfolder)
self.cpp_info.components["crypto"].build_modules["cmake_find_package"] = [self._module_file_rel_path]
if self._use_nmake:
libsuffix = "d" if self.settings.build_type == "Debug" else ""
if self._full_version < "1.1.0":
Expand Down

0 comments on commit 9faa1f8

Please sign in to comment.