-
Notifications
You must be signed in to change notification settings - Fork 0
[SBC-4238] Windows Example #28
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
Open
stedra-apryse
wants to merge
5
commits into
main
Choose a base branch
from
sd/windows
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+237
−86
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a70cb67
update C wrapper for windows
stedra-apryse 8660b09
update readme
stedra-apryse 7b12de4
downgrade to cmake 3.10
stedra-apryse 93c8b65
C project readme updated for Windows
stedra-apryse 3b9640c
remove mentions of wget
stedra-apryse 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 |
|---|---|---|
| @@ -1,17 +1,25 @@ | ||
| # 3.10 is the version shipped with Ubuntu 18.04, which is the base of NVIDIA JetPack 4.6. | ||
| cmake_minimum_required(VERSION 3.10) | ||
| project(scanbotsdk_c_example C) | ||
| set(CMAKE_C_STANDARD 99) | ||
|
|
||
| # Find or download Scanbot SDK | ||
| if(NOT SCANBOTSDK_VERSION) | ||
| message(FATAL_ERROR "SCANBOTSDK_VERSION is not set.") | ||
| set(SCANBOTSDK_VERSION "9.0.0") | ||
| endif() | ||
| set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") | ||
| set(SCANBOTSDK_DIR "${CMAKE_CURRENT_BINARY_DIR}/scanbotsdk") | ||
| set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) | ||
| find_package(ScanbotSDK REQUIRED) | ||
|
|
||
| file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c) | ||
| file(GLOB_RECURSE SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c") | ||
| add_executable(scanbotsdk_example ${SOURCE_FILES}) | ||
| target_include_directories(scanbotsdk_example PRIVATE include) | ||
| target_link_libraries(scanbotsdk_example PRIVATE scanbotsdk) | ||
| target_link_libraries(scanbotsdk_example PRIVATE ScanbotSDK::ScanbotSDK) | ||
|
|
||
| if(WIN32) | ||
| add_custom_command(TARGET scanbotsdk_example POST_BUILD | ||
|
kyrylo-volkov-apryse marked this conversation as resolved.
|
||
| COMMAND "${CMAKE_COMMAND}" -E copy_if_different | ||
| "$<TARGET_FILE:ScanbotSDK::ScanbotSDK>" | ||
| "$<TARGET_FILE_DIR:scanbotsdk_example>" | ||
| ) | ||
| 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
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 @@ | ||
| # Download.cmake | ||
| if(NOT URL OR NOT DEST) | ||
| message(FATAL_ERROR "Both URL and DEST variables must be defined.") | ||
| endif() | ||
|
|
||
| file(DOWNLOAD "${URL}" "${DEST}" | ||
| STATUS status | ||
| TLS_VERIFY ON | ||
| ) | ||
|
|
||
| list(GET status 0 status_code) | ||
| list(GET status 1 status_string) | ||
|
|
||
| if(NOT status_code EQUAL 0) | ||
| file(REMOVE "${DEST}") | ||
| message(FATAL_ERROR "Download failed (${status_code}): ${status_string}") | ||
| 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 |
|---|---|---|
| @@ -1,47 +1,107 @@ | ||
| include(ExternalProject) | ||
| include(FindPackageHandleStandardArgs) | ||
|
|
||
| if(NOT SCANBOTSDK_DIR) | ||
| message(FATAL_ERROR "SCANBOTSDK_DIR not set") | ||
| if(TARGET ScanbotSDK::ScanbotSDK) | ||
| return() | ||
| endif() | ||
|
|
||
| if (NOT EXISTS ${SCANBOTSDK_DIR}) | ||
| if(NOT DEFINED SCANBOTSDK_VERSION) | ||
| message(FATAL_ERROR "SCANBOTSDK_VERSION is not set.") | ||
| endif() | ||
|
|
||
| if(NOT DEFINED SCANBOTSDK_DIR) | ||
| set(SCANBOTSDK_DIR "${CMAKE_CURRENT_BINARY_DIR}") | ||
| endif() | ||
|
|
||
| if(NOT EXISTS "${SCANBOTSDK_DIR}/scanbotsdk") | ||
| if(CMAKE_SYSTEM_NAME STREQUAL "Windows") | ||
| if(CMAKE_SIZEOF_VOID_P EQUAL 4) | ||
| set(SCANBOTSDK_TARGET "windows-x86") | ||
| else() | ||
| set(SCANBOTSDK_TARGET "windows-x64") | ||
| endif() | ||
| elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||
| if(CMAKE_SYSTEM_PROCESSOR MATCHES ".*arm.*" OR CMAKE_SYSTEM_PROCESSOR MATCHES ".*aarch64.*") | ||
| set(SCANBOTSDK_TARGET "linux-aarch64") | ||
| else() | ||
| set(SCANBOTSDK_TARGET "linux-x86_64") | ||
| endif() | ||
| else() | ||
| message(FATAL_ERROR "System ${CMAKE_SYSTEM_NAME} not supported") | ||
| endif() | ||
|
|
||
| find_program(WGET_PATH wget REQUIRED) | ||
| set(_archive "${SCANBOTSDK_DIR}/scanbotsdk-${SCANBOTSDK_VERSION}-${SCANBOTSDK_TARGET}.tar.gz") | ||
|
kyrylo-volkov-apryse marked this conversation as resolved.
|
||
| set(_url "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv${SCANBOTSDK_VERSION}/scanbotsdk-${SCANBOTSDK_VERSION}-${SCANBOTSDK_TARGET}.tar.gz") | ||
|
|
||
| message(STATUS "Downloading ScanbotSDK ${SCANBOTSDK_VERSION} to ${SCANBOTSDK_DIR}") | ||
| file(MAKE_DIRECTORY "${SCANBOTSDK_DIR}") | ||
|
|
||
| if ("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES ".*arm.*" OR "${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES ".*aarch64.*") | ||
| set(SCANBOTSDK_ARCHITECTURE "aarch64") | ||
| else () | ||
| set(SCANBOTSDK_ARCHITECTURE "x86_64") | ||
| endif () | ||
| string(TOLOWER "${CMAKE_HOST_SYSTEM_NAME}-${SCANBOTSDK_ARCHITECTURE}" PLATFORM_ID) | ||
| set(URL "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv${SCANBOTSDK_VERSION}/scanbotsdk-${SCANBOTSDK_VERSION}-linux-${SCANBOTSDK_ARCHITECTURE}.tar.gz") | ||
| execute_process( | ||
| COMMAND ${WGET_PATH} "${URL}" | ||
| WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
| COMMAND "${CMAKE_COMMAND}" | ||
| "-DURL=${_url}" | ||
| "-DDEST=${_archive}" | ||
| -P "${CMAKE_CURRENT_LIST_DIR}/Download.cmake" | ||
| RESULT_VARIABLE _rc | ||
| ) | ||
| if(NOT _rc EQUAL 0) | ||
| file(REMOVE "${_archive}") | ||
| message(FATAL_ERROR "Failed to download Scanbot SDK from ${_url}") | ||
| endif() | ||
|
|
||
| execute_process( | ||
| COMMAND tar -xf scanbotsdk-${SCANBOTSDK_VERSION}-${PLATFORM_ID}.tar.gz | ||
| WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
| COMMAND "${CMAKE_COMMAND}" -E tar -xf "${_archive}" | ||
| WORKING_DIRECTORY "${SCANBOTSDK_DIR}" | ||
| RESULT_VARIABLE _rc | ||
| ) | ||
| if(NOT _rc EQUAL 0) | ||
| file(REMOVE "${_archive}") | ||
| file(REMOVE_RECURSE "${SCANBOTSDK_DIR}/scanbotsdk") | ||
| message(FATAL_ERROR "Failed to extract Scanbot SDK archive ${_archive}") | ||
| endif() | ||
|
|
||
| file(REMOVE "${_archive}") | ||
| endif() | ||
|
|
||
| find_library(ScanbotSDK_LIBS | ||
| NAMES libscanbotsdk.so | ||
| HINTS ${SCANBOTSDK_DIR}/lib/ | ||
| ) | ||
| NAMES scanbotsdk | ||
| PATHS "${SCANBOTSDK_DIR}/scanbotsdk/lib" | ||
| NO_DEFAULT_PATH | ||
| ) | ||
|
|
||
| find_path(ScanbotSDK_INCLUDE_DIRS | ||
| NAMES ScanbotSDK.h | ||
| HINTS ${SCANBOTSDK_DIR}/include/) | ||
| PATHS "${SCANBOTSDK_DIR}/scanbotsdk/include" | ||
| NO_DEFAULT_PATH | ||
| ) | ||
|
|
||
| set(SCANBOTSDK_REQUIRED_VARS ScanbotSDK_LIBS ScanbotSDK_INCLUDE_DIRS) | ||
|
|
||
| if(WIN32) | ||
| find_file(ScanbotSDK_DLL | ||
| NAMES scanbotsdk.dll | ||
| PATHS "${SCANBOTSDK_DIR}/scanbotsdk/lib" | ||
| NO_DEFAULT_PATH | ||
| ) | ||
| list(APPEND SCANBOTSDK_REQUIRED_VARS ScanbotSDK_DLL) | ||
| endif() | ||
|
|
||
| find_package_handle_standard_args(ScanbotSDK | ||
| REQUIRED_VARS ScanbotSDK_LIBS ScanbotSDK_INCLUDE_DIRS) | ||
| REQUIRED_VARS ${SCANBOTSDK_REQUIRED_VARS} | ||
| VERSION_VAR SCANBOTSDK_VERSION | ||
| ) | ||
|
|
||
| message(STATUS "Scanbot SDK third-party licenses are located at: ${SCANBOTSDK_DIR}/scanbotsdk/licenses/Libraries.txt") | ||
|
|
||
| add_library(scanbotsdk SHARED IMPORTED) | ||
| set_target_properties(scanbotsdk PROPERTIES | ||
| IMPORTED_LOCATION "${ScanbotSDK_LIBS}" | ||
| INTERFACE_INCLUDE_DIRECTORIES "${ScanbotSDK_INCLUDE_DIRS}" | ||
| ) | ||
| add_library(ScanbotSDK::ScanbotSDK SHARED IMPORTED) | ||
| set_target_properties(ScanbotSDK::ScanbotSDK PROPERTIES | ||
| INTERFACE_INCLUDE_DIRECTORIES "${ScanbotSDK_INCLUDE_DIRS}" | ||
| ) | ||
|
|
||
| if(WIN32) | ||
| set_target_properties(ScanbotSDK::ScanbotSDK PROPERTIES | ||
| IMPORTED_LOCATION "${ScanbotSDK_DLL}" | ||
| IMPORTED_IMPLIB "${ScanbotSDK_LIBS}" | ||
| ) | ||
| else() | ||
| set_target_properties(ScanbotSDK::ScanbotSDK PROPERTIES | ||
| IMPORTED_LOCATION "${ScanbotSDK_LIBS}" | ||
| ) | ||
| endif() | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we merge the PR only after v9 release is published?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we're not in a hurry to merge