Skip to content

Commit

Permalink
openssl/3.x.x: port conan-io#4772 fix builddirs and add vars module t…
Browse files Browse the repository at this point in the history
…o cmake_find_package only

Co-Authored-By: SpaceIm <[email protected]>
  • Loading branch information
Croydon and SpaceIm committed Sep 9, 2021
1 parent 0767f32 commit 5e682da
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions recipes/openssl/3.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,12 +587,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 @@ -619,26 +619,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.names["pkg_config"] = "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 ""
self.cpp_info.components["ssl"].libs = ["libssl" + libsuffix]
Expand Down

0 comments on commit 5e682da

Please sign in to comment.