Skip to content

Commit

Permalink
[cmake] upgrade to 3.18 (#12612)
Browse files Browse the repository at this point in the history
Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
  • Loading branch information
3 people authored Oct 20, 2020
1 parent bb7d4f2 commit eb18317
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 6,106 deletions.
2 changes: 1 addition & 1 deletion ports/folly/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: folly
Version: 2019.10.21.00
Port-Version: 4
Port-Version: 5
Homepage: https://github.com/facebook/folly
Description: An open-source C++ library developed and used at Facebook. The library is UNSTABLE on Windows
Build-Depends: openssl, libevent, double-conversion, glog, gflags, boost-chrono, boost-context, boost-conversion, boost-crc, boost-date-time, boost-filesystem, boost-multi-index, boost-program-options, boost-regex, boost-system, boost-thread, boost-smart-ptr
Expand Down
48 changes: 48 additions & 0 deletions ports/folly/fix-cmake-3.18.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
diff --git a/CMake/GenPkgConfig.cmake b/CMake/GenPkgConfig.cmake
index f8701b4..00a1e75 100644
--- a/CMake/GenPkgConfig.cmake
+++ b/CMake/GenPkgConfig.cmake
@@ -92,7 +92,19 @@ function(gen_pkgconfig_vars)

# Set the output variables
string(REPLACE ";" " " cflags "${cflags}")
- set("${var_prefix}_CFLAGS" "${cflags}" PARENT_SCOPE)
string(REPLACE ";" " " private_libs "${private_libs}")
+
+ # Since CMake 3.18 FindThreads may include a generator expression requiring
+ # a target, which gets propagated to us through INTERFACE_COMPILE_OPTIONS.
+ # Before CMake 3.19 there's no way to solve this in a general way, so we
+ # work around the specific case. See #1414 and CMake bug #21074.
+ if(CMAKE_VERSION VERSION_LESS 3.19)
+ string(REPLACE
+ "<COMPILE_LANG_AND_ID:CUDA,NVIDIA>" "<COMPILE_LANGUAGE:CUDA>"
+ cflags "${cflags}"
+ )
+ endif()
+
+ set("${var_prefix}_CFLAGS" "${cflags}" PARENT_SCOPE)
set("${var_prefix}_PRIVATE_LIBS" "${private_libs}" PARENT_SCOPE)
endfunction()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2de9298..950dd76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -414,10 +414,18 @@ configure_file(
${CMAKE_CURRENT_BINARY_DIR}/libfolly.pc.gen
@ONLY
)
+
+# Specify target to allow resolving generator expressions requiring
+# a target for CMake >=3.19. See #1414.
+if(NOT CMAKE_VERSION VERSION_LESS 3.19)
+ set(target_arg TARGET folly_deps)
+endif()
+
file(
GENERATE
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libfolly.pc
INPUT ${CMAKE_CURRENT_BINARY_DIR}/libfolly.pc.gen
+ ${target_arg}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libfolly.pc
1 change: 1 addition & 0 deletions ports/folly/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ vcpkg_from_github(
boost-1.70.patch
fix-addbit.patch
folly_c3861.patch
fix-cmake-3.18.patch # Remove this patch on the next update
)

file(COPY
Expand Down
2 changes: 1 addition & 1 deletion ports/opencv2/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: opencv2
Version: 2.4.13.7
Port-Version: 2
Port-Version: 3
Build-Depends: zlib
Description: computer vision library, version 2
Default-Features: eigen, jpeg, opengl, png, tiff
Expand Down
2,026 changes: 0 additions & 2,026 deletions ports/opencv2/FindCUDA.cmake

This file was deleted.

1 change: 0 additions & 1 deletion ports/opencv2/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ vcpkg_from_github(

file(REMOVE "${SOURCE_PATH}/cmake/FindCUDA.cmake")
file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindCUDA")
file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindCUDA.cmake DESTINATION ${SOURCE_PATH}/cmake/) #contains fixes for CUDA 11 compat, remove when CMake has support for it

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
"cuda" WITH_CUDA
Expand Down
1 change: 1 addition & 0 deletions ports/opencv3/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Source: opencv3
Version: 3.4.10
Port-Version: 1
Build-Depends: protobuf, zlib
Homepage: https://github.com/opencv/opencv
Description: computer vision library
Expand Down
2,026 changes: 0 additions & 2,026 deletions ports/opencv3/FindCUDA.cmake

This file was deleted.

4 changes: 0 additions & 4 deletions ports/opencv3/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ vcpkg_from_github(
)

file(REMOVE "${SOURCE_PATH}/cmake/FindCUDNN.cmake")
file(REMOVE "${SOURCE_PATH}/cmake/FindCUDA.cmake")
file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindCUDA")
file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindCUDA.cmake DESTINATION ${SOURCE_PATH}/cmake/) # backported from CMake 3.18, remove when released

string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT)

Expand Down Expand Up @@ -252,7 +249,6 @@ vcpkg_configure_cmake(
PREFER_NINJA
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
-DOPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE=ON #to use custom module with fixes for CUDA 11 compat, waiting for CMake support
###### ocv_options
-DOpenCV_INSTALL_BINARIES_PREFIX=
-DOPENCV_BIN_INSTALL_PATH=bin
Expand Down
Loading

0 comments on commit eb18317

Please sign in to comment.