Skip to content

Commit 6cc22b3

Browse files
authored
(#9143) octomap: relocatable shared libs on macOS
* simplify msvc checks * relocatable shared libs on macOS
1 parent e328b9a commit 6cc22b3

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

recipes/octomap/all/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4.3)
22
project(cmake_wrapper)
33

44
include(conanbuildinfo.cmake)
5-
conan_basic_setup()
5+
conan_basic_setup(KEEP_RPATHS)
66

77
if(WIN32 AND BUILD_SHARED_LIBS)
88
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

recipes/octomap/all/conanfile.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from conan.tools.microsoft import msvc_runtime_flag
12
from conans import ConanFile, CMake, tools
23
from conans.errors import ConanInvalidConfiguration
34
import os
@@ -33,6 +34,10 @@ class OctomapConan(ConanFile):
3334
def _source_subfolder(self):
3435
return "source_subfolder"
3536

37+
@property
38+
def _is_msvc(self):
39+
return str(self.settings.compiler) in ["Visual Studio", "msvc"]
40+
3641
def export_sources(self):
3742
self.copy("CMakeLists.txt")
3843
for patch in self.conan_data.get("patches", {}).get(self.version, []):
@@ -47,9 +52,7 @@ def configure(self):
4752
del self.options.fPIC
4853

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

5558
def source(self):
@@ -82,6 +85,9 @@ def _patch_sources(self):
8285
# No -Werror
8386
if tools.Version(self.version) >= "1.9.6":
8487
tools.replace_in_file(compiler_settings, "-Werror", "")
88+
# we want a clean rpath in installed shared libs
89+
tools.replace_in_file(compiler_settings, "set(CMAKE_INSTALL_RPATH \"${CMAKE_INSTALL_PREFIX}/lib\")", "")
90+
tools.replace_in_file(compiler_settings, "set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)", "")
8591

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

0 commit comments

Comments
 (0)