Skip to content

Commit

Permalink
(#9143) octomap: relocatable shared libs on macOS
Browse files Browse the repository at this point in the history
* simplify msvc checks

* relocatable shared libs on macOS
  • Loading branch information
SpaceIm authored Feb 3, 2022
1 parent e328b9a commit 6cc22b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
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)", "")

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

0 comments on commit 6cc22b3

Please sign in to comment.