Skip to content

Commit

Permalink
improve build process even more (AlexeyAB#7610)
Browse files Browse the repository at this point in the history
* test for shared libs

* improve flag handling

* build so lib in ci

* clone vcpkg if not found

* fix

* improve clang handling

* bump vcpkg.json version

* gemm.c compatible with ARM

* remove unnecessary vcpkg.json field

* do not unnecessarily rebuild vcpkg in the CI build stage

* use alexeyab nuget cache

* enable self-removal of build folder

* add interactivity in build.ps1 if not opt-out

* spellcheck README

* fix another leftover spelling error

* also auto-update darknet if possible

* do not self-update darknet in CI
  • Loading branch information
cenit authored Apr 18, 2021
1 parent 1f4598a commit ba8f7bf
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 140 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ jobs:
./vcpkg/bootstrap-vcpkg.sh;
mono $(./vcpkg/vcpkg fetch nuget | tail -n 1)
sources add
-source "https://nuget.pkg.github.com/cenit/index.json"
-source "https://nuget.pkg.github.com/AlexeyAB/index.json"
-storepasswordincleartext
-name "vcpkgbinarycache"
-username "cenit"
-username "AlexeyAB"
-password "${{ secrets.GITHUB_TOKEN }}"
- name: 'Build'
Expand All @@ -124,7 +124,7 @@ jobs:
CUDA_PATH: "/usr/local/cuda"
CUDA_TOOLKIT_ROOT_DIR: "/usr/local/cuda"
LD_LIBRARY_PATH: "/usr/local/cuda/lib64:/usr/local/cuda/lib64/stubs:$LD_LIBRARY_PATH"
run: ./build.ps1 -UseVCPKG -EnableOPENCV -EnableCUDA -ForceStaticLib
run: ./build.ps1 -UseVCPKG -DoNotUpdateVCPKG -EnableOPENCV -EnableCUDA -DisableInteractive -DoNotUpdateDARKNET

- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
CUDA_PATH: "/usr/local/cuda"
CUDA_TOOLKIT_ROOT_DIR: "/usr/local/cuda"
LD_LIBRARY_PATH: "/usr/local/cuda/lib64:/usr/local/cuda/lib64/stubs:$LD_LIBRARY_PATH"
run: ./build.ps1 -EnableOPENCV
run: ./build.ps1 -EnableOPENCV -DisableInteractive -DoNotUpdateDARKNET

- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -222,7 +222,7 @@ jobs:
CUDA_PATH: "/usr/local/cuda"
CUDA_TOOLKIT_ROOT_DIR: "/usr/local/cuda"
LD_LIBRARY_PATH: "/usr/local/cuda/lib64:/usr/local/cuda/lib64/stubs:$LD_LIBRARY_PATH"
run: ./build.ps1 -EnableOPENCV -EnableCUDA
run: ./build.ps1 -EnableOPENCV -EnableCUDA -DisableInteractive -DoNotUpdateDARKNET

- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -251,7 +251,7 @@ jobs:

- name: 'Build'
shell: pwsh
run: ./build.ps1 -ForceCPP
run: ./build.ps1 -ForceCPP -DisableInteractive -DoNotUpdateDARKNET


osx-vcpkg:
Expand All @@ -271,15 +271,15 @@ jobs:
./vcpkg/bootstrap-vcpkg.sh;
mono $(./vcpkg/vcpkg fetch nuget | tail -n 1)
sources add
-source "https://nuget.pkg.github.com/cenit/index.json"
-source "https://nuget.pkg.github.com/AlexeyAB/index.json"
-storepasswordincleartext
-name "vcpkgbinarycache"
-username "cenit"
-username "AlexeyAB"
-password "${{ secrets.GITHUB_TOKEN }}"
- name: 'Build'
shell: pwsh
run: ./build.ps1 -UseVCPKG
run: ./build.ps1 -UseVCPKG -DoNotUpdateVCPKG -DisableInteractive -DoNotUpdateDARKNET

- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -311,7 +311,7 @@ jobs:

- name: 'Build'
shell: pwsh
run: ./build.ps1 -EnableOPENCV
run: ./build.ps1 -EnableOPENCV -DisableInteractive -DoNotUpdateDARKNET

- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -340,7 +340,7 @@ jobs:

- name: 'Build'
shell: pwsh
run: ./build.ps1 -ForceCPP
run: ./build.ps1 -ForceCPP -DisableInteractive -DoNotUpdateDARKNET


win-vcpkg:
Expand All @@ -357,15 +357,15 @@ jobs:
./vcpkg/bootstrap-vcpkg.sh;
$(./vcpkg/vcpkg fetch nuget | tail -n 1)
sources add
-source "https://nuget.pkg.github.com/cenit/index.json"
-source "https://nuget.pkg.github.com/AlexeyAB/index.json"
-storepasswordincleartext
-name "vcpkgbinarycache"
-username "cenit"
-username "AlexeyAB"
-password "${{ secrets.GITHUB_TOKEN }}"
- name: 'Build'
shell: pwsh
run: ./build.ps1 -UseVCPKG -EnableOPENCV
run: ./build.ps1 -UseVCPKG -DoNotUpdateVCPKG -EnableOPENCV -DisableInteractive -DoNotUpdateDARKNET

- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -398,7 +398,7 @@ jobs:

- name: 'Build'
shell: pwsh
run: ./build.ps1
run: ./build.ps1 -DisableInteractive -DoNotUpdateDARKNET

- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -431,7 +431,7 @@ jobs:

- name: 'Build'
shell: pwsh
run: ./build.ps1 -ForceCPP
run: ./build.ps1 -ForceCPP -DisableInteractive -DoNotUpdateDARKNET


win-intlibs-cuda:
Expand All @@ -454,7 +454,7 @@ jobs:
CUDA_TOOLKIT_ROOT_DIR: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.2"
CUDACXX: "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.2\\bin\\nvcc.exe"
shell: pwsh
run: ./build.ps1 -EnableCUDA
run: ./build.ps1 -EnableCUDA -DisableInteractive -DoNotUpdateDARKNET


mingw:
Expand Down
38 changes: 21 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ option(ENABLE_CUDNN "Enable CUDNN" ON)
option(ENABLE_CUDNN_HALF "Enable CUDNN Half precision" ON)
option(ENABLE_ZED_CAMERA "Enable ZED Camera support" ON)
option(ENABLE_VCPKG_INTEGRATION "Enable VCPKG integration" ON)
option(VCPKG_BUILD_OPENCV_WITH_CUDA "Build OpenCV with CUDA extension integration" ON)

if(ENABLE_OPENCV_WITH_CUDA AND NOT APPLE)
if(VCPKG_BUILD_OPENCV_WITH_CUDA AND NOT APPLE)
list(APPEND VCPKG_MANIFEST_FEATURES "opencv-cuda")
endif()
if(ENABLE_CUDA AND NOT APPLE)
Expand All @@ -33,18 +34,6 @@ if(ENABLE_CUDNN AND ENABLE_CUDA AND NOT APPLE)
list(APPEND VCPKG_MANIFEST_FEATURES "cudnn")
endif()

if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_COMPILER_IS_GNUCC_OR_CLANG TRUE)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_COMPILER_IS_CLANG TRUE)
else()
set(CMAKE_COMPILER_IS_CLANG FALSE)
endif()
else()
set(CMAKE_COMPILER_IS_GNUCC_OR_CLANG FALSE)
set(CMAKE_COMPILER_IS_CLANG FALSE)
endif()

