-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[yoctolib] new port #48871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[yoctolib] new port #48871
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
2274a34
add port
nickdademo 196bfdf
v db
nickdademo 20ce242
add patch
nickdademo a7e5b0f
v db
nickdademo 04d2e01
adjust patch
nickdademo f4aff56
v db
nickdademo b5d121a
adjust patch to fix include
nickdademo 8578b80
v db
nickdademo ddbcc87
static only test
nickdademo 22ee127
v db
nickdademo b50b39c
adjust supports
nickdademo 4a5de26
v db
nickdademo 496d9b7
don't support android
nickdademo 80e1417
v db
nickdademo 7ea5911
try shared build
nickdademo b186548
v db
nickdademo 3adfcfa
better pkgconfig handling
nickdademo ca09622
unix line endings
nickdademo 211c110
v db
nickdademo 7f2c844
remove ssl feature
nickdademo d4ef34b
v db
nickdademo 58d5229
copy pdbs
nickdademo ec076e8
v db
nickdademo e915087
apply suggestions
nickdademo 1b7ad6e
v db
nickdademo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt | ||
| index 678fff5..2684a6c 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}/YoctoLibConfigVersion.cmake" | ||
| + VERSION ${PROJECT_VERSION} | ||
| + COMPATIBILITY SameMajorVersion | ||
| +) | ||
| +configure_package_config_file( | ||
| + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/YoctoLibConfig.cmake.in" | ||
| + "${CMAKE_CURRENT_BINARY_DIR}/YoctoLibConfig.cmake" | ||
| + INSTALL_DESTINATION share/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 YoctoLibTargets.cmake | ||
| + NAMESPACE YoctoLib:: | ||
|
nickdademo marked this conversation as resolved.
Outdated
|
||
| + DESTINATION share/YoctoLib | ||
| +) | ||
| +install(FILES | ||
| + "${CMAKE_CURRENT_BINARY_DIR}/YoctoLibConfig.cmake" | ||
| + "${CMAKE_CURRENT_BINARY_DIR}/YoctoLibConfigVersion.cmake" | ||
| + DESTINATION share/YoctoLib | ||
| +) | ||
| \ No newline at end of file | ||
| diff --git a/Sources/cmake/YoctoLibConfig.cmake.in b/Sources/cmake/YoctoLibConfig.cmake.in | ||
| new file mode 100644 | ||
| index 0000000..f7d558a | ||
| --- /dev/null | ||
| +++ b/Sources/cmake/YoctoLibConfig.cmake.in | ||
| @@ -0,0 +1,13 @@ | ||
| +@PACKAGE_INIT@ | ||
| + | ||
| +include(CMakeFindDependencyMacro) | ||
| + | ||
| +# Find platform-specific dependencies | ||
| +if(CMAKE_SYSTEM_NAME STREQUAL Linux) | ||
|
nickdademo marked this conversation as resolved.
Outdated
|
||
| + find_dependency(Threads REQUIRED) | ||
| + find_dependency(libusb REQUIRED) | ||
| +endif() | ||
| + | ||
| +include(${CMAKE_CURRENT_LIST_DIR}/YoctoLibTargets.cmake) | ||
| + | ||
| +check_required_components(YoctoLib) | ||
| \ No newline at end of file | ||
| diff --git a/Sources/yapi/CMakeLists.txt b/Sources/yapi/CMakeLists.txt | ||
| index f6b571f..da7102e 100644 | ||
| --- a/Sources/yapi/CMakeLists.txt | ||
| +++ b/Sources/yapi/CMakeLists.txt | ||
| @@ -139,7 +139,10 @@ 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") | ||
| @@ -158,8 +161,4 @@ if (APPLE) | ||
| target_link_libraries(yapi LINK_PUBLIC ${IOKIT_FRAMEWORK} ${CORE_FRAMEWORK}) | ||
| 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) | ||
| - | ||
| - | ||
| +set_target_properties(yapi PROPERTIES SOVERSION 1) | ||
| \ No newline at end of file | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.lib) | ||
|
nickdademo marked this conversation as resolved.
Outdated
|
||
| +endif() | ||
| + | ||
| set_target_properties(yapi PROPERTIES SOVERSION 1) | ||
| \ No newline at end of file | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,68 @@ | ||||||||
| diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt | ||||||||
| index 2684a6c..96886bd 100644 | ||||||||
| --- a/Sources/CMakeLists.txt | ||||||||
| +++ b/Sources/CMakeLists.txt | ||||||||
| @@ -181,12 +181,21 @@ add_library (YoctoLib ${YoctoLibCppSources} ${YoctoLibHSources}) | ||||||||
|
|
||||||||
| # add yapi low level api | ||||||||
| add_subdirectory(yapi) | ||||||||
| -target_link_libraries(YoctoLib PUBLIC yapi) | ||||||||
| +if(BUILD_SHARED_LIBS) | ||||||||
| + target_link_libraries(YoctoLib PRIVATE yapi) | ||||||||
| +else() | ||||||||
| + target_link_libraries(YoctoLib PUBLIC yapi) | ||||||||
| +endif() | ||||||||
|
nickdademo marked this conversation as resolved.
Outdated
|
||||||||
| 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> | ||||||||
| ) | ||||||||
| +if(WIN32 AND BUILD_SHARED_LIBS) | ||||||||
| + target_compile_definitions(YoctoLib PRIVATE GENERATE_DLL) | ||||||||
| +endif() | ||||||||
| set_target_properties(YoctoLib PROPERTIES SOVERSION 1) | ||||||||
| set_target_properties(YoctoLib PROPERTIES LIBRARY_OUTPUT_NAME yocto) | ||||||||
| install(FILES ${YoctoLibHSources} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||||||||
| @@ -203,12 +212,21 @@ configure_package_config_file( | ||||||||
| "${CMAKE_CURRENT_BINARY_DIR}/YoctoLibConfig.cmake" | ||||||||
| INSTALL_DESTINATION share/YoctoLib | ||||||||
| ) | ||||||||
| -install(TARGETS YoctoLib yapi | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of duplication the install command, use a variable
Suggested change
(or just export yapi?) |
||||||||
| - EXPORT YoctoLibTargets | ||||||||
| - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||||||||
| - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||||||||
| - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||||||||
| -) | ||||||||
| +if(BUILD_SHARED_LIBS) | ||||||||
| + install(TARGETS YoctoLib | ||||||||
| + EXPORT YoctoLibTargets | ||||||||
| + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||||||||
| + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||||||||
| + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||||||||
| + ) | ||||||||
| +else() | ||||||||
| + install(TARGETS YoctoLib yapi | ||||||||
| + EXPORT YoctoLibTargets | ||||||||
| + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||||||||
| + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||||||||
| + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||||||||
| + ) | ||||||||
| +endif() | ||||||||
| install(EXPORT YoctoLibTargets | ||||||||
| FILE YoctoLibTargets.cmake | ||||||||
| NAMESPACE YoctoLib:: | ||||||||
| diff --git a/Sources/yapi/CMakeLists.txt b/Sources/yapi/CMakeLists.txt | ||||||||
| index a06e04c..4ff6314 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}) | ||||||||
|
Comment on lines
+35
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this is where you make yapi something different from upstream. |
||||||||
| if(USE_YSSL) | ||||||||
| target_include_directories(yapi PRIVATE mbedtls/include) | ||||||||
| endif() | ||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt | ||
| index 96886bd..a004a21 100644 | ||
| --- a/Sources/CMakeLists.txt | ||
| +++ b/Sources/CMakeLists.txt | ||
| @@ -2,7 +2,7 @@ | ||
| cmake_minimum_required(VERSION 3.8) | ||
|
|
||
|
|
||
| -project(YoctoLib VERSION 1.0.1 DESCRIPTION "Yoctopuce C++ V2 library") | ||
| +project(YoctoLib VERSION 2.1.6320 DESCRIPTION "Yoctopuce C++ V2 library") | ||
|
nickdademo marked this conversation as resolved.
Outdated
|
||
| if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | ||
| SET(CMAKE_INSTALL_PREFIX "/usr") | ||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| diff --git a/Sources/yapi/CMakeLists.txt b/Sources/yapi/CMakeLists.txt | ||
| index 4ff6314..721379a 100644 | ||
| --- a/Sources/yapi/CMakeLists.txt | ||
| +++ b/Sources/yapi/CMakeLists.txt | ||
| @@ -146,7 +146,11 @@ target_include_directories(yapi PUBLIC | ||
|
|
||
| # 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) | ||
|
nickdademo marked this conversation as resolved.
Outdated
|
||
| endif() | ||
|
|
||
| if (APPLE) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| 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 | ||
| 004-fix_cmake_proj_version.patch | ||
| 005-find_linux_depends.patch | ||
| ) | ||
|
|
||
| string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED) | ||
|
|
||
|
nickdademo marked this conversation as resolved.
Outdated
|
||
| vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS | ||
| FEATURES | ||
| ssl USE_YSSL | ||
| ) | ||
|
|
||
| vcpkg_find_acquire_program(PKGCONFIG) | ||
| vcpkg_cmake_configure( | ||
| SOURCE_PATH "${SOURCE_PATH}/Sources" | ||
| OPTIONS | ||
| ${FEATURE_OPTIONS} | ||
| -DBUILD_SHARED_LIBS=${BUILD_SHARED} | ||
|
nickdademo marked this conversation as resolved.
Outdated
|
||
| -DCMAKE_INSTALL_INCLUDEDIR=include/yoctolib | ||
| "-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}" | ||
| ) | ||
| vcpkg_cmake_install() | ||
|
|
||
| vcpkg_cmake_config_fixup() | ||
|
|
||
| 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") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "name": "yoctolib", | ||
| "version": "2.1.6320", | ||
| "description": "Official Yoctopuce Library for C++", | ||
| "homepage": "https://github.com/yoctopuce/yoctolib_cpp", | ||
| "license": null, | ||
| "dependencies": [ | ||
| { | ||
| "name": "libusb", | ||
| "platform": "linux" | ||
| }, | ||
| { | ||
| "name": "vcpkg-cmake", | ||
| "host": true | ||
| }, | ||
| { | ||
| "name": "vcpkg-cmake-config", | ||
| "host": true | ||
| } | ||
| ], | ||
| "features": { | ||
| "ssl": { | ||
| "description": "Enable SSL/TLS support" | ||
| } | ||
|
nickdademo marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "versions": [ | ||
| { | ||
| "git-tree": "c0dcf7e1757311817997315ce1ccceae83dba901", | ||
| "version": "2.1.6320", | ||
| "port-version": 0 | ||
| } | ||
| ] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.