From 24f00ea278aca352aa49d2b175fb88fdae2fc804 Mon Sep 17 00:00:00 2001 From: onthegrid007 Date: Sun, 14 Jul 2024 19:32:38 -0700 Subject: [PATCH 1/8] Clang support --- CMakeLists.txt | 5 ++++- src/pc/protocols/usb_host.cpp | 18 +++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1867ae5..4a732ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,10 @@ if(XLINK_ENABLE_LIBUSB) if(WIN32 AND NOT MINGW) target_link_libraries(${TARGET_NAME} PRIVATE delayimp.lib) # workaround https://gitlab.kitware.com/cmake/cmake/-/issues/20022 - target_link_options(${TARGET_NAME} PUBLIC "$:d>.dll>") + if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # fix to https://github.com/luxonis/depthai-core/issues/1044 + target_link_options(${TARGET_NAME} PUBLIC "$:d>.dll>") + endif() endif() endif() diff --git a/src/pc/protocols/usb_host.cpp b/src/pc/protocols/usb_host.cpp index 65b517c..a57b749 100644 --- a/src/pc/protocols/usb_host.cpp +++ b/src/pc/protocols/usb_host.cpp @@ -1,6 +1,15 @@ // project #define MVLOG_UNIT_NAME xLinkUsb +// std +#include +#include +#include +#include +#include +#include +#include + // libraries #ifdef XLINK_LIBUSB_LOCAL #include @@ -15,15 +24,6 @@ #include "usb_host.h" #include "../PlatformDeviceFd.h" -// std -#include -#include -#include -#include -#include -#include -#include - constexpr static int MAXIMUM_PORT_NUMBERS = 7; using VidPid = std::pair; static const int MX_ID_TIMEOUT_MS = 100; From 335a3d4ebd2852685824b8d119d3ecd4566085e0 Mon Sep 17 00:00:00 2001 From: "Peter F." Date: Mon, 15 Jul 2024 12:02:40 -0700 Subject: [PATCH 2/8] change to delayload logic Co-authored-by: TheMarpe --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 201cf34..bf06328 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,7 @@ if(XLINK_ENABLE_LIBUSB) else() # Link to CMake libusb target_link_libraries(${TARGET_NAME} PRIVATE usb-1.0) - if(WIN32 AND NOT MINGW) + if(WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC") target_link_libraries(${TARGET_NAME} PRIVATE delayimp.lib) # workaround https://gitlab.kitware.com/cmake/cmake/-/issues/20022 if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") From 07eb5c87e9a97233716d7c0a1a9c20376378a0d1 Mon Sep 17 00:00:00 2001 From: onthegrid007 Date: Fri, 19 Jul 2024 21:31:29 -0700 Subject: [PATCH 3/8] fixed clang support --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 201cf34..1f55b25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,8 +92,6 @@ if(XLINK_ENABLE_LIBUSB) if(WIN32 AND NOT MINGW) target_link_libraries(${TARGET_NAME} PRIVATE delayimp.lib) # workaround https://gitlab.kitware.com/cmake/cmake/-/issues/20022 - if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - # fix to https://github.com/luxonis/depthai-core/issues/1044 target_link_options(${TARGET_NAME} PUBLIC "$:d>.dll>") endif() endif() From 541e9cc2b0a0d0c1acfd2f3a835fc1c81b9105b4 Mon Sep 17 00:00:00 2001 From: onthegrid007 Date: Fri, 19 Jul 2024 21:31:43 -0700 Subject: [PATCH 4/8] fixed clang support 2 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f55b25..d146058 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,7 @@ if(XLINK_ENABLE_LIBUSB) else() # Link to CMake libusb target_link_libraries(${TARGET_NAME} PRIVATE usb-1.0) - if(WIN32 AND NOT MINGW) + if(WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC") target_link_libraries(${TARGET_NAME} PRIVATE delayimp.lib) # workaround https://gitlab.kitware.com/cmake/cmake/-/issues/20022 target_link_options(${TARGET_NAME} PUBLIC "$:d>.dll>") From 26cdde068833162d1568927844c6287f5d3a84d7 Mon Sep 17 00:00:00 2001 From: onthegrid007 Date: Sat, 20 Jul 2024 19:38:25 -0700 Subject: [PATCH 5/8] flow control oops --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d146058..b6be6e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,8 +92,7 @@ if(XLINK_ENABLE_LIBUSB) if(WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC") target_link_libraries(${TARGET_NAME} PRIVATE delayimp.lib) # workaround https://gitlab.kitware.com/cmake/cmake/-/issues/20022 - target_link_options(${TARGET_NAME} PUBLIC "$:d>.dll>") - endif() + target_link_options(${TARGET_NAME} PUBLIC "$:d>.dll>") endif() endif() From ab88eae41c37f3d4cf50314c877d48f964551513 Mon Sep 17 00:00:00 2001 From: onthegrid007 Date: Tue, 23 Jul 2024 18:35:59 -0700 Subject: [PATCH 6/8] Add clang to workflow --- .github/workflows/.dev.workflow.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/.dev.workflow.yml b/.github/workflows/.dev.workflow.yml index 90407aa..d5a8658 100644 --- a/.github/workflows/.dev.workflow.yml +++ b/.github/workflows/.dev.workflow.yml @@ -8,16 +8,13 @@ on: branches-ignore: - xlink_upstream - - jobs: - build: runs-on: ${{ matrix.os }} strategy: matrix: os: [macos-latest, windows-latest, ubuntu-latest] - compiler: [default] + compiler: [default, clang] libusb: [ON, OFF] include: - os: windows-latest @@ -56,5 +53,9 @@ jobs: if: matrix.compiler == 'mingw' run: cmake . -Bbuild -DXLINK_BUILD_EXAMPLES=ON -DXLINK_BUILD_TESTS=ON -DXLINK_ENABLE_LIBUSB=${{ matrix.libusb }} -G"MinGW Makefiles" + - name: configure + if: matrix.compiler == 'clang' + run: cmake . -Bbuild -DXLINK_BUILD_EXAMPLES=ON -DXLINK_BUILD_TESTS=ON -DXLINK_ENABLE_LIBUSB=${{ matrix.libusb }} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + - name: build run: cmake --build build --parallel From f967dad124357aa5f5156c39005d90705ea73e4e Mon Sep 17 00:00:00 2001 From: onthegrid007 Date: Tue, 23 Jul 2024 18:41:12 -0700 Subject: [PATCH 7/8] Forgot to add clang installation --- .github/workflows/.dev.workflow.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/.dev.workflow.yml b/.github/workflows/.dev.workflow.yml index d5a8658..664a2ef 100644 --- a/.github/workflows/.dev.workflow.yml +++ b/.github/workflows/.dev.workflow.yml @@ -45,6 +45,23 @@ jobs: choco install mingw choco upgrade mingw + - name: Install Clang on macOS + if: matrix.os == 'macos-latest' && matrix.compiler == 'clang' + run: | + brew install llvm + echo "/usr/local/opt/llvm/bin" >> $GITHUB_PATH + + - name: Install Clang on Ubuntu + if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'clang' + run: | + sudo apt-get install clang + + - name: Install Clang on Windows + if: matrix.os == 'windows-latest' && matrix.compiler == 'clang' + run: | + choco install llvm + echo "C:\Program Files\LLVM\bin" >> $env:GITHUB_PATH + - name: configure if: matrix.compiler == 'default' run: cmake . -Bbuild -DXLINK_BUILD_EXAMPLES=ON -DXLINK_BUILD_TESTS=ON -DXLINK_ENABLE_LIBUSB=${{ matrix.libusb }} From 068144a5c906e73cce8134d857f66937f3e50d3e Mon Sep 17 00:00:00 2001 From: onthegrid007 Date: Mon, 29 Jul 2024 20:24:12 -0400 Subject: [PATCH 8/8] Add Ninja makefile system for clang --- .github/workflows/.dev.workflow.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/.dev.workflow.yml b/.github/workflows/.dev.workflow.yml index 664a2ef..2f09bfb 100644 --- a/.github/workflows/.dev.workflow.yml +++ b/.github/workflows/.dev.workflow.yml @@ -62,6 +62,21 @@ jobs: choco install llvm echo "C:\Program Files\LLVM\bin" >> $env:GITHUB_PATH + - name: Install Ninja on macOS + if: matrix.os == 'macos-latest' + run: | + brew install ninja + + - name: Install Ninja on Ubuntu + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get install ninja-build + + - name: Install Ninja on Windows + if: matrix.os == 'windows-latest' + run: | + choco install ninja + - name: configure if: matrix.compiler == 'default' run: cmake . -Bbuild -DXLINK_BUILD_EXAMPLES=ON -DXLINK_BUILD_TESTS=ON -DXLINK_ENABLE_LIBUSB=${{ matrix.libusb }} @@ -72,7 +87,7 @@ jobs: - name: configure if: matrix.compiler == 'clang' - run: cmake . -Bbuild -DXLINK_BUILD_EXAMPLES=ON -DXLINK_BUILD_TESTS=ON -DXLINK_ENABLE_LIBUSB=${{ matrix.libusb }} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + run: cmake . -Bbuild -DXLINK_BUILD_EXAMPLES=ON -DXLINK_BUILD_TESTS=ON -DXLINK_ENABLE_LIBUSB=${{ matrix.libusb }} -G"Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ - name: build - run: cmake --build build --parallel + run: cmake --build build --parallel \ No newline at end of file