move Stb lib to 3rdparty folder

This commit is contained in:
Stefano Sinigardi 2019-03-13 22:56:44 +01:00
parent dd27d67f58
commit 5be12ce058
31 changed files with 65 additions and 40 deletions

View File

@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src> $<INSTALL_INTERFACE:include>)
target_include_directories(uselib_track PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src> $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${Stb_INCLUDE_DIR}>)
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 $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src> $<INSTALL_INTERFACE:include>)
target_include_directories(darklib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src> $<INSTALL_INTERFACE:include>)
target_include_directories(uselib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src> $<INSTALL_INTERFACE:include>)
target_include_directories(darknet PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src> $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${Stb_INCLUDE_DIR}>)
target_include_directories(darklib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src> $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${Stb_INCLUDE_DIR}>)
target_include_directories(uselib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src> $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${Stb_INCLUDE_DIR}>)
if(CUDNN_FOUND)
target_link_libraries(darknet PRIVATE CuDNN::CuDNN)

View File

@ -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()

View File

@ -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)

View File

@ -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
}

View File

@ -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

30
cmake/Modules/FindStb.cmake Executable file
View File

@ -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)

0
image_yolov2.sh Normal file → Executable file
View File

0
image_yolov3.sh Normal file → Executable file
View File

0
json_mjpeg_streams.sh Normal file → Executable file
View File

0
net_cam_v3.sh Normal file → Executable file
View File

0
video_v2.sh Normal file → Executable file
View File

0
video_yolov3.sh Normal file → Executable file
View File