Skip to content

Commit 0bc50c0

Browse files
authored
[apriltag] New port added (microsoft#36336)
Signed-off-by: Vitalii Koshura <[email protected]>
1 parent fd675b7 commit 0bc50c0

File tree

6 files changed

+136
-0
lines changed

6 files changed

+136
-0
lines changed

ports/apriltag/fix-config.patch

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 72c3ad6..607d024 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -1,4 +1,4 @@
6+
-cmake_minimum_required(VERSION 3.1)
7+
+cmake_minimum_required(VERSION 3.5)
8+
project(apriltag VERSION 3.2.0 LANGUAGES C CXX)
9+
10+
if(POLICY CMP0077)
11+
@@ -39,6 +39,9 @@ endif()
12+
aux_source_directory(common COMMON_SRC)
13+
set(APRILTAG_SRCS apriltag.c apriltag_pose.c apriltag_quad_thresh.c)
14+
15+
+if (MSVC)
16+
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
17+
+endif()
18+
# Library
19+
file(GLOB TAG_FILES ${PROJECT_SOURCE_DIR}/tag*.c)
20+
add_library(${PROJECT_NAME} ${APRILTAG_SRCS} ${COMMON_SRC} ${TAG_FILES})
21+
@@ -46,8 +49,8 @@ add_library(${PROJECT_NAME} ${APRILTAG_SRCS} ${COMMON_SRC} ${TAG_FILES})
22+
if (MSVC)
23+
# FindThreads will not find pthread.h with MSVC
24+
# winmm is necessary for __imp_timeGetTime
25+
- find_library(PTHREAD_LIBRARIES NAMES pthreads)
26+
- target_link_libraries(${PROJECT_NAME} ${PTHREAD_LIBRARIES} winmm)
27+
+ find_package(PThreads4W REQUIRED)
28+
+ target_link_libraries(${PROJECT_NAME} PThreads4W::PThreads4W winmm)
29+
else()
30+
find_package(Threads REQUIRED)
31+
target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads m)
32+
@@ -101,6 +104,7 @@ write_basic_package_version_file("${version_config}" COMPATIBILITY SameMajorVers
33+
install(TARGETS ${PROJECT_NAME} EXPORT ${targets_export_name}
34+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
35+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
36+
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
37+
)
38+
39+
install(EXPORT ${targets_export_name}
40+
@@ -123,7 +127,7 @@ install(FILES "${PROJECT_BINARY_DIR}/apriltag.pc" DESTINATION "${CMAKE_INSTALL_L
41+
42+
# Python wrapper
43+
include(CMakeDependentOption)
44+
-cmake_dependent_option(BUILD_PYTHON_WRAPPER "Builds Python wrapper" ON BUILD_SHARED_LIBS OFF)
45+
+option(BUILD_PYTHON_WRAPPER "Builds Python wrapper" OFF)
46+
47+
if(BUILD_PYTHON_WRAPPER)
48+
SET(Python_ADDITIONAL_VERSIONS 3)
49+
@@ -160,7 +164,7 @@ string(STRIP ${PY_DEST} PY_DEST)
50+
install(FILES ${PROJECT_BINARY_DIR}/apriltag${PY_EXT_SUFFIX} DESTINATION ${PY_DEST})
51+
endif (NOT Python3_NOT_FOUND AND NOT Numpy_NOT_FOUND AND PYTHONLIBS_FOUND AND BUILD_PYTHON_WRAPPER)
52+
53+
-
54+
+if(0)
55+
# Examples
56+
# apriltag_demo
57+
add_executable(apriltag_demo example/apriltag_demo.c)
58+
@@ -179,3 +183,4 @@ endif(OpenCV_FOUND)
59+
60+
# install example programs
61+
install(TARGETS apriltag_demo RUNTIME DESTINATION bin)
62+
+endif()

ports/apriltag/portfile.cmake

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
if (VCPKG_TARGET_IS_WINDOWS)
2+
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
3+
endif()
4+
5+
vcpkg_from_github(
6+
OUT_SOURCE_PATH SOURCE_PATH
7+
REPO AprilRobotics/apriltag
8+
REF v${VERSION}
9+
SHA512 0b09b530ed03dce0bdc3c4e08b17d98f1303ab1d45870843354bf1a5bdf6c7efc6089e2bdf40a370d17a8191b7ce2c46fefa2dd2d49a959591351e00e186f33e
10+
HEAD_REF master
11+
PATCHES
12+
fix-config.patch
13+
)
14+
15+
vcpkg_cmake_configure(
16+
SOURCE_PATH "${SOURCE_PATH}"
17+
)
18+
19+
vcpkg_cmake_install()
20+
21+
vcpkg_copy_pdbs()
22+
23+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
24+
25+
vcpkg_cmake_config_fixup(CONFIG_PATH share/${PORT}/cmake)
26+
vcpkg_fixup_pkgconfig()
27+
28+
if (VCPKG_TARGET_IS_WINDOWS)
29+
file(READ "${CURRENT_PACKAGES_DIR}/share/${PORT}/${PORT}Config.cmake" FIXED_CONFIG)
30+
file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/${PORT}Config.cmake" "
31+
include(CMakeFindDependencyMacro)
32+
find_dependency(PThreads4W)
33+
${FIXED_CONFIG}
34+
")
35+
endif()
36+
37+
file(INSTALL "${SOURCE_PATH}/LICENSE.md" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
38+
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

ports/apriltag/usage

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The package apriltag is compatible with built-in CMake targets:
2+
3+
find_package(apriltag REQUIRED)
4+
target_link_libraries(main PRIVATE apriltag::apriltag)

ports/apriltag/vcpkg.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "apriltag",
3+
"version": "3.2.0",
4+
"description": "AprilTag is a visual fiducial system popular for robotics research.",
5+
"homepage": "https://april.eecs.umich.edu/software/apriltag",
6+
"license": "BSD-2-Clause",
7+
"supports": "!uwp",
8+
"dependencies": [
9+
"pthreads",
10+
{
11+
"name": "vcpkg-cmake",
12+
"host": true
13+
},
14+
{
15+
"name": "vcpkg-cmake-config",
16+
"host": true
17+
}
18+
]
19+
}

versions/a-/apriltag.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"versions": [
3+
{
4+
"git-tree": "3523f2ad6198164afda1782327470188dc3f7221",
5+
"version": "3.2.0",
6+
"port-version": 0
7+
}
8+
]
9+
}

versions/baseline.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@
172172
"baseline": "1.6.3",
173173
"port-version": 0
174174
},
175+
"apriltag": {
176+
"baseline": "3.2.0",
177+
"port-version": 0
178+
},
175179
"apsi": {
176180
"baseline": "0.11.0",
177181
"port-version": 0

0 commit comments

Comments
 (0)