From 5be12ce0589d822b9fb836f8db45ccedce832b85 Mon Sep 17 00:00:00 2001 From: Stefano Sinigardi Date: Wed, 13 Mar 2019 22:56:44 +0100 Subject: [PATCH] move Stb lib to 3rdparty folder --- .../{ => pthreads}/dll/x64/pthreadGC2.dll | Bin .../{ => pthreads}/dll/x64/pthreadVC2.dll | Bin .../{ => pthreads}/dll/x86/pthreadGC2.dll | Bin .../{ => pthreads}/dll/x86/pthreadGCE2.dll | Bin .../{ => pthreads}/dll/x86/pthreadVC2.dll | Bin .../{ => pthreads}/dll/x86/pthreadVCE2.dll | Bin .../{ => pthreads}/dll/x86/pthreadVSE2.dll | Bin 3rdparty/{ => pthreads}/include/pthread.h | 0 3rdparty/{ => pthreads}/include/sched.h | 0 3rdparty/{ => pthreads}/include/semaphore.h | 0 .../{ => pthreads}/lib/x64/libpthreadGC2.a | Bin .../{ => pthreads}/lib/x64/pthreadVC2.lib | Bin .../{ => pthreads}/lib/x86/libpthreadGC2.a | Bin .../{ => pthreads}/lib/x86/libpthreadGCE2.a | Bin .../{ => pthreads}/lib/x86/pthreadVC2.lib | Bin .../{ => pthreads}/lib/x86/pthreadVCE2.lib | Bin .../{ => pthreads}/lib/x86/pthreadVSE2.lib | Bin {src => 3rdparty/stb/include}/stb_image.h | 0 .../stb/include}/stb_image_write.h | 0 CMakeLists.txt | 15 ++++----- DarknetConfig.cmake.in | 11 +++++-- Makefile | 27 ++++++++-------- build.ps1 | 8 +---- build.sh | 14 ++++---- cmake/Modules/FindStb.cmake | 30 ++++++++++++++++++ image_yolov2.sh | 0 image_yolov3.sh | 0 json_mjpeg_streams.sh | 0 net_cam_v3.sh | 0 video_v2.sh | 0 video_yolov3.sh | 0 31 files changed, 65 insertions(+), 40 deletions(-) rename 3rdparty/{ => pthreads}/dll/x64/pthreadGC2.dll (100%) rename 3rdparty/{ => pthreads}/dll/x64/pthreadVC2.dll (100%) rename 3rdparty/{ => pthreads}/dll/x86/pthreadGC2.dll (100%) rename 3rdparty/{ => pthreads}/dll/x86/pthreadGCE2.dll (100%) rename 3rdparty/{ => pthreads}/dll/x86/pthreadVC2.dll (100%) rename 3rdparty/{ => pthreads}/dll/x86/pthreadVCE2.dll (100%) rename 3rdparty/{ => pthreads}/dll/x86/pthreadVSE2.dll (100%) rename 3rdparty/{ => pthreads}/include/pthread.h (100%) rename 3rdparty/{ => pthreads}/include/sched.h (100%) rename 3rdparty/{ => pthreads}/include/semaphore.h (100%) rename 3rdparty/{ => pthreads}/lib/x64/libpthreadGC2.a (100%) rename 3rdparty/{ => pthreads}/lib/x64/pthreadVC2.lib (100%) rename 3rdparty/{ => pthreads}/lib/x86/libpthreadGC2.a (100%) rename 3rdparty/{ => pthreads}/lib/x86/libpthreadGCE2.a (100%) rename 3rdparty/{ => pthreads}/lib/x86/pthreadVC2.lib (100%) rename 3rdparty/{ => pthreads}/lib/x86/pthreadVCE2.lib (100%) rename 3rdparty/{ => pthreads}/lib/x86/pthreadVSE2.lib (100%) rename {src => 3rdparty/stb/include}/stb_image.h (100%) rename {src => 3rdparty/stb/include}/stb_image_write.h (100%) create mode 100755 cmake/Modules/FindStb.cmake mode change 100644 => 100755 image_yolov2.sh mode change 100644 => 100755 image_yolov3.sh mode change 100644 => 100755 json_mjpeg_streams.sh mode change 100644 => 100755 net_cam_v3.sh mode change 100644 => 100755 video_v2.sh mode change 100644 => 100755 video_yolov3.sh diff --git a/3rdparty/dll/x64/pthreadGC2.dll b/3rdparty/pthreads/dll/x64/pthreadGC2.dll similarity index 100% rename from 3rdparty/dll/x64/pthreadGC2.dll rename to 3rdparty/pthreads/dll/x64/pthreadGC2.dll diff --git a/3rdparty/dll/x64/pthreadVC2.dll b/3rdparty/pthreads/dll/x64/pthreadVC2.dll similarity index 100% rename from 3rdparty/dll/x64/pthreadVC2.dll rename to 3rdparty/pthreads/dll/x64/pthreadVC2.dll diff --git a/3rdparty/dll/x86/pthreadGC2.dll b/3rdparty/pthreads/dll/x86/pthreadGC2.dll similarity index 100% rename from 3rdparty/dll/x86/pthreadGC2.dll rename to 3rdparty/pthreads/dll/x86/pthreadGC2.dll diff --git a/3rdparty/dll/x86/pthreadGCE2.dll b/3rdparty/pthreads/dll/x86/pthreadGCE2.dll similarity index 100% rename from 3rdparty/dll/x86/pthreadGCE2.dll rename to 3rdparty/pthreads/dll/x86/pthreadGCE2.dll diff --git a/3rdparty/dll/x86/pthreadVC2.dll b/3rdparty/pthreads/dll/x86/pthreadVC2.dll similarity index 100% rename from 3rdparty/dll/x86/pthreadVC2.dll rename to 3rdparty/pthreads/dll/x86/pthreadVC2.dll diff --git a/3rdparty/dll/x86/pthreadVCE2.dll b/3rdparty/pthreads/dll/x86/pthreadVCE2.dll similarity index 100% rename from 3rdparty/dll/x86/pthreadVCE2.dll rename to 3rdparty/pthreads/dll/x86/pthreadVCE2.dll diff --git a/3rdparty/dll/x86/pthreadVSE2.dll b/3rdparty/pthreads/dll/x86/pthreadVSE2.dll similarity index 100% rename from 3rdparty/dll/x86/pthreadVSE2.dll rename to 3rdparty/pthreads/dll/x86/pthreadVSE2.dll diff --git a/3rdparty/include/pthread.h b/3rdparty/pthreads/include/pthread.h similarity index 100% rename from 3rdparty/include/pthread.h rename to 3rdparty/pthreads/include/pthread.h diff --git a/3rdparty/include/sched.h b/3rdparty/pthreads/include/sched.h similarity index 100% rename from 3rdparty/include/sched.h rename to 3rdparty/pthreads/include/sched.h diff --git a/3rdparty/include/semaphore.h b/3rdparty/pthreads/include/semaphore.h similarity index 100% rename from 3rdparty/include/semaphore.h rename to 3rdparty/pthreads/include/semaphore.h diff --git a/3rdparty/lib/x64/libpthreadGC2.a b/3rdparty/pthreads/lib/x64/libpthreadGC2.a similarity index 100% rename from 3rdparty/lib/x64/libpthreadGC2.a rename to 3rdparty/pthreads/lib/x64/libpthreadGC2.a diff --git a/3rdparty/lib/x64/pthreadVC2.lib b/3rdparty/pthreads/lib/x64/pthreadVC2.lib similarity index 100% rename from 3rdparty/lib/x64/pthreadVC2.lib rename to 3rdparty/pthreads/lib/x64/pthreadVC2.lib diff --git a/3rdparty/lib/x86/libpthreadGC2.a b/3rdparty/pthreads/lib/x86/libpthreadGC2.a similarity index 100% rename from 3rdparty/lib/x86/libpthreadGC2.a rename to 3rdparty/pthreads/lib/x86/libpthreadGC2.a diff --git a/3rdparty/lib/x86/libpthreadGCE2.a b/3rdparty/pthreads/lib/x86/libpthreadGCE2.a similarity index 100% rename from 3rdparty/lib/x86/libpthreadGCE2.a rename to 3rdparty/pthreads/lib/x86/libpthreadGCE2.a diff --git a/3rdparty/lib/x86/pthreadVC2.lib b/3rdparty/pthreads/lib/x86/pthreadVC2.lib similarity index 100% rename from 3rdparty/lib/x86/pthreadVC2.lib rename to 3rdparty/pthreads/lib/x86/pthreadVC2.lib diff --git a/3rdparty/lib/x86/pthreadVCE2.lib b/3rdparty/pthreads/lib/x86/pthreadVCE2.lib similarity index 100% rename from 3rdparty/lib/x86/pthreadVCE2.lib rename to 3rdparty/pthreads/lib/x86/pthreadVCE2.lib diff --git a/3rdparty/lib/x86/pthreadVSE2.lib b/3rdparty/pthreads/lib/x86/pthreadVSE2.lib similarity index 100% rename from 3rdparty/lib/x86/pthreadVSE2.lib rename to 3rdparty/pthreads/lib/x86/pthreadVSE2.lib diff --git a/src/stb_image.h b/3rdparty/stb/include/stb_image.h similarity index 100% rename from src/stb_image.h rename to 3rdparty/stb/include/stb_image.h diff --git a/src/stb_image_write.h b/3rdparty/stb/include/stb_image_write.h similarity index 100% rename from src/stb_image_write.h rename to 3rdparty/stb/include/stb_image_write.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e6e6323a..8c6c38a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,14 +73,12 @@ if(ENABLE_CUDA AND NOT CUDA_COMPUTE_MODEL) endif() if(USE_INTEGRATED_LIBS) - include_directories(${CMAKE_CURRENT_LIST_DIR}/3rdparty/include) - set(PThreads_windows_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/3rdparty/include) - set(PThreads_windows_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/3rdparty/lib/x64/pthreadVC2.lib) + set(PThreads_windows_DIR ${CMAKE_CURRENT_LIST_DIR}/3rdparty/pthreads CACHE PATH "Path where pthreads for windows can be located") add_definitions(-D_TIMESPEC_DEFINED) endif() +set(Stb_DIR ${CMAKE_CURRENT_LIST_DIR}/3rdparty/stb/include CACHE PATH "Path where Stb image library can be located") set(CMAKE_DEBUG_POSTFIX d) - add_definitions(-DUSE_CMAKE_LIBS) if(MSVC) @@ -108,6 +106,7 @@ set(ENABLE_OPENCV "TRUE" CACHE BOOL "Enable OpenCV integration") if(ENABLE_OPENCV) find_package(OpenCV) endif() +find_package(Stb REQUIRED) set(SKIP_USELIB_TRACK "FALSE" CACHE BOOL "Skip building uselib_track" FORCE) if(OpenCV_FOUND) @@ -241,7 +240,7 @@ if(OpenCV_VERSION VERSION_GREATER "3.0" AND NOT SKIP_USELIB_TRACK) add_executable(uselib_track ${CMAKE_CURRENT_LIST_DIR}/src/yolo_console_dll.cpp) target_compile_definitions(uselib_track PRIVATE TRACK_OPTFLOW=1) set_target_properties(uselib_track PROPERTIES LINKER_LANGUAGE CXX) - target_include_directories(uselib_track PUBLIC $ $ $) + target_include_directories(uselib_track PUBLIC $ $ $ $) target_link_libraries(uselib_track PRIVATE ${OpenCV_LIBS}) endif() @@ -252,9 +251,9 @@ add_executable(darknet ${CMAKE_CURRENT_LIST_DIR}/src/darknet.c ${sources} ${head set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/src/darknet.c PROPERTIES LANGUAGE CXX) set_target_properties(darknet PROPERTIES LINKER_LANGUAGE CXX) -target_include_directories(darknet PUBLIC $ $ $) -target_include_directories(darklib PUBLIC $ $ $) -target_include_directories(uselib PUBLIC $ $ $) +target_include_directories(darknet PUBLIC $ $ $ $) +target_include_directories(darklib PUBLIC $ $ $ $) +target_include_directories(uselib PUBLIC $ $ $ $) if(CUDNN_FOUND) target_link_libraries(darknet PRIVATE CuDNN::CuDNN) diff --git a/DarknetConfig.cmake.in b/DarknetConfig.cmake.in index 0e8956f9..606503f2 100644 --- a/DarknetConfig.cmake.in +++ b/DarknetConfig.cmake.in @@ -6,10 +6,15 @@ # Compute paths get_filename_component(Darknet_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) set(Darknet_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@") +list(APPEND CMAKE_MODULE_PATH "${Darknet_CMAKE_DIR}") include(CMakeFindDependencyMacro) -find_dependency(OpenCV REQUIRED) +if(@ENABLE_OPENCV@) + find_dependency(OpenCV REQUIRED) +endif() + +find_dependency(Stb REQUIRED HINTS "@Stb_DIR@") if(@ENABLE_CUDA@) find_dependency(CUDNN) @@ -18,11 +23,11 @@ endif() set(CMAKE_THREAD_PREFER_PTHREAD ON) find_dependency(Threads) -if(@MSVC@) +if(MSVC) find_dependency(PThreads_windows) endif() -if("@CMAKE_VERSION@" VERSION_GREATER "3.9.0") +if("${CMAKE_VERSION}" VERSION_GREATER "3.9.0") find_dependency(OpenMP) endif() diff --git a/Makefile b/Makefile index d06e6ace..dd6e6e2e 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ OS := $(shell uname) # GTX 1080, GTX 1070, GTX 1060, GTX 1050, GTX 1030, Titan Xp, Tesla P40, Tesla P4 # ARCH= -gencode arch=compute_61,code=sm_61 -gencode arch=compute_61,code=compute_61 -# GP100/Tesla P100 – DGX-1 +# GP100/Tesla P100 - DGX-1 # ARCH= -gencode arch=compute_60,code=sm_60 # For Jetson TX1, Tegra X1, DRIVE CX, DRIVE PX - uncomment: @@ -53,30 +53,30 @@ endif CC=gcc CPP=g++ -NVCC=nvcc +NVCC=nvcc OPTS=-Ofast -LDFLAGS= -lm -pthread -COMMON= -Iinclude/ +LDFLAGS= -lm -pthread +COMMON= -Iinclude/ -I3rdparty/stb/include CFLAGS=-Wall -Wfatal-errors -Wno-unused-result -Wno-unknown-pragmas -fPIC -ifeq ($(DEBUG), 1) +ifeq ($(DEBUG), 1) #OPTS= -O0 -g #OPTS= -Og -g COMMON+= -DDEBUG CFLAGS+= -DDEBUG else -ifeq ($(AVX), 1) +ifeq ($(AVX), 1) CFLAGS+= -ffp-contract=fast -mavx -mavx2 -msse3 -msse4.1 -msse4.2 -msse4a endif endif CFLAGS+=$(OPTS) -ifeq ($(OPENCV), 1) +ifeq ($(OPENCV), 1) COMMON+= -DOPENCV CFLAGS+= -DOPENCV -LDFLAGS+= `pkg-config --libs opencv` -COMMON+= `pkg-config --cflags opencv` +LDFLAGS+= `pkg-config --libs opencv` +COMMON+= `pkg-config --cflags opencv` endif ifeq ($(OPENMP), 1) @@ -112,8 +112,8 @@ ARCH+= -gencode arch=compute_70,code=[sm_70,compute_70] endif OBJ=http_stream.o gemm.o utils.o cuda.o convolutional_layer.o list.o image.o activations.o im2col.o col2im.o blas.o crop_layer.o dropout_layer.o maxpool_layer.o softmax_layer.o data.o matrix.o network.o connected_layer.o cost_layer.o parser.o option_list.o darknet.o detection_layer.o captcha.o route_layer.o writing.o box.o nightmare.o normalization_layer.o avgpool_layer.o coco.o dice.o yolo.o detector.o layer.o compare.o classifier.o local_layer.o swag.o shortcut_layer.o activation_layer.o rnn_layer.o gru_layer.o rnn.o rnn_vid.o crnn_layer.o demo.o tag.o cifar.o go.o batchnorm_layer.o art.o region_layer.o reorg_layer.o reorg_old_layer.o super.o voxel.o tree.o yolo_layer.o upsample_layer.o lstm_layer.o -ifeq ($(GPU), 1) -LDFLAGS+= -lstdc++ +ifeq ($(GPU), 1) +LDFLAGS+= -lstdc++ OBJ+=convolutional_kernels.o activation_kernels.o im2col_kernels.o col2im_kernels.o blas_kernels.o crop_layer_kernels.o dropout_layer_kernels.o maxpool_layer_kernels.o network_kernels.o avgpool_layer_kernels.o endif @@ -122,12 +122,12 @@ DEPS = $(wildcard src/*.h) Makefile include/darknet.h all: obj backup results setchmod $(EXEC) $(LIBNAMESO) $(APPNAMESO) -ifeq ($(LIBSO), 1) +ifeq ($(LIBSO), 1) CFLAGS+= -fPIC $(LIBNAMESO): $(OBJS) include/yolo_v2_class.hpp src/yolo_v2_class.cpp $(CPP) -shared -std=c++11 -fvisibility=hidden -DLIB_EXPORTS $(COMMON) $(CFLAGS) $(OBJS) src/yolo_v2_class.cpp -o $@ $(LDFLAGS) - + $(APPNAMESO): $(LIBNAMESO) include/yolo_v2_class.hpp src/yolo_console_dll.cpp $(CPP) -std=c++11 $(COMMON) $(CFLAGS) -o $@ src/yolo_console_dll.cpp $(LDFLAGS) -L ./ -l:$(LIBNAMESO) endif @@ -157,4 +157,3 @@ setchmod: clean: rm -rf $(OBJS) $(EXEC) $(LIBNAMESO) $(APPNAMESO) - diff --git a/build.ps1 b/build.ps1 index e5a1e29b..8282a8a2 100755 --- a/build.ps1 +++ b/build.ps1 @@ -63,7 +63,7 @@ if (Test-Path env:CUDA_PATH) { } } -if (Test-Path $vcpkg_path) { +if ($vcpkg_path) { # RELEASE New-Item -Path .\build_win_release -ItemType directory -Force Set-Location build_win_release @@ -72,8 +72,6 @@ if (Test-Path $vcpkg_path) { Remove-Item DarknetConfig.cmake Remove-Item DarknetConfigVersion.cmake Set-Location .. -# Remove-Item -Force DarknetConfig.cmake -# Remove-Item -Force DarknetConfigVersion.cmake # DEBUG New-Item -Path .\build_win_debug -ItemType directory -Force @@ -83,8 +81,6 @@ if (Test-Path $vcpkg_path) { Remove-Item DarknetConfig.cmake Remove-Item DarknetConfigVersion.cmake Set-Location .. -# Remove-Item -Force DarknetConfig.cmake -# Remove-Item -Force DarknetConfigVersion.cmake } else { # USE LOCAL PTHREAD LIB, NO VCPKG, ONLY RELEASE @@ -96,6 +92,4 @@ else { Remove-Item DarknetConfig.cmake Remove-Item DarknetConfigVersion.cmake Set-Location .. -# Remove-Item -Force DarknetConfig.cmake -# Remove-Item -Force DarknetConfigVersion.cmake } diff --git a/build.sh b/build.sh index b41eddfe..7ff54d91 100755 --- a/build.sh +++ b/build.sh @@ -18,11 +18,10 @@ cd build_release cmake .. -DCMAKE_BUILD_TYPE=Release ${additional_defines} cmake --build . --target install -- -j${number_of_build_workers} #cmake --build . --target install --parallel ${number_of_build_workers} #valid only for CMake 3.12+ -rm DarknetConfig.cmake -rm DarknetConfigVersion.cmake +rm -f DarknetConfig.cmake +rm -f DarknetConfigVersion.cmake cd .. -rm DarknetConfig.cmake -rm DarknetConfigVersion.cmake +cp cmake/Modules/*.cmake share/darknet # DEBUG mkdir -p build_debug @@ -30,8 +29,7 @@ cd build_debug cmake .. -DCMAKE_BUILD_TYPE=Debug ${additional_defines} cmake --build . --target install -- -j${number_of_build_workers} #cmake --build . --target install --parallel ${number_of_build_workers} #valid only for CMake 3.12+ -rm DarknetConfig.cmake -rm DarknetConfigVersion.cmake +rm -f DarknetConfig.cmake +rm -f DarknetConfigVersion.cmake cd .. -rm DarknetConfig.cmake -rm DarknetConfigVersion.cmake +cp cmake/Modules/*.cmake share/darknet diff --git a/cmake/Modules/FindStb.cmake b/cmake/Modules/FindStb.cmake new file mode 100755 index 00000000..33ec81da --- /dev/null +++ b/cmake/Modules/FindStb.cmake @@ -0,0 +1,30 @@ +# Distributed under the OSI-approved BSD 3-Clause License. +# Copyright Stefano Sinigardi + +#.rst: +# FindStb +# ------------ +# +# Find the Stb include headers. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module defines the following variables: +# +# ``Stb_FOUND`` +# True if Stb library found +# +# ``Stb_INCLUDE_DIR`` +# Location of Stb headers +# + +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) +include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake) + +if(NOT Stb_INCLUDE_DIR) + find_path(Stb_INCLUDE_DIR NAMES stb_image.h PATHS ${Stb_DIR}) +endif() + +find_package_handle_standard_args(Stb DEFAULT_MSG Stb_INCLUDE_DIR) +mark_as_advanced(Stb_INCLUDE_DIR) diff --git a/image_yolov2.sh b/image_yolov2.sh old mode 100644 new mode 100755 diff --git a/image_yolov3.sh b/image_yolov3.sh old mode 100644 new mode 100755 diff --git a/json_mjpeg_streams.sh b/json_mjpeg_streams.sh old mode 100644 new mode 100755 diff --git a/net_cam_v3.sh b/net_cam_v3.sh old mode 100644 new mode 100755 diff --git a/video_v2.sh b/video_v2.sh old mode 100644 new mode 100755 diff --git a/video_yolov3.sh b/video_yolov3.sh old mode 100644 new mode 100755