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

octomap: relocatable shared libs on macOS #9143

Merged
merged 2 commits into from
Feb 3, 2022
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: 1 addition & 1 deletion recipes/octomap/all/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4.3)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()
conan_basic_setup(KEEP_RPATHS)

if(WIN32 AND BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
Expand Down
12 changes: 9 additions & 3 deletions recipes/octomap/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from conan.tools.microsoft import msvc_runtime_flag
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os
Expand Down Expand Up @@ -33,6 +34,10 @@ class OctomapConan(ConanFile):
def _source_subfolder(self):
return "source_subfolder"

@property
def _is_msvc(self):
return str(self.settings.compiler) in ["Visual Studio", "msvc"]

def export_sources(self):
self.copy("CMakeLists.txt")
for patch in self.conan_data.get("patches", {}).get(self.version, []):
Expand All @@ -47,9 +52,7 @@ def configure(self):
del self.options.fPIC

def validate(self):
if self.options.shared and \
((self.settings.compiler == "Visual Studio" and "MTd" in self.settings.compiler.runtime) or \
(str(self.settings.compiler) == "msvc" and self.settings.compiler.runtime == "static" and self.settings.compiler.runtime_type == "Debug")):
if self.options.shared and self._is_msvc and msvc_runtime_flag(self) == "MTd":
raise ConanInvalidConfiguration("shared octomap doesn't support MTd runtime")

def source(self):
Expand Down Expand Up @@ -82,6 +85,9 @@ def _patch_sources(self):
# No -Werror
if tools.Version(self.version) >= "1.9.6":
tools.replace_in_file(compiler_settings, "-Werror", "")
# we want a clean rpath in installed shared libs
tools.replace_in_file(compiler_settings, "set(CMAKE_INSTALL_RPATH \"${CMAKE_INSTALL_PREFIX}/lib\")", "")
tools.replace_in_file(compiler_settings, "set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)", "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in conan-io/hooks#376, you don't mention anything about CMAKE_INSTALL_RPATH/CMAKE_INSTALL_RPATH_UE_LINK_PATH. I think it should be explained why they have to be modified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Actually these 2 ones have to be left to their default value in CMake, otherwise it leads to hardcoded paths in RPATH of binaries in install tree.


def package(self):
self.copy("LICENSE.txt", dst="licenses", src=os.path.join(self._source_subfolder, "octomap"))
Expand Down