Skip to content
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
116 changes: 116 additions & 0 deletions ports/yoctolib/001-cmake_config.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt
index 678fff5..f60b212 100644
--- a/Sources/CMakeLists.txt
+++ b/Sources/CMakeLists.txt
@@ -181,10 +181,41 @@ add_library (YoctoLib ${YoctoLibCppSources} ${YoctoLibHSources})

# add yapi low level api
add_subdirectory(yapi)
-target_link_libraries(YoctoLib PRIVATE yapi)
-target_include_directories (YoctoLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+target_link_libraries(YoctoLib PUBLIC yapi)
+target_include_directories (YoctoLib
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
set_target_properties(YoctoLib PROPERTIES SOVERSION 1)
set_target_properties(YoctoLib PROPERTIES LIBRARY_OUTPUT_NAME yocto)
-install(TARGETS YoctoLib DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${YoctoLibHSources} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES yapi/yapi.h yapi/ydef.h yapi/yversion.h yapi/yjson.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/yapi)
+
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/unofficial-yoctolib-version.cmake"
+ VERSION ${VERSION}
+ COMPATIBILITY SameMajorVersion
+)
+configure_package_config_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/unofficial-yoctolib-config.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/unofficial-yoctolib-config.cmake"
+ INSTALL_DESTINATION share/unofficial-yoctolib
+)
+install(TARGETS YoctoLib yapi
+ EXPORT YoctoLibTargets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+install(EXPORT YoctoLibTargets
+ FILE unofficial-yoctolib-targets.cmake
+ NAMESPACE unofficial::yoctolib::
+ DESTINATION share/unofficial-yoctolib
+)
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/unofficial-yoctolib-config.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/unofficial-yoctolib-version.cmake"
+ DESTINATION share/unofficial-yoctolib
+)
diff --git a/Sources/cmake/unofficial-yoctolib-config.cmake.in b/Sources/cmake/unofficial-yoctolib-config.cmake.in
new file mode 100644
index 0000000..6f442b2
--- /dev/null
+++ b/Sources/cmake/unofficial-yoctolib-config.cmake.in
@@ -0,0 +1,14 @@
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(THREADS_PREFER_PTHREAD_FLAG TRUE)
+ find_dependency(Threads)
+ find_dependency(PkgConfig)
+ pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
+endif()
+
+include(${CMAKE_CURRENT_LIST_DIR}/unofficial-yoctolib-targets.cmake)
+
+check_required_components(unofficial-yoctolib)
\ No newline at end of file
diff --git a/Sources/yapi/CMakeLists.txt b/Sources/yapi/CMakeLists.txt
index f6b571f..ca02890 100644
--- a/Sources/yapi/CMakeLists.txt
+++ b/Sources/yapi/CMakeLists.txt
@@ -139,11 +139,18 @@ if(USE_YSSL)
target_include_directories(yapi PRIVATE mbedtls/include)
endif()