if(NOT CMAKE_HOST_SYSTEM_PROCESSOR AND NOT WIN32)
execute_process(COMMAND "uname" "-m" OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
Expand Down Expand Up @@ -87,6 +76,18 @@ enable_language(CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH})

if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_COMPILER_IS_GNUCC_OR_CLANG TRUE)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "clang")
set(CMAKE_COMPILER_IS_CLANG TRUE)
else()
set(CMAKE_COMPILER_IS_CLANG FALSE)
endif()
else()
set(CMAKE_COMPILER_IS_GNUCC_OR_CLANG FALSE)
set(CMAKE_COMPILER_IS_CLANG FALSE)
endif()

set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
Expand Down Expand Up @@ -201,12 +202,14 @@ endif()

set(ADDITIONAL_CXX_FLAGS "-Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -Wno-deprecated-declarations -Wno-write-strings")
set(ADDITIONAL_C_FLAGS "-Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -Wno-deprecated-declarations -Wno-write-strings")
if(UNIX AND BUILD_SHARED_LIBS AND NOT CMAKE_COMPILER_IS_CLANG)
set(SHAREDLIB_CXX_FLAGS "-Wl,-Bsymbolic")
set(SHAREDLIB_C_FLAGS "-Wl,-Bsymbolic")
endif()

if(MSVC)
set(ADDITIONAL_CXX_FLAGS "/wd4013 /wd4018 /wd4028 /wd4047 /wd4068 /wd4090 /wd4101 /wd4113 /wd4133 /wd4190 /wd4244 /wd4267 /wd4305 /wd4477 /wd4996 /wd4819 /fp:fast")
set(ADDITIONAL_C_FLAGS "/wd4013 /wd4018 /wd4028 /wd4047 /wd4068 /wd4090 /wd4101 /wd4113 /wd4133 /wd4190 /wd4244 /wd4267 /wd4305 /wd4477 /wd4996 /wd4819 /fp:fast")
set(CMAKE_CXX_FLAGS "${ADDITIONAL_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${ADDITIONAL_C_FLAGS} ${CMAKE_C_FLAGS}")
string(REGEX REPLACE "/O2" "/Ox" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
string(REGEX REPLACE "/O2" "/Ox" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
endif()
Expand All @@ -218,8 +221,6 @@ if(CMAKE_COMPILER_IS_GNUCC_OR_CLANG)
set(CMAKE_C_FLAGS "-pthread ${CMAKE_C_FLAGS}")
endif()
endif()
set(CMAKE_CXX_FLAGS "${ADDITIONAL_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${ADDITIONAL_C_FLAGS} ${CMAKE_C_FLAGS}")
string(REGEX REPLACE "-O0" "-Og" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REGEX REPLACE "-O3" "-Ofast" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
string(REGEX REPLACE "-O0" "-Og" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
Expand All @@ -230,6 +231,9 @@ if(CMAKE_COMPILER_IS_GNUCC_OR_CLANG)
endif()
endif()

set(CMAKE_CXX_FLAGS "${ADDITIONAL_CXX_FLAGS} ${SHAREDLIB_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${ADDITIONAL_C_FLAGS} ${SHAREDLIB_C_FLAGS} ${CMAKE_C_FLAGS}")

if(OpenCV_FOUND)
if(ENABLE_CUDA AND NOT OpenCV_CUDA_VERSION)
set(BUILD_USELIB_TRACK "FALSE" CACHE BOOL "Build uselib_track" FORCE)
Expand Down
Loading

0 comments on commit ba8f7bf

Please sign in to comment.