Skip to content

Commit 9a6866e

Browse files
authored
(#9365) gtsam: fix CMake imported targets + modernize
* modernize * bump dependencies also require onetbb instead of tbb recipe (deprecated) * relocatable shared libs on macOS * fix lib names
1 parent a00de66 commit 9a6866e

10 files changed

+292
-156
lines changed

recipes/gtsam/all/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 3.15)
22
project(cmake_wrapper)
33

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

77
add_subdirectory("source_subfolder")

recipes/gtsam/all/conandata.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
sources:
2-
"4.0.2":
3-
url: "https://github.com/borglab/gtsam/archive/4.0.2.tar.gz"
4-
sha256: "8770a440f1af98c3f0d9d4dffd568de2d4c21b245e7231e987e26bc236aeb5aa"
52
"4.0.3":
63
url: "https://github.com/borglab/gtsam/archive/4.0.3.tar.gz"
74
sha256: "eaa561749edf7a2d402981828253e28aed6c717dae35738301c5ab23e2595f25"
5+
"4.0.2":
6+
url: "https://github.com/borglab/gtsam/archive/4.0.2.tar.gz"
7+
sha256: "8770a440f1af98c3f0d9d4dffd568de2d4c21b245e7231e987e26bc236aeb5aa"
88
patches:
9+
"4.0.3":
10+
- patch_file: "patches/0001-conan-4.0.3.patch"
11+
base_path: "source_subfolder"
12+
- patch_file: "patches/0002-macos-rpath-4.0.3.patch"
13+
base_path: "source_subfolder"
914
"4.0.2":
10-
- patch_file: "patches/conan-4.0.2.patch"
15+
- patch_file: "patches/0001-conan-4.0.2.patch"
1116
base_path: "source_subfolder"
12-
"4.0.3":
13-
- patch_file: "patches/conan-4.0.3.patch"
17+
- patch_file: "patches/0002-macos-rpath-4.0.2.patch"
1418
base_path: "source_subfolder"

recipes/gtsam/all/conanfile.py

+204-137
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--- a/CMakeLists.txt
2+
+++ b/CMakeLists.txt
3+
@@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 3.0)
4+
# new feature to Cmake Version > 2.8.12
5+
# Mac ONLY. Define Relative Path on Mac OS
6+
if(NOT DEFINED CMAKE_MACOSX_RPATH)
7+
- set(CMAKE_MACOSX_RPATH 0)
8+
endif()
9+
10+
# Set the version number for the library
11+
--- a/gtsam/CMakeLists.txt
12+
+++ b/gtsam/CMakeLists.txt
13+
@@ -177,9 +177,6 @@ if(WIN32) # Add 'lib' prefix to static library to avoid filename collision with
14+
endif()
15+
16+
if (APPLE AND BUILD_SHARED_LIBS)
17+
- set_target_properties(gtsam PROPERTIES
18+
- INSTALL_NAME_DIR
19+
- "${CMAKE_INSTALL_PREFIX}/lib")
20+
endif()
21+
22+
install(
23+
--- a/gtsam/3rdparty/metis/libmetis/CMakeLists.txt
24+
+++ b/gtsam/3rdparty/metis/libmetis/CMakeLists.txt
25+
@@ -16,9 +16,6 @@ if(WIN32)
26+
endif()
27+
28+
if (APPLE)
29+
- set_target_properties(metis PROPERTIES
30+
- INSTALL_NAME_DIR
31+
- "${CMAKE_INSTALL_PREFIX}/lib")
32+
endif()
33+
34+
install(TARGETS metis EXPORT GTSAM-exports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--- a/CMakeLists.txt
2+
+++ b/CMakeLists.txt
3+
@@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 3.0)
4+
# new feature to Cmake Version > 2.8.12
5+
# Mac ONLY. Define Relative Path on Mac OS
6+
if(NOT DEFINED CMAKE_MACOSX_RPATH)
7+
- set(CMAKE_MACOSX_RPATH 0)
8+
endif()
9+
10+
# Set the version number for the library
11+
@@ -347,7 +346,6 @@ endif()
12+
13+
if (APPLE AND BUILD_SHARED_LIBS)
14+
# Set the default install directory on macOS
15+
- set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
16+
endif()
17+
18+
###############################################################################
19+
--- a/gtsam/3rdparty/metis/libmetis/CMakeLists.txt
20+
+++ b/gtsam/3rdparty/metis/libmetis/CMakeLists.txt
21+
@@ -16,9 +16,6 @@ if(WIN32)
22+
endif()
23+
24+
if (APPLE)
25+
- set_target_properties(metis-gtsam PROPERTIES
26+
- INSTALL_NAME_DIR
27+
- "${CMAKE_INSTALL_PREFIX}/lib")
28+
endif()
29+
30+
install(TARGETS metis-gtsam EXPORT GTSAM-exports
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
cmake_minimum_required(VERSION 3.0)
1+
cmake_minimum_required(VERSION 3.1)
22
project(test_package)
33

44
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
5-
conan_basic_setup()
5+
conan_basic_setup(TARGETS)
66

7-
add_executable(${PROJECT_NAME} test_package.cpp)
7+
find_package(GTSAM REQUIRED CONFIG)
88

9-
find_package(GTSAM REQUIRED)
10-
target_link_libraries(${PROJECT_NAME} GTSAM::gtsam)
9+
add_executable(${PROJECT_NAME} test_package.cpp)
10+
target_link_libraries(${PROJECT_NAME} gtsam)
1111
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
+6-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import os
21
from conans import ConanFile, CMake, tools
2+
import os
3+
34

4-
class gtsamTestConan(ConanFile):
5-
settings = "os", "compiler", "build_type", "arch"
6-
generators = "cmake", "cmake_find_package"
5+
class TestPackageConan(ConanFile):
6+
settings = "os", "arch", "compiler", "build_type"
7+
generators = "cmake", "cmake_find_package_multi"
78

89
def build(self):
910
cmake = CMake(self)
1011
cmake.configure()
1112
cmake.build()
1213

1314
def test(self):
14-
if not tools.cross_building(self.settings):
15+
if not tools.cross_building(self):
1516
bin_path = os.path.join("bin", "test_package")
1617
self.run(bin_path, run_environment=True)

recipes/gtsam/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
versions:
2-
"4.0.2":
3-
folder: all
42
"4.0.3":
53
folder: all
4+
"4.0.2":
5+
folder: all

0 commit comments

Comments
 (0)