From daa11da486fdcd42ffd7f1c391e1b3b4d3d653b9 Mon Sep 17 00:00:00 2001 From: Samir Rashid Date: Sun, 22 Oct 2023 17:07:19 -0700 Subject: [PATCH 01/12] commit late commit infrequently --- CMakeLists.txt | 20 +++++++- deps/arena-sdk/CMakeLists.txt | 4 +- deps/opencv/CMakeLists.txt | 14 ++++++ deps/torch/CMakeLists.txt | 22 +++++++++ shell.nix | 89 +++++++++++++++++++++++++++++++---- shell.nix.bak | 45 ++++++++++++++++++ src/main.cpp | 6 +++ 7 files changed, 189 insertions(+), 11 deletions(-) create mode 100644 deps/opencv/CMakeLists.txt create mode 100644 deps/torch/CMakeLists.txt create mode 100644 shell.nix.bak diff --git a/CMakeLists.txt b/CMakeLists.txt index f99ecfe6..8c1b8c55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,24 @@ FATAL: In-source builds are not allowed. ") endif() +# Check if Ninja is available +find_program(NINJA_EXECUTABLE ninja) -cmake_minimum_required(VERSION 3.13) +# Set the default generator +if(NINJA_EXECUTABLE) + set(CMAKE_GENERATOR "Ninja") +else() + set(CMAKE_GENERATOR "Unix Makefiles") # Use a fallback generator +endif() + +# enable build caching +find_program(CCACHE_FOUND ccache) +if(CCACHE_FOUND) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) +endif() + +cmake_minimum_required(VERSION 3.13 FATAL_ERROR) set(CMAKE_CXX_COMPILER g++) @@ -35,6 +51,8 @@ set(DEPS_DIRECTORY ${PROJECT_SOURCE_DIR}/deps) add_subdirectory(${DEPS_DIRECTORY}/arena-sdk) add_subdirectory(${DEPS_DIRECTORY}/json) +add_subdirectory(${DEPS_DIRECTORY}/opencv) +# add_subdirectory(${DEPS_DIRECTORY}/torch) # ============================= # ============================= diff --git a/deps/arena-sdk/CMakeLists.txt b/deps/arena-sdk/CMakeLists.txt index 9fbbef47..1c24847e 100644 --- a/deps/arena-sdk/CMakeLists.txt +++ b/deps/arena-sdk/CMakeLists.txt @@ -22,8 +22,8 @@ if(UNIX AND NOT APPLE) "${ARENA_SDK_DIR}/extracted/GenICam/library/CPP/include" ) file(GLOB_RECURSE ARENA_LIBS - "${ARENA_SDK_DIR}/extracted/lib64/*.so" - "${ARENA_SDK_DIR}/extracted/ffmpeg/*.so" + # "${ARENA_SDK_DIR}/extracted/lib64/*.so" + "${ARENA_SDK_DIR}/extracted/**/*.so" ) target_link_libraries(${PROJECT_NAME} PRIVATE ${ARENA_LIBS} diff --git a/deps/opencv/CMakeLists.txt b/deps/opencv/CMakeLists.txt new file mode 100644 index 00000000..b0212cb9 --- /dev/null +++ b/deps/opencv/CMakeLists.txt @@ -0,0 +1,14 @@ +include(FetchContent) +Set(FETCHCONTENT_QUIET FALSE) + +# https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent +FetchContent_Declare(OpenCV + URL https://github.com/opencv/opencv/archive/refs/tags/4.8.1.tar.gz + ) + +FetchContent_MakeAvailable(OpenCV) + +include_directories( ${OpenCV_INCLUDE_DIRS} ) +target_link_libraries(${PROJECT_NAME} PRIVATE + ${OpenCV_LIBS} +) diff --git a/deps/torch/CMakeLists.txt b/deps/torch/CMakeLists.txt new file mode 100644 index 00000000..cbd87b49 --- /dev/null +++ b/deps/torch/CMakeLists.txt @@ -0,0 +1,22 @@ +include(FetchContent) +Set(FETCHCONTENT_QUIET FALSE) + +# https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent +FetchContent_Declare(Torch + # URL https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip + URL https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.1.0%2Bcpu.zip +) + +FetchContent_MakeAvailable(Torch) +# find_package(Torch REQUIRED) +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}") + +target_link_libraries(${PROJECT_NAME} PRIVATE + "${TORCH_LIBRARIES}" +) + + + +# add_executable(example-app example-app.cpp) +# target_link_libraries(example-app "${TORCH_LIBRARIES}") +# set_property(TARGET example-app PROPERTY CXX_STANDARD 17) \ No newline at end of file diff --git a/shell.nix b/shell.nix index 53312f08..b49e66d8 100644 --- a/shell.nix +++ b/shell.nix @@ -1,10 +1,83 @@ -{ pkgs ? import {} }: +# { pkgs ? import {} }: -pkgs.mkShell { - buildInputs = [ - pkgs.gcc - pkgs.cmake - pkgs.libclang - ]; -} +# pkgs.mkShell { +# buildInputs = [ +# pkgs.gcc +# pkgs.cmake +# pkgs.libclang +# pkgs.xz +# pkgs.bzip2 +# ]; + # LD_LIBRARY_PATH = lib.makeLibPath [ pkgs.bzip2 pkgs.xz ]; + # shellHook = '' + # CURRENTDIR=$PWD + # CONF_FILE=Arena_SDK.conf + + # echo + # echo "Arena SDK configuration script" + # echo "Usage: Arena_SDK_Linux_x64.conf [-r]" + # echo "-r: Remove existing $CONF_FILE before add new paths" + # echo + + # if [ "$1" = "-r" ]; then + # echo "Removing existing $CONF_FILE" + # sudo rm -f /etc/ld.so.conf.d/$CONF_FILE + # echo + # fi + + # echo "Adding the following Arena SDK library paths to /etc/ld.so.conf.d/$CONF_FILE:" + # echo + # echo "$CURRENTDIR/lib64" + # echo "$CURRENTDIR/GenICam/library/lib/Linux64_x64" + # echo "$CURRENTDIR/ffmpeg" + + # sh -c "echo $CURRENTDIR/deps/arena-sdk/ArenaSDK_Linux_x64/lib64/lib64 > /etc/ld.so.conf.d/$CONF_FILE" + # sh -c "echo $CURRENTDIR/deps/arena-sdk/ArenaSDK_Linux_x64/lib64/GenICam/library/lib/Linux64_x64 >> /etc/ld.so.conf.d/$CONF_FILE" + # sh -c "echo $CURRENTDIR/deps/arena-sdk/ArenaSDK_Linux_x64/lib64/ffmpeg >> /etc/ld.so.conf.d/$CONF_FILE" + + # echo + # echo "Please remember to install these packages if not already installed before proceeding:" + # echo "- g++ 5 or higher" + # echo "- make" + # ''; +# } + + +{pkgs ? import {}}: +(pkgs.buildFHSUserEnv { + name = "python 3.9"; + targetPkgs = pkgs: (with pkgs; [ + python3 + ccache + # pipenv + + # LSP + # python39Packages.python-lsp-server + + # C deps + glib + glibc + stdenv + zlib + + gcc + cmake + libclang + xz + bzip2 + + ]); +# runScript = "zsh"; +profile = '' + LD_LIBRARY_PATH=${pkgs.zlib}/lib:${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.glibc}/lib:${pkgs.glib}/lib:${pkgs.bzip2}/lib:$LD_LIBRARY_PATH + # set SOURCE_DATE_EPOCH so that we can use python wheels + SOURCE_DATE_EPOCH=$(date +%s) + PATH=$HOME/.local/bin:$PATH + # PYTHONPATH=$HOME/.local/lib/python3.9/site-packages:$PYTHONPATH + # export PIP_PREFIX=$(pwd)/_build/pip_packages + # export PYTHONPATH="$PIP_PREFIX/${pkgs.python3.sitePackages}:$PYTHONPATH" + # export PATH="$PIP_PREFIX/bin:$PATH" + # unset SOURCE_DATE_EPOCH + ''; +}).env diff --git a/shell.nix.bak b/shell.nix.bak new file mode 100644 index 00000000..18004593 --- /dev/null +++ b/shell.nix.bak @@ -0,0 +1,45 @@ +{ pkgs ? import {} }: + +pkgs.mkShell { + buildInputs = [ + pkgs.gcc + pkgs.cmake + pkgs.libclang + pkgs.xz + pkgs.bzip2 + ]; + # LD_LIBRARY_PATH = lib.makeLibPath [ pkgs.bzip2 pkgs.xz ]; + + # shellHook = '' + # CURRENTDIR=$PWD + # CONF_FILE=Arena_SDK.conf + + # echo + # echo "Arena SDK configuration script" + # echo "Usage: Arena_SDK_Linux_x64.conf [-r]" + # echo "-r: Remove existing $CONF_FILE before add new paths" + # echo + + # if [ "$1" = "-r" ]; then + # echo "Removing existing $CONF_FILE" + # sudo rm -f /etc/ld.so.conf.d/$CONF_FILE + # echo + # fi + + # echo "Adding the following Arena SDK library paths to /etc/ld.so.conf.d/$CONF_FILE:" + # echo + # echo "$CURRENTDIR/lib64" + # echo "$CURRENTDIR/GenICam/library/lib/Linux64_x64" + # echo "$CURRENTDIR/ffmpeg" + + # sh -c "echo $CURRENTDIR/deps/arena-sdk/ArenaSDK_Linux_x64/lib64/lib64 > /etc/ld.so.conf.d/$CONF_FILE" + # sh -c "echo $CURRENTDIR/deps/arena-sdk/ArenaSDK_Linux_x64/lib64/GenICam/library/lib/Linux64_x64 >> /etc/ld.so.conf.d/$CONF_FILE" + # sh -c "echo $CURRENTDIR/deps/arena-sdk/ArenaSDK_Linux_x64/lib64/ffmpeg >> /etc/ld.so.conf.d/$CONF_FILE" + + # echo + # echo "Please remember to install these packages if not already installed before proceeding:" + # echo "- g++ 5 or higher" + # echo "- make" + # ''; +} + diff --git a/src/main.cpp b/src/main.cpp index b993038b..e13219e6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,10 @@ #include "core/states.hpp" +// #include +// #include +#include + int main() { std::cout << "hello" << std::endl; @@ -9,5 +13,7 @@ int main() { state.tick(); +// torch::Tensor tensor = torch::rand({2, 3}); +// std::cout << tensor << std::endl; return 0; } \ No newline at end of file From 4498570354e67cb08e89d110cea6dfb03a61c58a Mon Sep 17 00:00:00 2001 From: Samir Rashid Date: Wed, 25 Oct 2023 16:58:13 -0700 Subject: [PATCH 02/12] opencv header works --- CMakeLists.txt | 5 +++- deps/opencv/CMakeLists.txt | 33 ++++++++++++++++++++---- deps/opencv/CMakeLists.txt.stackoverflow | 18 +++++++++++++ deps/torch/CMakeLists.txt | 12 +++++++-- shell.nix | 5 ++-- src/main.cpp | 2 +- 6 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 deps/opencv/CMakeLists.txt.stackoverflow diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c1b8c55..a6846c8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,9 @@ file(GLOB_RECURSE HEADERS "include/*.hpp") # ============================= # Executable set(INCLUDE_DIRECTORY ${PROJECT_SOURCE_DIR}/include) -include_directories(${INCLUDE_DIRECTORY}) +message("OpenCV include directories: ${OpenCV_INCLUDE_DIRS}") + +include_directories(${INCLUDE_DIRECTORY} ${OpenCV_INCLUDE_DIRS} ) add_executable(${PROJECT_NAME} ${SOURCES}) # ============================= @@ -64,6 +66,7 @@ add_subdirectory(${DEPS_DIRECTORY}/google-test) # ============================= # Linting get_target_property(PROJECT_LIBS_INCLUDE_DIRS ${PROJECT_NAME} INCLUDE_DIRECTORIES) + foreach(dir ${PROJECT_LIBS_INCLUDE_DIRS}) string(APPEND LIB_INCLUDE_CLANG_TIDY_STRING "-I${dir};") endforeach() diff --git a/deps/opencv/CMakeLists.txt b/deps/opencv/CMakeLists.txt index b0212cb9..6bf0e17f 100644 --- a/deps/opencv/CMakeLists.txt +++ b/deps/opencv/CMakeLists.txt @@ -1,14 +1,37 @@ include(FetchContent) Set(FETCHCONTENT_QUIET FALSE) - +# cmake .. -DBUILD_TESTS=OFF +# add_compile_options(-Wno-deprecated-enum-enum-conversion) # https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent FetchContent_Declare(OpenCV URL https://github.com/opencv/opencv/archive/refs/tags/4.8.1.tar.gz + OVERRIDE_FIND_PACKAGE ) FetchContent_MakeAvailable(OpenCV) -include_directories( ${OpenCV_INCLUDE_DIRS} ) -target_link_libraries(${PROJECT_NAME} PRIVATE - ${OpenCV_LIBS} -) +find_package(OpenCV REQUIRED COMPONENTS core imgproc highgui) +# Set(OpenCV_DIR "/home/samir/Documents/github/tuas/obcpp/deps/opencv/opencv-build") +# add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/opencv-src +# ${CMAKE_CURRENT_BINARY_DIR}/opencv-build) +# file(GLOB_RECURSE HEADERS "./**/*.hpp") +# include_directories(${PROJECT_NAME} ${OpenCV_INCLUDE_DIRS} ${HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/opencv-src "./opencv-src/include/opencv2/opencv.hpp") +# target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCV_INCLUDE_DIRS} )#${HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/opencv-src "./opencv-src/include/opencv2/opencv.hpp") +# target_link_libraries(${PROJECT_NAME} PRIVATE +# ${OpenCV_LIBS} +# ) + +target_compile_options(${PROJECT_NAME} PRIVATE -Wno-deprecated-enum-enum-conversion) + +file(GLOB_RECURSE HEADERS "include/*.hpp") + +message("OpenCV include directories: ${OpenCV_INCLUDE_DIRS}") +set(OpenCV_INCLUDE_DIRS ${OpenCV_SOURCE_DIR}/include ) +message("OpenCV include directories: ${OpenCV_INCLUDE_DIRS}") +target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCV_INCLUDE_DIRS} ${OPENCV_CONFIG_FILE_INCLUDE_DIR} + ${OPENCV_MODULE_opencv_core_LOCATION}/include + ${OPENCV_MODULE_opencv_highgui_LOCATION}/include ${HEADERS}) +target_link_libraries(${PROJECT_NAME} PRIVATE ${OpenCV_LIBS} opencv_core opencv_highgui) + +# Set( "OpenCV_DIR" "opencv-build" ) +# set(OpenCV_DIR ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/deps/opencv/CMakeLists.txt.stackoverflow b/deps/opencv/CMakeLists.txt.stackoverflow new file mode 100644 index 00000000..bb88bf70 --- /dev/null +++ b/deps/opencv/CMakeLists.txt.stackoverflow @@ -0,0 +1,18 @@ + +include(FetchContent) +FetchContent_Declare( + opencv + GIT_REPOSITORY https://github.com/opencv/opencv.git + GIT_TAG 4.6.0 + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE +) +FetchContent_MakeAvailable(opencv) + +add_executable(my_target main.cpp) +target_include_directories(ocv_test PRIVATE + ${OPENCV_CONFIG_FILE_INCLUDE_DIR} + ${OPENCV_MODULE_opencv_core_LOCATION}/include + ${OPENCV_MODULE_opencv_highgui_LOCATION}/include + ) +target_link_libraries(my_target opencv_core opencv_highgui) \ No newline at end of file diff --git a/deps/torch/CMakeLists.txt b/deps/torch/CMakeLists.txt index cbd87b49..3b5072cf 100644 --- a/deps/torch/CMakeLists.txt +++ b/deps/torch/CMakeLists.txt @@ -3,17 +3,25 @@ Set(FETCHCONTENT_QUIET FALSE) # https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent FetchContent_Declare(Torch - # URL https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip URL https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.1.0%2Bcpu.zip ) + # URL https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip FetchContent_MakeAvailable(Torch) # find_package(Torch REQUIRED) -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}") target_link_libraries(${PROJECT_NAME} PRIVATE "${TORCH_LIBRARIES}" ) +include_directories(SYSTEM ${TORCH_INCLUDE_DIRS}) + +# find_package(Torch REQUIRED) +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}") + +# add_executable(example-app example-app.cpp) +# target_link_libraries(example-app "${TORCH_LIBRARIES}") +# set_property(TARGET example-app PROPERTY CXX_STANDARD 17) diff --git a/shell.nix b/shell.nix index b49e66d8..a231ce5d 100644 --- a/shell.nix +++ b/shell.nix @@ -50,6 +50,7 @@ targetPkgs = pkgs: (with pkgs; [ python3 ccache + # ninja # pipenv # LSP @@ -68,9 +69,9 @@ bzip2 ]); -# runScript = "zsh"; +runScript = "bash"; profile = '' - LD_LIBRARY_PATH=${pkgs.zlib}/lib:${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.glibc}/lib:${pkgs.glib}/lib:${pkgs.bzip2}/lib:$LD_LIBRARY_PATH + LD_LIBRARY_PATH=${pkgs.zlib}/lib:${pkgs.bzip2}/lib:$LD_LIBRARY_PATH # set SOURCE_DATE_EPOCH so that we can use python wheels SOURCE_DATE_EPOCH=$(date +%s) PATH=$HOME/.local/bin:$PATH diff --git a/src/main.cpp b/src/main.cpp index e13219e6..94658ce0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,7 +2,7 @@ #include "core/states.hpp" -// #include +#include // #include #include From 218a94984b43bae753351c3b9401601d5996f435 Mon Sep 17 00:00:00 2001 From: Samir Rashid Date: Wed, 25 Oct 2023 21:21:03 -0700 Subject: [PATCH 03/12] broken --- CMakeLists.txt | 4 ++-- deps/opencv/CMakeLists.txt.stackoverflow | 1 + deps/torch/CMakeLists.txt | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6846c8f..ae2543f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,8 +53,8 @@ set(DEPS_DIRECTORY ${PROJECT_SOURCE_DIR}/deps) add_subdirectory(${DEPS_DIRECTORY}/arena-sdk) add_subdirectory(${DEPS_DIRECTORY}/json) -add_subdirectory(${DEPS_DIRECTORY}/opencv) -# add_subdirectory(${DEPS_DIRECTORY}/torch) +# add_subdirectory(${DEPS_DIRECTORY}/opencv) +add_subdirectory(${DEPS_DIRECTORY}/torch) # ============================= # ============================= diff --git a/deps/opencv/CMakeLists.txt.stackoverflow b/deps/opencv/CMakeLists.txt.stackoverflow index bb88bf70..a820e97e 100644 --- a/deps/opencv/CMakeLists.txt.stackoverflow +++ b/deps/opencv/CMakeLists.txt.stackoverflow @@ -1,4 +1,5 @@ +# https://github.com/opencv/opencv/issues/20548 include(FetchContent) FetchContent_Declare( opencv diff --git a/deps/torch/CMakeLists.txt b/deps/torch/CMakeLists.txt index 3b5072cf..d72c24f1 100644 --- a/deps/torch/CMakeLists.txt +++ b/deps/torch/CMakeLists.txt @@ -1,20 +1,23 @@ include(FetchContent) Set(FETCHCONTENT_QUIET FALSE) -# https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent FetchContent_Declare(Torch URL https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.1.0%2Bcpu.zip ) # URL https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip FetchContent_MakeAvailable(Torch) -# find_package(Torch REQUIRED) + +# message(FATAL_ERROR ${CMAKE_BINARY_DIR}) +set(Torch_DIR "${CMAKE_BINARY_DIR}/_deps/torch-src/share/cmake/Torch/") +find_package(Torch REQUIRED) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}") target_link_libraries(${PROJECT_NAME} PRIVATE "${TORCH_LIBRARIES}" ) -include_directories(SYSTEM ${TORCH_INCLUDE_DIRS}) +target_include_directories(${PROJECT_NAME} PRIVATE ${TORCH_INCLUDE_DIRS}) # find_package(Torch REQUIRED) # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}") From 70ff6b109fa4f644ec19d205f45379609d990ffe Mon Sep 17 00:00:00 2001 From: Samir Rashid Date: Wed, 25 Oct 2023 22:04:04 -0700 Subject: [PATCH 04/12] yes --- CMakeLists.txt | 5 +++-- deps/opencv/CMakeLists.txt | 2 +- deps/torch/CMakeLists.txt | 7 ++++--- src/main.cpp | 30 ++++++++++++++++++++++++++---- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae2543f3..60e39f8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,9 +54,10 @@ set(DEPS_DIRECTORY ${PROJECT_SOURCE_DIR}/deps) add_subdirectory(${DEPS_DIRECTORY}/arena-sdk) add_subdirectory(${DEPS_DIRECTORY}/json) # add_subdirectory(${DEPS_DIRECTORY}/opencv) -add_subdirectory(${DEPS_DIRECTORY}/torch) +# add_subdirectory(${DEPS_DIRECTORY}/torch) # ============================= - +include(${DEPS_DIRECTORY}/torch/CMakeLists.txt) +include(${DEPS_DIRECTORY}/opencv/CMakeLists.txt) # ============================= # Unit tests add_subdirectory(tests) diff --git a/deps/opencv/CMakeLists.txt b/deps/opencv/CMakeLists.txt index 6bf0e17f..fe0e49f3 100644 --- a/deps/opencv/CMakeLists.txt +++ b/deps/opencv/CMakeLists.txt @@ -6,7 +6,7 @@ Set(FETCHCONTENT_QUIET FALSE) FetchContent_Declare(OpenCV URL https://github.com/opencv/opencv/archive/refs/tags/4.8.1.tar.gz OVERRIDE_FIND_PACKAGE - ) +) FetchContent_MakeAvailable(OpenCV) diff --git a/deps/torch/CMakeLists.txt b/deps/torch/CMakeLists.txt index d72c24f1..922e6bbe 100644 --- a/deps/torch/CMakeLists.txt +++ b/deps/torch/CMakeLists.txt @@ -8,12 +8,13 @@ FetchContent_Declare(Torch FetchContent_MakeAvailable(Torch) -# message(FATAL_ERROR ${CMAKE_BINARY_DIR}) -set(Torch_DIR "${CMAKE_BINARY_DIR}/_deps/torch-src/share/cmake/Torch/") -find_package(Torch REQUIRED) +# message(FATAL_ERROR ${torch_SOURCE_DIR}) +# set(Torch_DIR "${CMAKE_BINARY_DIR}/_deps/torch-src/share/cmake/Torch/") +find_package(Torch REQUIRED HINTS "${torch_SOURCE_DIR}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}") +# message(FATAL_ERROR ${TORCH_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} PRIVATE "${TORCH_LIBRARIES}" ) diff --git a/src/main.cpp b/src/main.cpp index 94658ce0..3018beb9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,17 +3,39 @@ #include "core/states.hpp" #include -// #include +#include #include int main() { - std::cout << "hello" << std::endl; + std::cout << "hellasdfasdfTarget torch_cpu not found.o" << std::endl; PreparationState state; state.tick(); -// torch::Tensor tensor = torch::rand({2, 3}); -// std::cout << tensor << std::endl; + torch::Tensor tensor = torch::rand({2, 3}); + std::cout << tensor << std::endl; + + //create a gui window: + namedWindow("Output",1); + + //initialize a 120X350 matrix of black pixels: + Mat output = Mat::zeros( 120, 350, CV_8UC3 ); + + //write text on the matrix: + putText(output, + "Hello World :)", + cvPoint(15,70), + FONT_HERSHEY_PLAIN, + 3, + cvScalar(0,255,0), + 4); + + //display the image: + imshow("Output", output); + + //wait for the user to press any key: + waitKey(0); + return 0; } \ No newline at end of file From 91f4dd419f99346e5c5532c0bbf3e49d29387654 Mon Sep 17 00:00:00 2001 From: Samir Rashid Date: Thu, 26 Oct 2023 06:07:10 +0000 Subject: [PATCH 05/12] it twerks --- deps/opencv/CMakeLists.txt | 5 ++++- src/main.cpp | 21 +++++---------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/deps/opencv/CMakeLists.txt b/deps/opencv/CMakeLists.txt index fe0e49f3..8fd36ac7 100644 --- a/deps/opencv/CMakeLists.txt +++ b/deps/opencv/CMakeLists.txt @@ -23,7 +23,7 @@ find_package(OpenCV REQUIRED COMPONENTS core imgproc highgui) target_compile_options(${PROJECT_NAME} PRIVATE -Wno-deprecated-enum-enum-conversion) -file(GLOB_RECURSE HEADERS "include/*.hpp") +file(GLOB_RECURSE HEADERS "include/**/*.hpp") message("OpenCV include directories: ${OpenCV_INCLUDE_DIRS}") set(OpenCV_INCLUDE_DIRS ${OpenCV_SOURCE_DIR}/include ) @@ -33,5 +33,8 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCV_INCLUDE_DIRS} ${OPENCV_MODULE_opencv_highgui_LOCATION}/include ${HEADERS}) target_link_libraries(${PROJECT_NAME} PRIVATE ${OpenCV_LIBS} opencv_core opencv_highgui) +get_target_property(TMP ${PROJECT_NAME} INCLUDE_DIRECTORIES) +# message(FATAL_ERROR ${TMP}) + # Set( "OpenCV_DIR" "opencv-build" ) # set(OpenCV_DIR ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/main.cpp b/src/main.cpp index 3018beb9..083237cd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,6 +6,8 @@ #include #include +using namespace cv; + int main() { std::cout << "hellasdfasdfTarget torch_cpu not found.o" << std::endl; @@ -17,25 +19,12 @@ int main() { std::cout << tensor << std::endl; //create a gui window: - namedWindow("Output",1); + // namedWindow("Output",1); //initialize a 120X350 matrix of black pixels: Mat output = Mat::zeros( 120, 350, CV_8UC3 ); + std::cout << output << std::endl; - //write text on the matrix: - putText(output, - "Hello World :)", - cvPoint(15,70), - FONT_HERSHEY_PLAIN, - 3, - cvScalar(0,255,0), - 4); - - //display the image: - imshow("Output", output); - - //wait for the user to press any key: - waitKey(0); - + return 0; } \ No newline at end of file From 206831c1e6ba33dfcb1f41cf62fbb5f1ad56170e Mon Sep 17 00:00:00 2001 From: Samir Rashid Date: Wed, 25 Oct 2023 23:23:46 -0700 Subject: [PATCH 06/12] contrib --- deps/opencv/CMakeLists.txt | 58 ++++++++++++++++++-------------------- src/main.cpp | 19 +++++++++++-- 2 files changed, 43 insertions(+), 34 deletions(-) diff --git a/deps/opencv/CMakeLists.txt b/deps/opencv/CMakeLists.txt index 8fd36ac7..701d7124 100644 --- a/deps/opencv/CMakeLists.txt +++ b/deps/opencv/CMakeLists.txt @@ -1,40 +1,36 @@ include(FetchContent) -Set(FETCHCONTENT_QUIET FALSE) -# cmake .. -DBUILD_TESTS=OFF -# add_compile_options(-Wno-deprecated-enum-enum-conversion) -# https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent + +# Fetch the main OpenCV repository FetchContent_Declare(OpenCV - URL https://github.com/opencv/opencv/archive/refs/tags/4.8.1.tar.gz + URL https://github.com/opencv/opencv/archive/refs/tags/4.8.1.tar.gz OVERRIDE_FIND_PACKAGE ) -FetchContent_MakeAvailable(OpenCV) - -find_package(OpenCV REQUIRED COMPONENTS core imgproc highgui) -# Set(OpenCV_DIR "/home/samir/Documents/github/tuas/obcpp/deps/opencv/opencv-build") -# add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/opencv-src -# ${CMAKE_CURRENT_BINARY_DIR}/opencv-build) -# file(GLOB_RECURSE HEADERS "./**/*.hpp") -# include_directories(${PROJECT_NAME} ${OpenCV_INCLUDE_DIRS} ${HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/opencv-src "./opencv-src/include/opencv2/opencv.hpp") -# target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCV_INCLUDE_DIRS} )#${HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/opencv-src "./opencv-src/include/opencv2/opencv.hpp") -# target_link_libraries(${PROJECT_NAME} PRIVATE -# ${OpenCV_LIBS} -# ) - -target_compile_options(${PROJECT_NAME} PRIVATE -Wno-deprecated-enum-enum-conversion) +set( OPENCV_EXTRA_MODULES_PATH ${OpenCV_SOURCE_DIR}/../opencvcontrib-src/modules) +# Fetch the OpenCV contrib repository +FetchContent_Declare(OpenCVContrib + URL https://github.com/opencv/opencv_contrib/archive/refs/tags/4.8.1.tar.gz + # SOURCE_DIR "${CMAKE_BINARY_DIR}/opencv_contrib-src" # Specify a separate source directory + # PREFIX "${CMAKE_BINARY_DIR}/opencv_contrib-prefix" # Specify a separate prefix directory +) -file(GLOB_RECURSE HEADERS "include/**/*.hpp") +# Make both OpenCV and OpenCV contrib available +FetchContent_MakeAvailable(OpenCV OpenCVContrib) -message("OpenCV include directories: ${OpenCV_INCLUDE_DIRS}") +# Find OpenCV +find_package(OpenCV REQUIRED COMPONENTS core imgproc highgui) set(OpenCV_INCLUDE_DIRS ${OpenCV_SOURCE_DIR}/include ) -message("OpenCV include directories: ${OpenCV_INCLUDE_DIRS}") -target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCV_INCLUDE_DIRS} ${OPENCV_CONFIG_FILE_INCLUDE_DIR} - ${OPENCV_MODULE_opencv_core_LOCATION}/include - ${OPENCV_MODULE_opencv_highgui_LOCATION}/include ${HEADERS}) -target_link_libraries(${PROJECT_NAME} PRIVATE ${OpenCV_LIBS} opencv_core opencv_highgui) +file(GLOB_RECURSE HEADERS "${OpenCV_SOURCE_DIR}/modules/**/*.hpp") +# message(FATAL_ERROR ${HEADERS}) +# Add OpenCV's contrib modules to the target +target_link_libraries(${PROJECT_NAME} PRIVATE ${OpenCV_LIBS} opencv_core opencv_highgui opencv_contrib) -get_target_property(TMP ${PROJECT_NAME} INCLUDE_DIRECTORIES) -# message(FATAL_ERROR ${TMP}) - -# Set( "OpenCV_DIR" "opencv-build" ) -# set(OpenCV_DIR ${CMAKE_CURRENT_BINARY_DIR}) +# Specify include directories, including OpenCV's contrib +target_include_directories(${PROJECT_NAME} PRIVATE + ${OpenCV_INCLUDE_DIRS} + ${OpenCVContrib_SOURCE_DIR}/modules # Include contrib modules + ${OPENCV_CONFIG_FILE_INCLUDE_DIR} + ${OPENCV_MODULE_opencv_core_LOCATION}/include + ${OPENCV_MODULE_opencv_highgui_LOCATION}/include + # ${HEADERS} +) diff --git a/src/main.cpp b/src/main.cpp index 083237cd..22bca6b5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,12 +19,25 @@ int main() { std::cout << tensor << std::endl; //create a gui window: - // namedWindow("Output",1); + namedWindow("Output",1); //initialize a 120X350 matrix of black pixels: Mat output = Mat::zeros( 120, 350, CV_8UC3 ); - std::cout << output << std::endl; - + //write text on the matrix: + putText(output, + "Hello World :)", + cvPoint(15,70), + FONT_HERSHEY_PLAIN, + 3, + cvScalar(0,255,0), + 4); + + //display the image: + imshow("Output", output); + + //wait for the user to press any key: + waitKey(0); + return 0; } \ No newline at end of file From 956eabcc9bcc4acb16f65e6e8debf9a98122af6c Mon Sep 17 00:00:00 2001 From: Samir Rashid Date: Thu, 26 Oct 2023 07:03:31 +0000 Subject: [PATCH 07/12] opencv and torch both work in main --- deps/opencv/CMakeLists.txt | 22 +++++++++++++++++----- src/main.cpp | 10 +++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/deps/opencv/CMakeLists.txt b/deps/opencv/CMakeLists.txt index 701d7124..e0ca1d74 100644 --- a/deps/opencv/CMakeLists.txt +++ b/deps/opencv/CMakeLists.txt @@ -6,7 +6,7 @@ FetchContent_Declare(OpenCV OVERRIDE_FIND_PACKAGE ) -set( OPENCV_EXTRA_MODULES_PATH ${OpenCV_SOURCE_DIR}/../opencvcontrib-src/modules) +# set( OPENCV_EXTRA_MODULES_PATH ${OpenCV_SOURCE_DIR}/../opencvcontrib-src/modules) # Fetch the OpenCV contrib repository FetchContent_Declare(OpenCVContrib URL https://github.com/opencv/opencv_contrib/archive/refs/tags/4.8.1.tar.gz @@ -18,12 +18,11 @@ FetchContent_Declare(OpenCVContrib FetchContent_MakeAvailable(OpenCV OpenCVContrib) # Find OpenCV -find_package(OpenCV REQUIRED COMPONENTS core imgproc highgui) +find_package(OpenCV REQUIRED COMPONENTS core imgproc highgui features2d flann dnn imgcodecs videoio imgproc ml) set(OpenCV_INCLUDE_DIRS ${OpenCV_SOURCE_DIR}/include ) -file(GLOB_RECURSE HEADERS "${OpenCV_SOURCE_DIR}/modules/**/*.hpp") -# message(FATAL_ERROR ${HEADERS}) +# file(GLOB_RECURSE HEADERS "${OpenCV_SOURCE_DIR}/modules/**/*.hpp") # Add OpenCV's contrib modules to the target -target_link_libraries(${PROJECT_NAME} PRIVATE ${OpenCV_LIBS} opencv_core opencv_highgui opencv_contrib) +target_link_libraries(${PROJECT_NAME} PRIVATE ${OpenCV_LIBS} opencv_core opencv_highgui opencv_features2d opencv_flann opencv_imgcodecs opencv_dnn opencv_videoio opencv_imgproc opencv_ml ) # Specify include directories, including OpenCV's contrib target_include_directories(${PROJECT_NAME} PRIVATE @@ -32,5 +31,18 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${OPENCV_CONFIG_FILE_INCLUDE_DIR} ${OPENCV_MODULE_opencv_core_LOCATION}/include ${OPENCV_MODULE_opencv_highgui_LOCATION}/include + ${OPENCV_MODULE_opencv_features2d_LOCATION}/include + + ${OPENCV_MODULE_opencv_flann_LOCATION}/include + ${OPENCV_MODULE_opencv_imgcodecs_LOCATION}/include + ${OPENCV_MODULE_opencv_dnn_LOCATION}/include + ${OPENCV_MODULE_opencv_videoio_LOCATION}/include + ${OPENCV_MODULE_opencv_imgproc_LOCATION}/include + ${OPENCV_MODULE_opencv_ml_LOCATION}/include # ${HEADERS} ) + +# message(FATAL_ERROR ${OpenCVContrib_SOURCE_DIR}) + +get_target_property(TMP ${PROJECT_NAME} INCLUDE_DIRECTORIES) +# message(FATAL_ERROR ${TMP}) \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 22bca6b5..514bfe43 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,7 +19,7 @@ int main() { std::cout << tensor << std::endl; //create a gui window: - namedWindow("Output",1); + // namedWindow("Output",1); //initialize a 120X350 matrix of black pixels: Mat output = Mat::zeros( 120, 350, CV_8UC3 ); @@ -27,17 +27,17 @@ int main() { //write text on the matrix: putText(output, "Hello World :)", - cvPoint(15,70), + Point(15,70), FONT_HERSHEY_PLAIN, 3, - cvScalar(0,255,0), + Scalar(0,255,0), 4); //display the image: - imshow("Output", output); + imwrite("Output.png", output); //wait for the user to press any key: - waitKey(0); + // waitKey(0); return 0; } \ No newline at end of file From ff9b1e8f9444312a76906a113774f2bcdb0947b3 Mon Sep 17 00:00:00 2001 From: Samir Rashid Date: Thu, 26 Oct 2023 00:11:52 -0700 Subject: [PATCH 08/12] code cleanup --- deps/opencv/CMakeLists.txt.stackoverflow | 19 ---------- shell.nix | 48 +----------------------- shell.nix.bak | 45 ---------------------- src/main.cpp | 45 ++++++++++------------ 4 files changed, 20 insertions(+), 137 deletions(-) delete mode 100644 deps/opencv/CMakeLists.txt.stackoverflow delete mode 100644 shell.nix.bak diff --git a/deps/opencv/CMakeLists.txt.stackoverflow b/deps/opencv/CMakeLists.txt.stackoverflow deleted file mode 100644 index a820e97e..00000000 --- a/deps/opencv/CMakeLists.txt.stackoverflow +++ /dev/null @@ -1,19 +0,0 @@ - -# https://github.com/opencv/opencv/issues/20548 -include(FetchContent) -FetchContent_Declare( - opencv - GIT_REPOSITORY https://github.com/opencv/opencv.git - GIT_TAG 4.6.0 - GIT_SHALLOW TRUE - GIT_PROGRESS TRUE -) -FetchContent_MakeAvailable(opencv) - -add_executable(my_target main.cpp) -target_include_directories(ocv_test PRIVATE - ${OPENCV_CONFIG_FILE_INCLUDE_DIR} - ${OPENCV_MODULE_opencv_core_LOCATION}/include - ${OPENCV_MODULE_opencv_highgui_LOCATION}/include - ) -target_link_libraries(my_target opencv_core opencv_highgui) \ No newline at end of file diff --git a/shell.nix b/shell.nix index a231ce5d..df5310fe 100644 --- a/shell.nix +++ b/shell.nix @@ -1,52 +1,6 @@ -# { pkgs ? import {} }: - -# pkgs.mkShell { -# buildInputs = [ -# pkgs.gcc -# pkgs.cmake -# pkgs.libclang -# pkgs.xz -# pkgs.bzip2 -# ]; - # LD_LIBRARY_PATH = lib.makeLibPath [ pkgs.bzip2 pkgs.xz ]; - - # shellHook = '' - # CURRENTDIR=$PWD - # CONF_FILE=Arena_SDK.conf - - # echo - # echo "Arena SDK configuration script" - # echo "Usage: Arena_SDK_Linux_x64.conf [-r]" - # echo "-r: Remove existing $CONF_FILE before add new paths" - # echo - - # if [ "$1" = "-r" ]; then - # echo "Removing existing $CONF_FILE" - # sudo rm -f /etc/ld.so.conf.d/$CONF_FILE - # echo - # fi - - # echo "Adding the following Arena SDK library paths to /etc/ld.so.conf.d/$CONF_FILE:" - # echo - # echo "$CURRENTDIR/lib64" - # echo "$CURRENTDIR/GenICam/library/lib/Linux64_x64" - # echo "$CURRENTDIR/ffmpeg" - - # sh -c "echo $CURRENTDIR/deps/arena-sdk/ArenaSDK_Linux_x64/lib64/lib64 > /etc/ld.so.conf.d/$CONF_FILE" - # sh -c "echo $CURRENTDIR/deps/arena-sdk/ArenaSDK_Linux_x64/lib64/GenICam/library/lib/Linux64_x64 >> /etc/ld.so.conf.d/$CONF_FILE" - # sh -c "echo $CURRENTDIR/deps/arena-sdk/ArenaSDK_Linux_x64/lib64/ffmpeg >> /etc/ld.so.conf.d/$CONF_FILE" - - # echo - # echo "Please remember to install these packages if not already installed before proceeding:" - # echo "- g++ 5 or higher" - # echo "- make" - # ''; -# } - - {pkgs ? import {}}: (pkgs.buildFHSUserEnv { - name = "python 3.9"; + name = "OBCPP"; targetPkgs = pkgs: (with pkgs; [ python3 ccache diff --git a/shell.nix.bak b/shell.nix.bak deleted file mode 100644 index 18004593..00000000 --- a/shell.nix.bak +++ /dev/null @@ -1,45 +0,0 @@ -{ pkgs ? import {} }: - -pkgs.mkShell { - buildInputs = [ - pkgs.gcc - pkgs.cmake - pkgs.libclang - pkgs.xz - pkgs.bzip2 - ]; - # LD_LIBRARY_PATH = lib.makeLibPath [ pkgs.bzip2 pkgs.xz ]; - - # shellHook = '' - # CURRENTDIR=$PWD - # CONF_FILE=Arena_SDK.conf - - # echo - # echo "Arena SDK configuration script" - # echo "Usage: Arena_SDK_Linux_x64.conf [-r]" - # echo "-r: Remove existing $CONF_FILE before add new paths" - # echo - - # if [ "$1" = "-r" ]; then - # echo "Removing existing $CONF_FILE" - # sudo rm -f /etc/ld.so.conf.d/$CONF_FILE - # echo - # fi - - # echo "Adding the following Arena SDK library paths to /etc/ld.so.conf.d/$CONF_FILE:" - # echo - # echo "$CURRENTDIR/lib64" - # echo "$CURRENTDIR/GenICam/library/lib/Linux64_x64" - # echo "$CURRENTDIR/ffmpeg" - - # sh -c "echo $CURRENTDIR/deps/arena-sdk/ArenaSDK_Linux_x64/lib64/lib64 > /etc/ld.so.conf.d/$CONF_FILE" - # sh -c "echo $CURRENTDIR/deps/arena-sdk/ArenaSDK_Linux_x64/lib64/GenICam/library/lib/Linux64_x64 >> /etc/ld.so.conf.d/$CONF_FILE" - # sh -c "echo $CURRENTDIR/deps/arena-sdk/ArenaSDK_Linux_x64/lib64/ffmpeg >> /etc/ld.so.conf.d/$CONF_FILE" - - # echo - # echo "Please remember to install these packages if not already installed before proceeding:" - # echo "- g++ 5 or higher" - # echo "- make" - # ''; -} - diff --git a/src/main.cpp b/src/main.cpp index 514bfe43..97893035 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,36 +8,29 @@ using namespace cv; -int main() { - std::cout << "hellasdfasdfTarget torch_cpu not found.o" << std::endl; +int main() +{ + std::cout << "hellasdfasdfTarget torch_cpu not found.o" << std::endl; - PreparationState state; + PreparationState state; - state.tick(); + state.tick(); torch::Tensor tensor = torch::rand({2, 3}); std::cout << tensor << std::endl; - //create a gui window: - // namedWindow("Output",1); - - //initialize a 120X350 matrix of black pixels: - Mat output = Mat::zeros( 120, 350, CV_8UC3 ); - - //write text on the matrix: - putText(output, - "Hello World :)", - Point(15,70), - FONT_HERSHEY_PLAIN, - 3, - Scalar(0,255,0), - 4); - - //display the image: - imwrite("Output.png", output); - - //wait for the user to press any key: - // waitKey(0); - - return 0; + Mat output = Mat::zeros(120, 350, CV_8UC3); + + // write text on the matrix: + putText(output, + "Hello World :)", + Point(15, 70), + FONT_HERSHEY_PLAIN, + 3, + Scalar(0, 255, 0), + 4); + + imwrite("Output.png", output); + + return 0; } \ No newline at end of file From a7c3c5103713a8f545dc3373668ebd49acf30e2c Mon Sep 17 00:00:00 2001 From: Samir Rashid Date: Thu, 26 Oct 2023 15:02:38 -0700 Subject: [PATCH 09/12] fix docker support, cant reproduce linting timeout --- Dockerfile | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 083b4e60..4c1ce173 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,53 @@ FROM ubuntu:22.04 +# https://gist.github.com/SSARCandy/fc960d8905330ac695e71e3f3807ce3d +# OpenCV dependencies from above RUN apt-get update \ && apt-get upgrade -y \ && apt-get install -y build-essential \ gdb \ git \ - cmake \ clang-tidy \ - wget \ No newline at end of file + wget \ + ccache \ + vim +# cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev +# python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev + +# the official docs say also these +# https://docs.opencv.org/4.x/d7/d9f/tutorial_linux_install.html +# sudo apt update && sudo apt install -y cmake g++ wget unzip +# xz? bzip2? + +# TODO: is it possible to save the built opencv in the docker build? Need to see what cmake keeps checking and wasting time on. + +RUN apt-get update \ + && rm -rf /var/lib/apt/lists/* \ + && wget https://github.com/Kitware/CMake/releases/download/v3.27.7/cmake-3.27.7-linux-x86_64.sh \ + -q -O /tmp/cmake-install.sh \ + && chmod u+x /tmp/cmake-install.sh \ + && mkdir /opt/cmake-3.24.1 \ + && /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-3.24.1 \ + && rm /tmp/cmake-install.sh \ + && ln -s /opt/cmake-3.24.1/bin/* /usr/local/bin + +WORKDIR /obcpp + +COPY . /obcpp + +WORKDIR /obcpp/build + +# RUN cmake .. + +# RUN make obcpp # parallelize this + +CMD ["/bin/bash"] +# CMD ["/obcpp/build/bin/obcpp"] + +# docker build - < Dockerfile +# docker build -t "test" . +# docker run -it --rm test + +# https://www.jmoisio.eu/en/blog/2020/06/01/building-cpp-containers-using-docker-and-cmake/ +# find -name "*Cache.txt" -delete + +# TODO: this container is way too big for some reason. Refer to above blog post for staged build (may not want to do that for development tho. I am unable to get devcontainers running) \ No newline at end of file From 1f2b4093f78f61ebcc252f8b59d8e0b18d58994a Mon Sep 17 00:00:00 2001 From: Anthony Tarbinian Date: Thu, 26 Oct 2023 23:44:33 +0000 Subject: [PATCH 10/12] temporarily removing opencv --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 60e39f8c..8c832155 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,8 @@ add_subdirectory(${DEPS_DIRECTORY}/json) # add_subdirectory(${DEPS_DIRECTORY}/torch) # ============================= include(${DEPS_DIRECTORY}/torch/CMakeLists.txt) -include(${DEPS_DIRECTORY}/opencv/CMakeLists.txt) +# NOTE: temporarily leaving out opencv until we have it working in dev container +# include(${DEPS_DIRECTORY}/opencv/CMakeLists.txt) # ============================= # Unit tests add_subdirectory(tests) From 590b04ac4ec12b591024f47027b59880cdb4df3e Mon Sep 17 00:00:00 2001 From: Anthony Tarbinian Date: Thu, 26 Oct 2023 23:46:34 +0000 Subject: [PATCH 11/12] remove cruft from opencv war --- CMakeLists.txt | 5 ----- deps/opencv/CMakeLists.txt | 5 ----- 2 files changed, 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c832155..c7f95417 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,9 +41,6 @@ file(GLOB_RECURSE HEADERS "include/*.hpp") # ============================= # Executable set(INCLUDE_DIRECTORY ${PROJECT_SOURCE_DIR}/include) -message("OpenCV include directories: ${OpenCV_INCLUDE_DIRS}") - -include_directories(${INCLUDE_DIRECTORY} ${OpenCV_INCLUDE_DIRS} ) add_executable(${PROJECT_NAME} ${SOURCES}) # ============================= @@ -53,8 +50,6 @@ set(DEPS_DIRECTORY ${PROJECT_SOURCE_DIR}/deps) add_subdirectory(${DEPS_DIRECTORY}/arena-sdk) add_subdirectory(${DEPS_DIRECTORY}/json) -# add_subdirectory(${DEPS_DIRECTORY}/opencv) -# add_subdirectory(${DEPS_DIRECTORY}/torch) # ============================= include(${DEPS_DIRECTORY}/torch/CMakeLists.txt) # NOTE: temporarily leaving out opencv until we have it working in dev container diff --git a/deps/opencv/CMakeLists.txt b/deps/opencv/CMakeLists.txt index e0ca1d74..fc577d20 100644 --- a/deps/opencv/CMakeLists.txt +++ b/deps/opencv/CMakeLists.txt @@ -41,8 +41,3 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${OPENCV_MODULE_opencv_ml_LOCATION}/include # ${HEADERS} ) - -# message(FATAL_ERROR ${OpenCVContrib_SOURCE_DIR}) - -get_target_property(TMP ${PROJECT_NAME} INCLUDE_DIRECTORIES) -# message(FATAL_ERROR ${TMP}) \ No newline at end of file From 8172d9361ef3e7a9a1ce2b5cf57104350b6170ba Mon Sep 17 00:00:00 2001 From: Anthony Tarbinian Date: Thu, 26 Oct 2023 23:47:56 +0000 Subject: [PATCH 12/12] mend --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7f95417..b90df5e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ file(GLOB_RECURSE HEADERS "include/*.hpp") # Executable set(INCLUDE_DIRECTORY ${PROJECT_SOURCE_DIR}/include) add_executable(${PROJECT_NAME} ${SOURCES}) +include_directories(${INCLUDE_DIRECTORY}) # ============================= # =============================