-target_include_directories (yapi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(yapi PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/yapi>
+)

# add pthread usb-1.0 library only on linux
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
-target_link_libraries (yapi LINK_PUBLIC pthread usb-1.0)
+ set(THREADS_PREFER_PTHREAD_FLAG TRUE)
+ find_package(Threads REQUIRED)
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
+ target_link_libraries(yapi LINK_PUBLIC Threads::Threads PkgConfig::libusb)
endif()

if (APPLE)
@@ -159,7 +166,3 @@ if (APPLE)
endif()

set_target_properties(yapi PROPERTIES SOVERSION 1)
-install(TARGETS yapi DESTINATION ${CMAKE_INSTALL_LIBDIR})
-install(FILES yapi.h ydef.h yversion.h yjson.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/yapi)
-
-
diff --git a/Sources/yapi/yproto.h b/Sources/yapi/yproto.h
index 5fbadb3..ab0a801 100644
--- a/Sources/yapi/yproto.h
+++ b/Sources/yapi/yproto.h
@@ -163,7 +163,7 @@ typedef struct {
/*****************************************************************************
LINUX SPECIFIC HEADER
****************************************************************************/
-#include <libusb-1.0/libusb.h>
+#include <libusb.h>
#endif

/*****************************************************************************
14 changes: 14 additions & 0 deletions ports/yoctolib/002-add_missing_win32_bcrypt_linkage.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/Sources/yapi/CMakeLists.txt b/Sources/yapi/CMakeLists.txt
index da7102e..a06e04c 100644
--- a/Sources/yapi/CMakeLists.txt
+++ b/Sources/yapi/CMakeLists.txt
@@ -161,4 +161,8 @@ if (APPLE)
target_link_libraries(yapi LINK_PUBLIC ${IOKIT_FRAMEWORK} ${CORE_FRAMEWORK})
endif()

+if (WIN32)
+ target_link_libraries(yapi PRIVATE bcrypt)
+endif()
+
set_target_properties(yapi PROPERTIES SOVERSION 1)
\ No newline at end of file
39 changes: 39 additions & 0 deletions ports/yoctolib/003-fix_win32_shared_build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt
index 33af30d..2c0d1c5 100644
--- a/Sources/CMakeLists.txt
+++ b/Sources/CMakeLists.txt
@@ -178,14 +178,19 @@ set(YoctoLibCppSources
)

add_library (YoctoLib ${YoctoLibCppSources} ${YoctoLibHSources})
+if(WIN32 AND BUILD_SHARED_LIBS)
+ target_compile_definitions(YoctoLib PRIVATE GENERATE_DLL)
+endif()

# add yapi low level api
add_subdirectory(yapi)
-target_link_libraries(YoctoLib PUBLIC yapi)
-target_include_directories (YoctoLib
+target_link_libraries(YoctoLib PRIVATE yapi)
+target_include_directories(YoctoLib
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/yapi>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/yapi>
)
set_target_properties(YoctoLib PROPERTIES SOVERSION 1)
set_target_properties(YoctoLib PROPERTIES LIBRARY_OUTPUT_NAME yocto)
diff --git a/Sources/yapi/CMakeLists.txt b/Sources/yapi/CMakeLists.txt
index f825a5c..28a7669 100644
--- a/Sources/yapi/CMakeLists.txt
+++ b/Sources/yapi/CMakeLists.txt
@@ -134,7 +134,7 @@ set(YAPI_C_FILES
yssl.c
)

-add_library (yapi ${YAPI_C_FILES} ${MBEDTLS_C_FILES})
+add_library (yapi STATIC ${YAPI_C_FILES} ${MBEDTLS_C_FILES})
if(USE_YSSL)
target_include_directories(yapi PRIVATE mbedtls/include)
endif()
33 changes: 33 additions & 0 deletions ports/yoctolib/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO yoctopuce/yoctolib_cpp
REF "v${VERSION}"
SHA512 c57baae00289dc2bbcabe278d9ff5667077bd3b93fadd20fd9de4428050af0bb6a659849b52e5c93b3e51c6d71764839c0d299e775d4133f85fa31990242077e
HEAD_REF master
PATCHES
001-cmake_config.patch
002-add_missing_win32_bcrypt_linkage.patch
003-fix_win32_shared_build.patch
)

if(VCPKG_TARGET_IS_LINUX)
vcpkg_find_acquire_program(PKGCONFIG)
set(ENV{PKG_CONFIG} "${PKGCONFIG}")
endif()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}/Sources"
OPTIONS
-DVERSION=${VERSION}
-DCMAKE_INSTALL_INCLUDEDIR=include/yoctolib
-DUSE_YSSL=OFF
)
vcpkg_cmake_install()

vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-yoctolib)
vcpkg_copy_pdbs()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/README.md")
22 changes: 22 additions & 0 deletions ports/yoctolib/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "yoctolib",
"version": "2.1.6320",
"description": "Official Yoctopuce Library for C++",
"homepage": "https://github.com/yoctopuce/yoctolib_cpp",
"license": null,
"supports": "!(uwp | android)",
"dependencies": [
{
"name": "libusb",
"platform": "!(windows | osx)"
},
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -10860,6 +10860,10 @@
"baseline": "2022-03-06",
"port-version": 0
},
"yoctolib": {
"baseline": "2.1.6320",
"port-version": 0
},
"yoga": {
"baseline": "3.2.1",
"port-version": 0
Expand Down
9 changes: 9 additions & 0 deletions versions/y-/yoctolib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "a068fe63550863e24dc9cfd6e55ebd8e8fd7c742",
"version": "2.1.6320",
"port-version": 0
}
]
}