Compare commits

...

Author SHA1 Message Date
  Damien Nguyen b67f19b9a0
Fix compilation issues 4 years ago
  Damien Nguyen dd065fa28b
Remove include_directories() in external_libs/ 4 years ago
  Damien Nguyen 80deb84e98
Use CMAKE_POSITION_INDEPENDENT_CODE, CMAKE_CXX/CUDA_STANDARD... 4 years ago
  Damien Nguyen 6c52a94d7c
Create CMake option to enable/disable -Werror 4 years ago
  Damien Nguyen 1345f5e38e
Add support for system pkgs: cppjieba 4 years ago
  Damien Nguyen 740537bf3e
Add support for system pkgs: grpc 4 years ago
  Damien Nguyen cb716482fd
Add support for system pkgs: flatbuffers 4 years ago
  Damien Nguyen ba139e8d35
Add support for system pkgs: OpenCV 4 years ago
  Damien Nguyen 2609b6ff67
Add support for system pkgs: nccl 4 years ago
  Damien Nguyen ac9b9e7743
Add support for system pkgs: ompi 4 years ago
  Damien Nguyen 67d5bf2358
Add support for system pkgs: onednn 4 years ago
  Damien Nguyen 116703d769
Add support for system pkgs: gtest 4 years ago
  Damien Nguyen 6f686d981e
Add support for system pkgs: libtiff 4 years ago
  Damien Nguyen e6311e89ac
Add support for system pkgs: protobuf, sentencepiece 4 years ago
  Damien Nguyen 1127b645b7
Add support for system pkgs: c-ares & update to c-ares 1.17.2 4 years ago
  Damien Nguyen aad4118626
Add support for system pkgs: abseil-cpp 4 years ago
  Damien Nguyen 2aac1f21ad
Add support for system pkgs: libevent 4 years ago
  Damien Nguyen 17ba5e8dee
Add support for system pkgs: re2 4 years ago
  Damien Nguyen 1292087099
Add support for system pkgs: tinyxml2 4 years ago
  Damien Nguyen b8e61f718e
Add support for system pkgs: icu4c 4 years ago
  Damien Nguyen f693e52518
Add support for system pkgs: google-glog 4 years ago
  Damien Nguyen a55deaa2e0
Add support for system pkgs: Zlib 4 years ago
  Damien Nguyen d3c122d8d8
Add support for system pkgs: TurboJPEG 4 years ago
  Damien Nguyen e3f518e3cd
Add support for system pkgs: sqlite3 4 years ago
  Damien Nguyen c1dfe18e53
Add support for system pkgs: nlohnmann_json 4 years ago
  Damien Nguyen bee122200e
Add support for system pkgs: OpenSSL 4 years ago
  Damien Nguyen 53eb6cbc89
Add support for system pkgs: Eigen3, pybind11 4 years ago
  Damien Nguyen d6acfd84fd
Introduce FindTemplate.cmake and update utils.cmake 4 years ago
  Damien Nguyen 2ae66df602
Add TARGET_ALIAS to mindspore_add_pkg 4 years ago
  Damien Nguyen db3397602a
Add some repository configuration files 4 years ago
  Damien Nguyen 4a227d0585
Avoid naming collision with matmul 4 years ago
100 changed files with 13663 additions and 1490 deletions
Unified View
  1. +86
    -0
      .cmake-format.yaml
  2. +21
    -0
      .editorconfig
  3. +19
    -4
      CMakeLists.txt
  4. +2
    -1
      cmake/dependency_graphengine.cmake
  5. +20
    -23
      cmake/external_libs/absl.cmake
  6. +14
    -18
      cmake/external_libs/c-ares.cmake
  7. +14
    -14
      cmake/external_libs/cppjieba.cmake
  8. +7
    -12
      cmake/external_libs/eigen.cmake
  9. +96
    -104
      cmake/external_libs/flatbuffers.cmake
  10. +43
    -36
      cmake/external_libs/glog.cmake
  11. +119
    -98
      cmake/external_libs/grpc.cmake
  12. +46
    -54
      cmake/external_libs/gtest.cmake
  13. +39
    -41
      cmake/external_libs/icu4c.cmake
  14. +39
    -37
      cmake/external_libs/jpeg_turbo.cmake
  15. +19
    -18
      cmake/external_libs/json.cmake
  16. +19
    -19
      cmake/external_libs/libevent.cmake
  17. +32
    -17
      cmake/external_libs/libtiff.cmake
  18. +31
    -28
      cmake/external_libs/mkl_dnn.cmake
  19. +14
    -14
      cmake/external_libs/nccl.cmake
  20. +14
    -13
      cmake/external_libs/ompi.cmake
  21. +63
    -115
      cmake/external_libs/opencv.cmake
  22. +18
    -19
      cmake/external_libs/openssl.cmake
  23. +134
    -117
      cmake/external_libs/protobuf.cmake
  24. +32
    -50
      cmake/external_libs/pybind11.cmake
  25. +15
    -15
      cmake/external_libs/re2.cmake
  26. +34
    -39
      cmake/external_libs/sentencepiece.cmake
  27. +26
    -31
      cmake/external_libs/sqlite.cmake
  28. +14
    -14
      cmake/external_libs/tinyxml2.cmake
  29. +14
    -13
      cmake/external_libs/zlib.cmake
  30. +26
    -7
      cmake/mind_expression.cmake
  31. +231
    -0
      cmake/modules/FindEigen3.cmake
  32. +94
    -0
      cmake/modules/FindFlatbuffers.cmake
  33. +246
    -0
      cmake/modules/FindGTest.cmake
  34. +290
    -0
      cmake/modules/FindLibevent.cmake
  35. +271
    -0
      cmake/modules/FindOpenCV.cmake
  36. +639
    -0
      cmake/modules/FindOpenSSL.cmake
  37. +285
    -0
      cmake/modules/FindTIFF.cmake
  38. +1497
    -0
      cmake/modules/FindTemplate.cmake
  39. +334
    -0
      cmake/modules/FindTurboJPEG.cmake
  40. +289
    -0
      cmake/modules/Findabsl.cmake
  41. +234
    -0
      cmake/modules/Findc-ares.cmake
  42. +228
    -0
      cmake/modules/Findcppjieba.cmake
  43. +378
    -0
      cmake/modules/FindgRPC.cmake
  44. +242
    -0
      cmake/modules/Findglog.cmake
  45. +242
    -0
      cmake/modules/Findnccl.cmake
  46. +228
    -0
      cmake/modules/Findnlohmann_json.cmake
  47. +288
    -0
      cmake/modules/Findpybind11.cmake
  48. +242
    -0
      cmake/modules/Findre2.cmake
  49. +302
    -0
      cmake/modules/Findsentencepiece.cmake
  50. +242
    -0
      cmake/modules/Findtinyxml2.cmake
  51. +34
    -0
      cmake/modules/_find_utils_begin.cmake
  52. +29
    -0
      cmake/modules/_find_utils_end.cmake
  53. +514
    -0
      cmake/modules/absl/20200923.cmake
  54. +527
    -0
      cmake/modules/absl/20210324.cmake
  55. +571
    -0
      cmake/modules/absl/20211102.cmake
  56. +599
    -0
      cmake/modules/opencv/4.0.cmake
  57. +414
    -0
      cmake/modules/opencv/4.1.cmake
  58. +414
    -0
      cmake/modules/opencv/4.2.cmake
  59. +414
    -0
      cmake/modules/opencv/4.3.cmake
  60. +414
    -0
      cmake/modules/opencv/4.4.cmake
  61. +457
    -0
      cmake/modules/opencv/4.5.cmake
  62. +108
    -0
      cmake/modules/opencv/5.0.cmake
  63. +5
    -0
      cmake/options.cmake
  64. +993
    -330
      cmake/utils.cmake
  65. +1
    -1
      docs/api/api_python/mindspore.ops.rst
  66. +0
    -0
      docs/api/api_python/ops/mindspore.ops.matmul_.rst
  67. +51
    -40
      mindspore/ccsrc/CMakeLists.txt
  68. +2
    -0
      mindspore/ccsrc/backend/common/optimizer/CMakeLists.txt
  69. +1
    -0
      mindspore/ccsrc/backend/common/pass/CMakeLists.txt
  70. +47
    -42
      mindspore/ccsrc/backend/common/session/CMakeLists.txt
  71. +1
    -1
      mindspore/ccsrc/backend/common/session/ascend_auto_monad.cc
  72. +2
    -2
      mindspore/ccsrc/backend/common/session/ascend_session.cc
  73. +2
    -0
      mindspore/ccsrc/backend/common/somas/CMakeLists.txt
  74. +4
    -3
      mindspore/ccsrc/backend/common/somas/somas_solver_core.cc
  75. +6
    -1
      mindspore/ccsrc/backend/graph_compiler/CMakeLists.txt
  76. +3
    -0
      mindspore/ccsrc/common/CMakeLists.txt
  77. +3
    -3
      mindspore/ccsrc/common/graph_kernel/add_atomic_clean.cc
  78. +3
    -3
      mindspore/ccsrc/common/graph_kernel/parallel_fusion.cc
  79. +2
    -0
      mindspore/ccsrc/common/mem_reuse/CMakeLists.txt
  80. +11
    -6
      mindspore/ccsrc/cxx_api/CMakeLists.txt
  81. +6
    -1
      mindspore/ccsrc/debug/CMakeLists.txt
  82. +1
    -0
      mindspore/ccsrc/debug/env_config_parser.h
  83. +2
    -0
      mindspore/ccsrc/distributed/CMakeLists.txt
  84. +2
    -1
      mindspore/ccsrc/fl/CMakeLists.txt
  85. +7
    -4
      mindspore/ccsrc/frontend/operator/CMakeLists.txt
  86. +12
    -9
      mindspore/ccsrc/frontend/optimizer/CMakeLists.txt
  87. +3
    -0
      mindspore/ccsrc/frontend/parallel/CMakeLists.txt
  88. +1
    -0
      mindspore/ccsrc/frontend/parallel/auto_parallel/rec_core/rec_cost.h
  89. +2
    -0
      mindspore/ccsrc/kernel/CMakeLists.txt
  90. +3
    -2
      mindspore/ccsrc/kernel/akg/akg_kernel_json_generator.cc
  91. +3
    -3
      mindspore/ccsrc/minddata/dataset/CMakeLists.txt
  92. +14
    -1
      mindspore/ccsrc/minddata/dataset/api/CMakeLists.txt
  93. +2
    -0
      mindspore/ccsrc/minddata/dataset/audio/ir/CMakeLists.txt
  94. +49
    -45
      mindspore/ccsrc/minddata/dataset/audio/ir/kernels/CMakeLists.txt
  95. +2
    -1
      mindspore/ccsrc/minddata/dataset/audio/kernels/CMakeLists.txt
  96. +3
    -1
      mindspore/ccsrc/minddata/dataset/callback/CMakeLists.txt
  97. +9
    -2
      mindspore/ccsrc/minddata/dataset/core/CMakeLists.txt
  98. +1
    -1
      mindspore/ccsrc/minddata/dataset/core/pybind_support.h
  99. +8
    -1
      mindspore/ccsrc/minddata/dataset/engine/CMakeLists.txt
  100. +29
    -15
      mindspore/ccsrc/minddata/dataset/engine/cache/CMakeLists.txt

+ 86
- 0
.cmake-format.yaml View File

@@ -0,0 +1,86 @@
markup:
first_comment_is_literal: true
format:
disable: false
line_width: 120
tab_size: 2
use_tabchars: false
max_subgroups_hwrap: 2
max_pargs_hwrap: 6
max_rows_cmdline: 2
separate_ctrl_name_with_space: false
separate_fn_name_with_space: false
dangle_parens: false
dangle_align: prefix
min_prefix_chars: 4
max_prefix_chars: 10
max_lines_hwrap: 2
line_ending: unix
command_case: canonical
keyword_case: unchanged
enable_sort: true
autosort: false
require_valid_layout: false
parse:
additional_commands:
test_compile_option:
pargs:
nargs: 1+
flags:
- AUTO_ADD_CO
kwargs:
LANGS: +
FLAGS: +
GENEX: 1
test_link_option:
pargs:
nargs: 1+
flags:
- AUTO_ADD_LO
- VERBATIM
kwargs:
LANGS: +
FLAGS: +
GENEX: 1
mindspore_add_pkg:
pargs:
nargs: 1
flags:
- FORCE_EXACT_VERSION
- CMAKE_PKG_NO_COMPONENTS
- GEN_CMAKE_CONFIG
- FORCE_CONFIG_SEARCH
- BUILD_OPTION_PASS_PREFIX
kwargs:
URL: 1
MD5: 1
GIT_REPOSITORY: 1
GIT_TAG: 1
VER: 1
EXE: 1
DIR: 1
HEAD_ONLY: 1
CMAKE_PATH: 1
RELEASE: 1
LIB_PATH: 1
CUSTOM_CMAKE: 1
NS_NAME: 1
CMAKE_OPTION: +
LIBS: +
LIBS_CMAKE_NAMES: +
PRE_CONFIGURE_COMMAND: +
CONFIGURE_COMMAND: +
BUILD_OPTION: +
INSTALL_INCS: +
INSTALL_LIBS: +
PATCHES: +
SUBMODULES: +
SOURCEMODULES: +
ONLY_MAKE: +
ONLY_MAKE_INCS: +
ONLY_MAKE_LIBS: +
TARGET_ALIAS: 2
lint:
argument_var_pattern: _?[a-z][a-z0-9_]+
local_var_pattern: _?([a-z][a-z0-9_]+|[A-Z][A-Z0-9_]+)
macro_pattern: '[0-9a-z_]+'

+ 21
- 0
.editorconfig View File

@@ -0,0 +1,21 @@
root = true

[*]
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = false
indent_style = space
indent_size = 4

[*.{yml,yaml}]
indent_size = 2

[{CMakeLists.txt,*.cmake}]
indent_size = 2
tab_width = 8

[*.{h,hpp,hxx,c,cpp,cxx}]
tab_width = 8

[{Makefile,**.mk}]
indent_style = tab

+ 19
- 4
CMakeLists.txt View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14.0)
cmake_minimum_required(VERSION 3.17.0)
project(MindSpore) project(MindSpore)


if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
@@ -80,11 +80,26 @@ set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -g2 -ggdb -fno-inline-functions -f
-Wl,--allow-shlib-undefined -D_LIBCPP_INLINE_VISIBILITY='' -D_LIBCPP_DISABLE_EXTERN_TEMPLATE=1 \ -Wl,--allow-shlib-undefined -D_LIBCPP_INLINE_VISIBILITY='' -D_LIBCPP_DISABLE_EXTERN_TEMPLATE=1 \
-DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2 -Wno-cpp") -DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2 -Wno-cpp")


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include -std=c++17 \
-Werror -Wall -Wno-deprecated-declarations -fPIC")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

if(CUDAToolkit_VERSION VERSION_LESS 11.0)
set(CMAKE_CUDA_STANDARD 14)
else()
set(CMAKE_CUDA_STANDARD 17)
endif()
if(NOT CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES 60 70)
endif()
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr")
set(CMAKE_CUDA_STANDARD_REQUIRED TRUE)

set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include \
-Wall -Wno-deprecated-declarations")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)


set(PYBIND11_CPP_STANDARD -std=c++17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTION_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTION_CXX_FLAGS}")


if(ENABLE_AKG AND CMAKE_SYSTEM_NAME MATCHES "Linux") if(ENABLE_AKG AND CMAKE_SYSTEM_NAME MATCHES "Linux")


+ 2
- 1
cmake/dependency_graphengine.cmake View File

@@ -11,7 +11,7 @@ function(find_submodule_lib module name path)
find_library(${module}_LIBRARY_DIR NAMES ${name} NAMES_PER_DIR PATHS ${path} find_library(${module}_LIBRARY_DIR NAMES ${name} NAMES_PER_DIR PATHS ${path}
PATH_SUFFIXES lib PATH_SUFFIXES lib
) )
if("${${module}_LIBRARY_DIR}" STREQUAL "${module}_LIBRARY_DIR-NOTFOUND")
if(NOT ${module}_LIBRARY_DIR)
message(FATAL_ERROR "${name} not found in any of following paths: ${path}") message(FATAL_ERROR "${name} not found in any of following paths: ${path}")
endif() endif()
add_library(${module} SHARED IMPORTED) add_library(${module} SHARED IMPORTED)
@@ -43,6 +43,7 @@ if(ENABLE_TESTCASES OR MODE_ASCEND_ALL OR MODE_ASCEND_ACL)
endforeach() endforeach()
ge_protobuf_generate(GE_PROTO_SRCS GE_PROTO_HDRS ${GE_PROTO_FILE}) ge_protobuf_generate(GE_PROTO_SRCS GE_PROTO_HDRS ${GE_PROTO_FILE})
add_library(graph SHARED ${GE_PROTO_SRCS}) add_library(graph SHARED ${GE_PROTO_SRCS})
target_link_libraries(graph PUBLIC mindspore::protobuf)
else() else()
message(FATAL_ERROR "No compile option defined for GraphEngine, exiting") message(FATAL_ERROR "No compile option defined for GraphEngine, exiting")
endif() endif()

+ 20
- 23
cmake/external_libs/absl.cmake View File

@@ -1,30 +1,27 @@
if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/abseil-cpp/repository/archive/20200923.3.tar.gz")
set(MD5 "daba6e99c7a84e2242a0107bbd873669")
set(REQ_URL "https://gitee.com/mirrors/abseil-cpp/repository/archive/20200923.3.tar.gz")
set(MD5 "daba6e99c7a84e2242a0107bbd873669")
else() else()
set(REQ_URL "https://github.com/abseil/abseil-cpp/archive/20200923.3.tar.gz")
set(MD5 "daba6e99c7a84e2242a0107bbd873669")
set(REQ_URL "https://github.com/abseil/abseil-cpp/archive/20200923.3.tar.gz")
set(MD5 "daba6e99c7a84e2242a0107bbd873669")
endif() endif()


if(NOT ENABLE_GLIBCXX) if(NOT ENABLE_GLIBCXX)
set(absl_CXXFLAGS "${absl_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
set(absl_CXXFLAGS "${absl_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif() endif()


mindspore_add_pkg(absl
VER 20200923.3
LIBS absl_strings absl_throw_delegate absl_raw_logging_internal absl_int128 absl_bad_optional_access
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=TRUE
-DCMAKE_CXX_STANDARD=11
)

include_directories(${absl_INC})

add_library(mindspore::absl_strings ALIAS absl::absl_strings)
add_library(mindspore::absl_throw_delegate ALIAS absl::absl_throw_delegate)
add_library(mindspore::absl_raw_logging_internal ALIAS absl::absl_raw_logging_internal)
add_library(mindspore::absl_int128 ALIAS absl::absl_int128)
add_library(mindspore::absl_bad_optional_access ALIAS absl::absl_bad_optional_access)
mindspore_add_pkg(
absl
VER 20200923.3
FORCE_EXACT_VERSION
LIBS absl_strings absl_throw_delegate absl_raw_logging_internal absl_int128 absl_bad_optional_access
LIBS_CMAKE_NAMES strings throw_delegate raw_logging_internal int128 bad_optional_access
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=TRUE -DCMAKE_CXX_STANDARD=11
PATCHES ${TOP_DIR}/third_party/patch/absl/absl.patch001
TARGET_ALIAS mindspore::absl_strings absl::strings
TARGET_ALIAS mindspore::absl_throw_delegate absl::throw_delegate
TARGET_ALIAS mindspore::absl_raw_logging_internal absl::raw_logging_internal
TARGET_ALIAS mindspore::absl_int128 absl::int128
TARGET_ALIAS mindspore::absl_bad_optional_access absl::bad_optional_access)

+ 14
- 18
cmake/external_libs/c-ares.cmake View File

@@ -1,22 +1,18 @@
if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/c-ares/repository/archive/cares-1_15_0.tar.gz")
set(MD5 "459876e53724a2c87ed2876312b96aed")
set(REQ_URL "https://gitee.com/mirrors/c-ares/repository/archive/cares-1_17_2.tar.gz")
set(MD5 "59cd1207df8f9522797535245e12b871")
else() else()
set(REQ_URL "https://github.com/c-ares/c-ares/releases/download/cares-1_15_0/c-ares-1.15.0.tar.gz")
set(MD5 "d2391da274653f7643270623e822dff7")
set(REQ_URL "https://github.com/c-ares/c-ares/releases/download/cares-1_17_2/c-ares-1.17.2.tar.gz")
set(MD5 "3802264830c6886411dac606c66fdbf8")
endif() endif()


mindspore_add_pkg(c-ares
VER 1.15.0
LIBS cares
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release
-DCARES_SHARED:BOOL=OFF
-DCARES_STATIC:BOOL=ON
-DCARES_STATIC_PIC:BOOL=ON
-DHAVE_LIBNSL:BOOL=OFF
PATCHES ${TOP_DIR}/third_party/patch/c-ares/CVE-2021-3672.patch)

include_directories(${c-ares_INC})
add_library(mindspore::cares ALIAS c-ares::cares)
mindspore_add_pkg(
c-ares
VER 1.17.2
LIBS cares
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${TOP_DIR}/third_party/patch/c-ares/c-ares.patch001
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release -DCARES_SHARED:BOOL=OFF -DCARES_STATIC:BOOL=ON
-DCARES_STATIC_PIC:BOOL=ON -DHAVE_LIBNSL:BOOL=OFF
TARGET_ALIAS mindspore::cares c-ares::cares)

+ 14
- 14
cmake/external_libs/cppjieba.cmake View File

@@ -2,20 +2,20 @@ set(cppjieba_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(cppjieba_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(cppjieba_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")


if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/cppjieba/repository/archive/v5.0.3.tar.gz")
set(MD5 "06fcc22b4db6c332dc1b0bd353bdf6f2")
set(REQ_URL "https://gitee.com/mirrors/cppjieba/repository/archive/v5.0.3.tar.gz")
set(MD5 "06fcc22b4db6c332dc1b0bd353bdf6f2")
else() else()
set(REQ_URL "https://github.com/yanyiwu/cppjieba/archive/v5.0.3.tar.gz")
set(MD5 "b8b3f7a73032c9ce9daafa4f67196c8c")
set(REQ_URL "https://github.com/yanyiwu/cppjieba/archive/v5.0.3.tar.gz")
set(MD5 "b8b3f7a73032c9ce9daafa4f67196c8c")
endif() endif()


mindspore_add_pkg(cppjieba
VER 5.0.3
HEAD_ONLY ./
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${TOP_DIR}/third_party/patch/cppjieba/cppjieba.patch001)
include_directories(${cppjieba_INC}include)
include_directories(${cppjieba_INC}deps)
add_library(mindspore::cppjieba ALIAS cppjieba)
mindspore_add_pkg(
cppjieba
VER 5.0.3
LIBS cppjieba
CMAKE_OPTION " "
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${TOP_DIR}/third_party/patch/cppjieba/cppjieba.patch001
${TOP_DIR}/third_party/patch/cppjieba/cppjieba.patch002
TARGET_ALIAS mindspore::cppjieba cppjieba::cppjieba)

+ 7
- 12
cmake/external_libs/eigen.cmake View File

@@ -1,18 +1,13 @@
set(Eigen3_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(Eigen3_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(Eigen3_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(Eigen3_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")



set(REQ_URL "https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.tar.gz") set(REQ_URL "https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.tar.gz")
set(MD5 "609286804b0f79be622ccf7f9ff2b660") set(MD5 "609286804b0f79be622ccf7f9ff2b660")



mindspore_add_pkg(Eigen3
VER 3.3.9
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DBUILD_TESTING=OFF)
find_package(Eigen3 3.3.9 REQUIRED ${MS_FIND_NO_DEFAULT_PATH})
include_directories(${Eigen3_INC})
include_directories(${EIGEN3_INCLUDE_DIR})
set_property(TARGET Eigen3::Eigen PROPERTY IMPORTED_GLOBAL TRUE)
add_library(mindspore::eigen ALIAS Eigen3::Eigen)
mindspore_add_pkg(
Eigen3
VER 3.3.9
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DBUILD_TESTING=OFF
TARGET_ALIAS mindspore::eigen Eigen3::Eigen)

+ 96
- 104
cmake/external_libs/flatbuffers.cmake View File

@@ -1,134 +1,126 @@
if(MSVC) if(MSVC)
set(flatbuffers_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_CFLAGS "${CMAKE_C_FLAGS}")
set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(flatbuffers_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_CFLAGS "${CMAKE_C_FLAGS}")
set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
else() else()
set(flatbuffers_CXXFLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong")
set(flatbuffers_CFLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong")
set(flatbuffers_CXXFLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong")
set(flatbuffers_CFLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong")
endif() endif()


if(WIN32) if(WIN32)
set(flatbuffers_USE_STATIC_LIBS ON)
set(flatbuffers_USE_STATIC_LIBS ON)
endif() endif()


if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/flatbuffers/repository/archive/v2.0.0.tar.gz")
set(MD5 "5c23d17c0486b81d4c11907e8f7bf36b")
set(REQ_URL "https://gitee.com/mirrors/flatbuffers/repository/archive/v2.0.0.tar.gz")
set(MD5 "5c23d17c0486b81d4c11907e8f7bf36b")
else() else()
set(REQ_URL "https://github.com/google/flatbuffers/archive/v2.0.0.tar.gz")
set(MD5 "a27992324c3cbf86dd888268a23d17bd")
set(REQ_URL "https://github.com/google/flatbuffers/archive/v2.0.0.tar.gz")
set(MD5 "a27992324c3cbf86dd888268a23d17bd")
endif() endif()


if(APPLE) if(APPLE)
set(flatbuffers_CXXFLAGS "${flatbuffers_CXXFLAGS} -Wno-deprecated")
set(flatbuffers_CXXFLAGS "${flatbuffers_CXXFLAGS} -Wno-deprecated")
endif() endif()

if(APPLE) if(APPLE)
mindspore_add_pkg(flatbuffers
VER 2.0.0
LIBS flatbuffers
EXE flatc
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_LIBDIR=lib)
set(CMAKE_OPTION -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_LIBDIR=lib)
else() else()
mindspore_add_pkg(flatbuffers
VER 2.0.0
LIBS flatbuffers
EXE flatc
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_C_COMPILER=${FLATC_GCC_COMPILER} -DCMAKE_CXX_COMPILER=${FLATC_GXX_COMPILER}
-DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release)
set(CMAKE_OPTION -DCMAKE_C_COMPILER=${FLATC_GCC_COMPILER} -DCMAKE_CXX_COMPILER=${FLATC_GXX_COMPILER}
-DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release)
endif() endif()


include_directories(${flatbuffers_INC})
add_library(mindspore::flatbuffers ALIAS flatbuffers::flatbuffers)
add_executable(mindspore::flatc ALIAS flatbuffers::flatc)
function(ms_build_flatbuffers source_schema_files
source_schema_dirs
custom_target_name
generated_output_dir)

set(total_schema_dirs "")
set(total_generated_files "")
set(FLATC mindspore::flatc)
foreach(schema_dir ${source_schema_dirs})
set(total_schema_dirs -I ${schema_dir} ${total_schema_dirs})
endforeach()
if(MS_PREFER_SYSTEM_PKGS OR MS_FLATBUFFERS_PREFER_SYSTEM)
# Most Linux distributions are likely to ship at least the shared library
set(_flatbuffer_lib_name flatbuffers_shared)
else()
set(_flatbuffer_lib_name flatbuffers)
endif()


foreach(schema IN LISTS ${source_schema_files})
get_filename_component(filename ${schema} NAME_WE)
if(NOT ${generated_output_dir} STREQUAL "")
set(generated_file ${generated_output_dir}/${filename}_generated.h)
add_custom_command(
OUTPUT ${generated_file}
COMMAND ${FLATC} --gen-mutable
--reflect-names --gen-object-api -o ${generated_output_dir}
${total_schema_dirs}
-c -b --reflect-types ${schema}
DEPENDS ${FLATC} ${schema}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Running C++ flatbuffers compiler on ${schema}" VERBATIM)
list(APPEND total_generated_files ${generated_file})
endif()
endforeach()
mindspore_add_pkg(
Flatbuffers
VER 2.0.0
LIBS flatbuffers
LIBS_CMAKE_NAMES ${_flatbuffer_lib_name}
EXE flatc
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION ${CMAKE_OPTION}
TARGET_ALIAS mindspore::flatbuffers flatbuffers::${_flatbuffer_lib_name}
TARGET_ALIAS mindspore::flatc flatbuffers::flatc)


add_custom_target(${custom_target_name} ALL
DEPENDS ${total_generated_files})
function(ms_build_flatbuffers source_schema_files source_schema_dirs custom_target_name generated_output_dir)
set(total_schema_dirs "")
set(total_generated_files "")
set(FLATC mindspore::flatc)
foreach(schema_dir ${source_schema_dirs})
set(total_schema_dirs -I ${schema_dir} ${total_schema_dirs})
endforeach()


foreach(schema IN LISTS ${source_schema_files})
get_filename_component(filename ${schema} NAME_WE)
if(NOT ${generated_output_dir} STREQUAL "") if(NOT ${generated_output_dir} STREQUAL "")
include_directories(${generated_output_dir})
set_property(TARGET ${custom_target_name}
PROPERTY GENERATED_OUTPUT_DIR
${generated_output_dir})
set(generated_file ${generated_output_dir}/${filename}_generated.h)
add_custom_command(
OUTPUT ${generated_file}
COMMAND ${FLATC} --gen-mutable --reflect-names --gen-object-api -o ${generated_output_dir} ${total_schema_dirs}
-c -b --reflect-types ${schema}
DEPENDS ${FLATC} ${schema}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Running C++ flatbuffers compiler on ${schema}"
VERBATIM)
list(APPEND total_generated_files ${generated_file})
endif() endif()
endfunction()
endforeach()


function(ms_build_flatbuffers_lite
source_schema_files source_schema_dirs custom_target_name generated_output_dir if_inner)
add_custom_target(${custom_target_name} ALL DEPENDS ${total_generated_files})


set(total_schema_dirs "")
set(total_generated_files "")
set(FLATC mindspore::flatc)
foreach(schema_dir ${source_schema_dirs})
set(total_schema_dirs -I ${schema_dir} ${total_schema_dirs})
endforeach()
if(NOT ${generated_output_dir} STREQUAL "")
include_directories(${generated_output_dir})
set_property(TARGET ${custom_target_name} PROPERTY GENERATED_OUTPUT_DIR ${generated_output_dir})
endif()
endfunction()


foreach(schema IN LISTS ${source_schema_files})
get_filename_component(filename ${schema} NAME_WE)
if(NOT ${generated_output_dir} STREQUAL "")
set(generated_file ${generated_output_dir}/${filename}_generated.h)
if(if_inner MATCHES "inner")
add_custom_command(
OUTPUT ${generated_file}
COMMAND ${FLATC} --gen-mutable
--reflect-names --gen-object-api -o ${generated_output_dir}
${total_schema_dirs}
-c -b --reflect-types ${schema}
DEPENDS ${FLATC} ${schema}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Running C++ flatbuffers compiler on ${schema}" VERBATIM)
else()
add_custom_command(
OUTPUT ${generated_file}
COMMAND ${FLATC} -o ${generated_output_dir}
${total_schema_dirs}
-c -b ${schema}
DEPENDS ${FLATC} ${schema}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Running C++ flatbuffers compiler on ${schema}" VERBATIM)
endif()
list(APPEND total_generated_files ${generated_file})
endif()
endforeach()
function(ms_build_flatbuffers_lite source_schema_files source_schema_dirs custom_target_name generated_output_dir
if_inner)


add_custom_target(${custom_target_name} ALL
DEPENDS ${total_generated_files})
set(total_schema_dirs "")
set(total_generated_files "")
set(FLATC mindspore::flatc)
foreach(schema_dir ${source_schema_dirs})
set(total_schema_dirs -I ${schema_dir} ${total_schema_dirs})
endforeach()


foreach(schema IN LISTS ${source_schema_files})
get_filename_component(filename ${schema} NAME_WE)
if(NOT ${generated_output_dir} STREQUAL "") if(NOT ${generated_output_dir} STREQUAL "")
include_directories(${generated_output_dir})
set_property(TARGET ${custom_target_name}
PROPERTY GENERATED_OUTPUT_DIR
${generated_output_dir})
set(generated_file ${generated_output_dir}/${filename}_generated.h)
if(if_inner MATCHES "inner")
add_custom_command(
OUTPUT ${generated_file}
COMMAND ${FLATC} --gen-mutable --reflect-names --gen-object-api -o ${generated_output_dir}
${total_schema_dirs} -c -b --reflect-types ${schema}
DEPENDS ${FLATC} ${schema}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Running C++ flatbuffers compiler on ${schema}"
VERBATIM)
else()
add_custom_command(
OUTPUT ${generated_file}
COMMAND ${FLATC} -o ${generated_output_dir} ${total_schema_dirs} -c -b ${schema}
DEPENDS ${FLATC} ${schema}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Running C++ flatbuffers compiler on ${schema}"
VERBATIM)
endif()
list(APPEND total_generated_files ${generated_file})
endif() endif()
endforeach()

add_custom_target(${custom_target_name} ALL DEPENDS ${total_generated_files})

if(NOT ${generated_output_dir} STREQUAL "")
include_directories(${generated_output_dir})
set_property(TARGET ${custom_target_name} PROPERTY GENERATED_OUTPUT_DIR ${generated_output_dir})
endif()
endfunction() endfunction()

+ 43
- 36
cmake/external_libs/glog.cmake View File

@@ -1,52 +1,59 @@
if(BUILD_LITE) if(BUILD_LITE)
if(MSVC)
set(flatbuffers_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_CFLAGS "${CMAKE_C_FLAGS}")
set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
else()
set(glog_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_CXX_FLAGS} -Dgoogle=mindspore_private")
set(glog_CFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_C_FLAGS}")
set(glog_LDFLAGS "${SECURE_SHARED_LINKER_FLAGS}")
endif()
set(glog_patch "")
set(glog_lib glog)
else()
if(MSVC)
set(flatbuffers_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_CFLAGS "${CMAKE_C_FLAGS}")
set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
else()
set(glog_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_CXX_FLAGS} -Dgoogle=mindspore_private") set(glog_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_CXX_FLAGS} -Dgoogle=mindspore_private")
set(glog_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(glog_patch ${CMAKE_SOURCE_DIR}/third_party/patch/glog/glog.patch001)
set(glog_lib mindspore_glog)
set(glog_CFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_C_FLAGS}")
set(glog_LDFLAGS "${SECURE_SHARED_LINKER_FLAGS}")
endif()
set(glog_patch "")
else()
set(glog_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_CXX_FLAGS} -Dgoogle=mindspore_private")
set(glog_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(glog_patch ${CMAKE_SOURCE_DIR}/third_party/patch/glog/glog.patch001)
endif() endif()


if(NOT ENABLE_GLIBCXX) if(NOT ENABLE_GLIBCXX)
set(glog_CXXFLAGS "${glog_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
set(glog_CXXFLAGS "${glog_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif() endif()


if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/glog/repository/archive/v0.4.0.tar.gz")
set(MD5 "9a7598a00c569a11ff1a419076de4ed7")
set(REQ_URL "https://gitee.com/mirrors/glog/repository/archive/v0.4.0.tar.gz")
set(MD5 "9a7598a00c569a11ff1a419076de4ed7")
else() else()
set(REQ_URL "https://github.com/google/glog/archive/v0.4.0.tar.gz")
set(MD5 "0daea8785e6df922d7887755c3d100d0")
set(REQ_URL "https://github.com/google/glog/archive/v0.4.0.tar.gz")
set(MD5 "0daea8785e6df922d7887755c3d100d0")
endif() endif()


set(glog_option -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON -DWITH_GFLAGS=OFF set(glog_option -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON -DWITH_GFLAGS=OFF
-DCMAKE_BUILD_TYPE=Release)
-DCMAKE_BUILD_TYPE=Release)


if(WIN32 AND NOT MSVC) if(WIN32 AND NOT MSVC)
execute_process(COMMAND "${CMAKE_C_COMPILER}" -dumpmachine
OUTPUT_VARIABLE i686_or_x86_64
)
if(i686_or_x86_64 MATCHES "^i686-")
set(glog_option ${glog_option} -DHAVE_DBGHELP=ON)
endif()
execute_process(COMMAND "${CMAKE_C_COMPILER}" -dumpmachine OUTPUT_VARIABLE i686_or_x86_64)
if(i686_or_x86_64 MATCHES "^i686-")
set(glog_option ${glog_option} -DHAVE_DBGHELP=ON)
endif()
endif() endif()


mindspore_add_pkg(glog
VER 0.4.0
LIBS ${glog_lib}
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${glog_patch}
CMAKE_OPTION ${glog_option})
include_directories(${glog_INC})
add_library(mindspore::glog ALIAS glog::${glog_lib})
mindspore_add_pkg(
glog
VER 0.4.0
LIBS glog
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${glog_patch}
CMAKE_OPTION ${glog_option}
TARGET_ALIAS mindspore::glog glog::glog)

if(NOT MS_PREFER_SYSTEM_PKGS AND NOT MS_GLOG_PREFER_SYSTEM)
set(MS_PATCHED_GLOG_NAME
TRUE
CACHE INTERNAL "")
target_compile_definitions(glog::glog INTERFACE MS_PATCHED_GLOG_NAME)
else()
set(MS_PATCHED_GLOG_NAME
FALSE
CACHE INTERNAL "")
endif()

+ 119
- 98
cmake/external_libs/grpc.cmake View File

@@ -1,129 +1,150 @@
set(grpc_USE_STATIC_LIBS OFF) set(grpc_USE_STATIC_LIBS OFF)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -D_FORTIFY_SOURCE=2 -O2 \
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -D_FORTIFY_SOURCE=2 -O2 \
-Dgrpc=mindspore_grpc -Dgrpc_impl=mindspore_grpc_impl -Dgrpc_core=mindspore_grpc_core") -Dgrpc=mindspore_grpc -Dgrpc_impl=mindspore_grpc_impl -Dgrpc_core=mindspore_grpc_core")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
else() else()
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2 \
set(grpc_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2 \
-Dgrpc=mindspore_grpc -Dgrpc_impl=mindspore_grpc_impl -Dgrpc_core=mindspore_grpc_core") -Dgrpc=mindspore_grpc -Dgrpc_impl=mindspore_grpc_impl -Dgrpc_core=mindspore_grpc_core")
if(NOT ENABLE_GLIBCXX)
set(grpc_CXXFLAGS "${grpc_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
if(NOT ENABLE_GLIBCXX)
set(grpc_CXXFLAGS "${grpc_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
endif() endif()


if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(grpc_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
set(grpc_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif() endif()


if(EXISTS ${protobuf_ROOT}/lib64)
set(_FINDPACKAGE_PROTOBUF_CONFIG_DIR "${protobuf_ROOT}/lib64/cmake/protobuf")
file(GLOB _dirs "${_MS_LIB_CACHE}/*")
list(PREPEND CMAKE_PREFIX_PATH ${_dirs})

if(NOT MS_PREFER_SYSTEM_PKGS AND NOT MS_PROTOBUF_PREFER_SYSTEM)
if(NOT protobuf_DIR)
find_package(protobuf CONFIG QUIET)
endif()
set(_FINDPACKAGE_PROTOBUF_CONFIG_DIR "-DProtobuf_DIR:PATH=${protobuf_DIR}")
message("grpc using Protobuf_DIR : " ${_FINDPACKAGE_PROTOBUF_CONFIG_DIR})
else() else()
set(_FINDPACKAGE_PROTOBUF_CONFIG_DIR "${protobuf_ROOT}/lib/cmake/protobuf")
# We rely on system discovery anyway so should work when building grpc
endif() endif()
message("grpc using Protobuf_DIR : " ${_FINDPACKAGE_PROTOBUF_CONFIG_DIR})


if(EXISTS ${absl_ROOT}/lib64)
set(_FINDPACKAGE_ABSL_CONFIG_DIR "${absl_ROOT}/lib64/cmake/absl")
else()
set(_FINDPACKAGE_ABSL_CONFIG_DIR "${absl_ROOT}/lib/cmake/absl")
if(NOT absl_DIR)
find_package(absl CONFIG QUIET)
endif() endif()
set(_FINDPACKAGE_ABSL_CONFIG_DIR "-Dabsl_DIR:PATH=${absl_DIR}")
message("grpc using absl_DIR : " ${_FINDPACKAGE_ABSL_CONFIG_DIR}) message("grpc using absl_DIR : " ${_FINDPACKAGE_ABSL_CONFIG_DIR})


if(EXISTS ${re2_ROOT}/lib64)
set(_FINDPACKAGE_RE2_CONFIG_DIR "${re2_ROOT}/lib64/cmake/re2")
if(NOT MS_PREFER_SYSTEM_PKGS AND NOT MS_RE2_PREFER_SYSTEM)
if(NOT re2_DIR)
find_package(re2 CONFIG QUIET)
endif()
set(_FINDPACKAGE_RE2_CONFIG_DIR "-Dre2_DIR:PATH=${re2_DIR}")
message("grpc using re2_DIR : " ${_FINDPACKAGE_RE2_CONFIG_DIR})
else() else()
set(_FINDPACKAGE_RE2_CONFIG_DIR "${re2_ROOT}/lib/cmake/re2")
# We rely on system discovery anyway so should work when building grpc
endif() endif()
message("grpc using re2_DIR : " ${_FINDPACKAGE_RE2_CONFIG_DIR})


if(EXISTS ${openssl_ROOT})
set(_CMAKE_ARGS_OPENSSL_ROOT_DIR "-DOPENSSL_ROOT_DIR:PATH=${openssl_ROOT}")
list(POP_FRONT CMAKE_PREFIX_PATH)

if(NOT MS_PREFER_SYSTEM_PKGS AND NOT MS_OPENSSL_PREFER_SYSTEM)
foreach(_dir ${_dirs})
if(_dir MATCHES ".*OpenSSL.*")
set(OpenSSL_ROOT ${_dir})
break()
endif()
endforeach()
message(STATUS "OpenSSL_ROOT = ${OpenSSL_ROOT}")
if(EXISTS ${OpenSSL_ROOT})
set(_CMAKE_ARGS_OPENSSL_ROOT_DIR "-DOPENSSL_ROOT_DIR:PATH=${OpenSSL_ROOT}")
endif()
else()
# We rely on system discovery anyway so should work when building grpc
endif() endif()


if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/grpc/repository/archive/v1.36.1.tar.gz")
set(MD5 "71252ebcd8e9e32a818a907dfd4b63cc")
set(REQ_URL "https://gitee.com/mirrors/grpc/repository/archive/v1.36.1.tar.gz")
set(MD5 "71252ebcd8e9e32a818a907dfd4b63cc")
else() else()
set(REQ_URL "https://github.com/grpc/grpc/archive/v1.36.1.tar.gz")
set(MD5 "90c93203e95e89af5f46738588217057")
set(REQ_URL "https://github.com/grpc/grpc/archive/v1.36.1.tar.gz")
set(MD5 "90c93203e95e89af5f46738588217057")
endif() endif()


mindspore_add_pkg(grpc
VER 1.36.1
LIBS mindspore_grpc++ mindspore_grpc mindspore_gpr mindspore_upb mindspore_address_sorting
EXE grpc_cpp_plugin
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${TOP_DIR}/third_party/patch/grpc/grpc.patch001
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release
-DBUILD_SHARED_LIBS=ON
-DgRPC_INSTALL:BOOL=ON
-DgRPC_BUILD_TESTS:BOOL=OFF
-DgRPC_PROTOBUF_PROVIDER:STRING=package
-DgRPC_PROTOBUF_PACKAGE_TYPE:STRING=CONFIG
-DProtobuf_DIR:PATH=${_FINDPACKAGE_PROTOBUF_CONFIG_DIR}
-DgRPC_ZLIB_PROVIDER:STRING=package
-DZLIB_ROOT:PATH=${zlib_ROOT}
-DgRPC_ABSL_PROVIDER:STRING=package
-Dabsl_DIR:PATH=${_FINDPACKAGE_ABSL_CONFIG_DIR}
-DgRPC_CARES_PROVIDER:STRING=package
-Dc-ares_DIR:PATH=${c-ares_ROOT}/lib/cmake/c-ares
-DgRPC_SSL_PROVIDER:STRING=package
${_CMAKE_ARGS_OPENSSL_ROOT_DIR}
-DgRPC_RE2_PROVIDER:STRING=package
-Dre2_DIR:PATH=${_FINDPACKAGE_RE2_CONFIG_DIR}
)

include_directories(${grpc_INC})

add_library(mindspore::grpc++ ALIAS grpc::mindspore_grpc++)

# link other grpc libs
target_link_libraries(grpc::mindspore_grpc++ INTERFACE grpc::mindspore_grpc grpc::mindspore_gpr grpc::mindspore_upb
grpc::mindspore_address_sorting)
mindspore_add_pkg(
gRPC
VER 1.36.1
LIBS mindspore_grpc++ mindspore_grpc mindspore_gpr mindspore_upb mindspore_address_sorting
LIBS_CMAKE_NAMES grpc++ grpc gpr upb address_sorting
EXE grpc_cpp_plugin
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${TOP_DIR}/third_party/patch/grpc/grpc.patch001
CMAKE_OPTION
-DCMAKE_BUILD_TYPE:STRING=Release
-DBUILD_SHARED_LIBS=ON
-DgRPC_INSTALL:BOOL=ON
-DgRPC_BUILD_TESTS:BOOL=OFF
-DgRPC_PROTOBUF_PROVIDER:STRING=package
-DgRPC_PROTOBUF_PACKAGE_TYPE:STRING=CONFIG
${_FINDPACKAGE_PROTOBUF_CONFIG_DIR}
-DgRPC_ZLIB_PROVIDER:STRING=package
-DZLIB_ROOT:PATH=${zlib_ROOT}
-DgRPC_ABSL_PROVIDER:STRING=package
${_FINDPACKAGE_ABSL_CONFIG_DIR}
-DgRPC_CARES_PROVIDER:STRING=package
-Dc-ares_DIR:PATH=${c-ares_ROOT}/lib/cmake/c-ares
-DgRPC_SSL_PROVIDER:STRING=package
${_CMAKE_ARGS_OPENSSL_ROOT_DIR}
-DgRPC_RE2_PROVIDER:STRING=package
${_FINDPACKAGE_RE2_CONFIG_DIR}
TARGET_ALIAS mindspore::grpc++ gRPC::grpc++)


# modify mindspore macro define # modify mindspore macro define
add_compile_definitions(grpc=mindspore_grpc)
add_compile_definitions(grpc_impl=mindspore_grpc_impl)
add_compile_definitions(grpc_core=mindspore_grpc_core)


function(ms_grpc_generate c_var h_var)
if(NOT ARGN)
message(SEND_ERROR "Error: ms_grpc_generate() called without any proto files")
return()
endif()
# add_compile_definitions(grpc=mindspore_grpc)

# add_compile_definitions(grpc_impl=mindspore_grpc_impl)


set(${c_var})
set(${h_var})

foreach(file ${ARGN})
get_filename_component(abs_file ${file} ABSOLUTE)
get_filename_component(file_name ${file} NAME_WE)
get_filename_component(file_dir ${abs_file} PATH)
file(RELATIVE_PATH rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${file_dir})

list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc")
list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h")
list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.cc")
list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.h")

add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc"
"${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h"
"${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.cc"
"${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.h"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto"
COMMAND protobuf::protoc --version
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto
--grpc_out=${CMAKE_BINARY_DIR}/proto
--plugin=protoc-gen-grpc=$<TARGET_FILE:grpc::grpc_cpp_plugin> ${abs_file}
DEPENDS protobuf::protoc grpc::grpc_cpp_plugin ${abs_file}
COMMENT "Running C++ gRPC compiler on ${file}" VERBATIM)
endforeach()

set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE)
set(${c_var} ${${c_var}} PARENT_SCOPE)
set(${h_var} ${${h_var}} PARENT_SCOPE)
# add_compile_definitions(grpc_core=mindspore_grpc_core)

function(ms_grpc_generate c_var h_var)
if(NOT ARGN)
message(SEND_ERROR "Error: ms_grpc_generate() called without any proto files")
return()
endif()

set(${c_var})
set(${h_var})

foreach(file ${ARGN})
get_filename_component(abs_file ${file} ABSOLUTE)
get_filename_component(file_name ${file} NAME_WE)
get_filename_component(file_dir ${abs_file} PATH)
file(RELATIVE_PATH rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${file_dir})

list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc")
list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h")
list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.cc")
list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.h")

add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc" "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h"
"${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.cc" "${CMAKE_BINARY_DIR}/proto/${file_name}.grpc.pb.h"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto"
COMMAND protobuf::protoc --version
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto --grpc_out=${CMAKE_BINARY_DIR}/proto
--plugin=protoc-gen-grpc=$<TARGET_FILE:gRPC::grpc_cpp_plugin> ${abs_file}
DEPENDS protobuf::protoc gRPC::grpc_cpp_plugin ${abs_file}
COMMENT "Running C++ gRPC compiler on ${file}"
VERBATIM)
endforeach()

set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE)
set(${c_var}
${${c_var}}
PARENT_SCOPE)
set(${h_var}
${${h_var}}
PARENT_SCOPE)
endfunction() endfunction()

+ 46
- 54
cmake/external_libs/gtest.cmake View File

@@ -1,67 +1,59 @@
set(gtest_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(gtest_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(gtest_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(gtest_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")


set(CMAKE_OPTION
-DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON
-DCMAKE_MACOSX_RPATH=TRUE -Dgtest_disable_pthreads=ON)
set(CMAKE_OPTION -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON
-DCMAKE_MACOSX_RPATH=TRUE -Dgtest_disable_pthreads=ON -Dgtest_build_samples=OFF
-Dgtest_build_tests=OFF)
if(BUILD_LITE) if(BUILD_LITE)
if(PLATFORM_ARM64)
set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
-DANDROID_NATIVE_API_LEVEL=19
-DANDROID_NDK=$ENV{ANDROID_NDK}
-DANDROID_ABI=arm64-v8a
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
-DANDROID_STL=${ANDROID_STL}
${CMAKE_OPTION})
endif()
if(PLATFORM_ARM32)
set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
-DANDROID_NATIVE_API_LEVEL=19
-DANDROID_NDK=$ENV{ANDROID_NDK}
-DANDROID_ABI=armeabi-v7a
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
-DANDROID_STL=${ANDROID_STL}
${CMAKE_OPTION})
endif()
if(PLATFORM_ARM64)
set(CMAKE_OPTION
-DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
-DANDROID_NATIVE_API_LEVEL=19
-DANDROID_NDK=$ENV{ANDROID_NDK}
-DANDROID_ABI=arm64-v8a
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
-DANDROID_STL=${ANDROID_STL}
${CMAKE_OPTION})
endif()
if(PLATFORM_ARM32)
set(CMAKE_OPTION
-DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
-DANDROID_NATIVE_API_LEVEL=19
-DANDROID_NDK=$ENV{ANDROID_NDK}
-DANDROID_ABI=armeabi-v7a
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
-DANDROID_STL=${ANDROID_STL}
${CMAKE_OPTION})
endif()
endif() endif()


if(NOT ENABLE_GLIBCXX) if(NOT ENABLE_GLIBCXX)
set(gtest_CXXFLAGS "${gtest_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
set(gtest_CXXFLAGS "${gtest_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif() endif()


if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/googletest/repository/archive/release-1.8.1.tar.gz")
set(MD5 "2e6fbeb6a91310a16efe181886c59596")
set(REQ_URL "https://gitee.com/mirrors/googletest/repository/archive/release-1.11.0.tar.gz")
set(MD5 "e8a8df240b6938bb6384155d4c37d937")
else() else()
set(REQ_URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz")
set(MD5 "2e6fbeb6a91310a16efe181886c59596")
set(REQ_URL "https://github.com/google/googletest/archive/release-1.11.0.tar.gz")
set(MD5 "e8a8df240b6938bb6384155d4c37d937")
endif() endif()


mindspore_add_pkg(gtest
VER 1.8.1
LIBS gtest gmock
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION ${CMAKE_OPTION})
include_directories(${gtest_INC})
add_library(mindspore::gtest ALIAS gtest::gtest)
add_library(mindspore::gmock ALIAS gtest::gmock)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
file(COPY ${gtest_DIRPATH}/bin/libgtest${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
file(COPY ${gtest_DIRPATH}/bin/libgtest_main${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
file(COPY ${gtest_DIRPATH}/bin/libgmock_main${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
file(COPY ${gtest_DIRPATH}/bin/libgmock${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
else()
file(COPY ${gtest_LIBPATH}/libgtest${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
file(COPY ${gtest_LIBPATH}/libgtest_main${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
file(COPY ${gtest_LIBPATH}/libgmock${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
file(COPY ${gtest_LIBPATH}/libgmock_main${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION
${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
endif()
mindspore_add_pkg(
GTest
VER 1.8.1
LIBS gtest gmock gtest_main gmock_main
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION ${CMAKE_OPTION}
TARGET_ALIAS mindspore::gtest GTest::gtest
TARGET_ALIAS mindspore::gmock GTest::gmock)

foreach(_tgt GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)
foreach(_prop IMPORTED_LOCATION_RELEASE IMPORTED_LOCATION IMPORTED_LOCATION_DEBUG IMPORTED_LOCATION_NOCONFIG)
get_target_property(_lib ${_tgt} ${_prop})
if(_lib)
file(COPY ${_lib} DESTINATION ${CMAKE_BINARY_DIR}/googletest/googlemock/gtest)
endif()
endforeach()
endforeach()

+ 39
- 41
cmake/external_libs/icu4c.cmake View File

@@ -3,56 +3,54 @@ set(LIB_ICU_DATA icudata)
set(LIB_ICU_I18N icui18n) set(LIB_ICU_I18N icui18n)


if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/icu/repository/archive/release-67-1.tar.gz")
set(MD5 "0c2662a2b0bc80b0eb56495205247c8f")
set(REQ_URL "https://gitee.com/mirrors/icu/repository/archive/release-67-1.tar.gz")
set(MD5 "0c2662a2b0bc80b0eb56495205247c8f")
else() else()
set(REQ_URL "https://github.com/unicode-org/icu/archive/release-67-1.tar.gz")
set(MD5 "fd525fb47d8827b0b7da78b51dd2d93f")
set(REQ_URL "https://github.com/unicode-org/icu/archive/release-67-1.tar.gz")
set(MD5 "fd525fb47d8827b0b7da78b51dd2d93f")
endif() endif()


if(CMAKE_SYSTEM_NAME MATCHES "Windows") if(CMAKE_SYSTEM_NAME MATCHES "Windows")
message("icu4c thirdparty do not support windows currently.")
message("icu4c thirdparty do not support windows currently.")
else() else()
set(JSON_FILE "{ \n\
set(JSON_FILE
"{ \n\
\"strategy\": \"additive\",\n\ \"strategy\": \"additive\",\n\
\"featureFilters\": {\n\ \"featureFilters\": {\n\
\"normalization\": \"include\"\n\ \"normalization\": \"include\"\n\
}\n\ }\n\
}\ }\
") ")
file(WRITE ${CMAKE_BINARY_DIR}/icu4c_filter.json ${JSON_FILE})
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
mindspore_add_pkg(icu4c
VER 67.1
LIBS ${LIB_ICU_COMMON} ${LIB_ICU_DATA} ${LIB_ICU_I18N}
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/icu4c/icu4c.patch01
CONFIGURE_COMMAND ./icu4c/source/runConfigureICU MacOSX --disable-tests
--disable-samples --disable-icuio --disable-extras
ICU_DATA_FILTER_FILE=${CMAKE_BINARY_DIR}/icu4c_filter.json
)
else()
mindspore_add_pkg(icu4c
VER 67.1
LIBS ${LIB_ICU_COMMON} ${LIB_ICU_DATA} ${LIB_ICU_I18N}
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${TOP_DIR}/third_party/patch/icu4c/icu4c.patch01
CONFIGURE_COMMAND ./icu4c/source/runConfigureICU Linux --enable-rpath --disable-tests --disable-samples
--disable-icuio --disable-extras
ICU_DATA_FILTER_FILE=${CMAKE_BINARY_DIR}/icu4c_filter.json
)
endif()
include_directories(${icu4c_INC})
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
include(${CMAKE_SOURCE_DIR}/cmake/change_rpath.cmake)
changerpath($<TARGET_FILE:icu4c::${LIB_ICU_COMMON}> ${LIB_ICU_COMMON} "libicuuc;libicudata")
changerpath($<TARGET_FILE:icu4c::${LIB_ICU_DATA}> ${LIB_ICU_DATA} "libicudata")
changerpath($<TARGET_FILE:icu4c::${LIB_ICU_I18N}> ${LIB_ICU_I18N} "libicuuc;libicudata;libicui18n")
endif()
add_library(mindspore::icuuc ALIAS icu4c::${LIB_ICU_COMMON})
add_library(mindspore::icudata ALIAS icu4c::${LIB_ICU_DATA})
add_library(mindspore::icui18n ALIAS icu4c::${LIB_ICU_I18N})
add_definitions(-D ENABLE_ICU4C)
file(WRITE ${CMAKE_BINARY_DIR}/icu4c_filter.json ${JSON_FILE})
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/icu4c/icu4c.patch01)
set(CONFIGURE_COMMAND ./icu4c/source/runConfigureICU MacOSX --disable-tests --disable-samples --disable-icuio
--disable-extras ICU_DATA_FILTER_FILE=${CMAKE_BINARY_DIR}/icu4c_filter.json)
else()
set(PATCHES ${TOP_DIR}/third_party/patch/icu4c/icu4c.patch01)
set(CONFIGURE_COMMAND ./icu4c/source/runConfigureICU Linux --enable-rpath --disable-tests --disable-samples
--disable-icuio --disable-extras ICU_DATA_FILTER_FILE=${CMAKE_BINARY_DIR}/icu4c_filter.json)
endif()

mindspore_add_pkg(
ICU
VER 67.1
LIBS ${LIB_ICU_COMMON} ${LIB_ICU_DATA} ${LIB_ICU_I18N}
LIBS_CMAKE_NAMES uc data i18n
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${PATCHES}
CONFIGURE_COMMAND ${CONFIGURE_COMMAND}
GEN_CMAKE_CONFIG
TARGET_ALIAS mindspore::icuuc ICU::uc
TARGET_ALIAS mindspore::icudata ICU::data
TARGET_ALIAS mindspore::icui18n ICU::i18n)

if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND NOT MS_ICU_PREFER_SYSTEM)
include(${CMAKE_SOURCE_DIR}/cmake/change_rpath.cmake)
changerpath($<TARGET_FILE:ICU::uc> ${LIB_ICU_COMMON} "libicuuc;libicudata")
changerpath($<TARGET_FILE:ICU::data> ${LIB_ICU_DATA} "libicudata")
changerpath($<TARGET_FILE:ICU::i18n> ${LIB_ICU_I18N} "libicuuc;libicudata;libicui18n")
endif()
add_definitions(-DENABLE_ICU4C)
endif() endif()

+ 39
- 37
cmake/external_libs/jpeg_turbo.cmake View File

@@ -1,56 +1,58 @@

if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/libjpeg-turbo/repository/archive/2.0.4.tar.gz")
set(MD5 "44c43e4a9fb352f47090804529317c88")
set(REQ_URL "https://gitee.com/mirrors/libjpeg-turbo/repository/archive/2.0.4.tar.gz")
set(MD5 "44c43e4a9fb352f47090804529317c88")
else() else()
set(REQ_URL "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.4.tar.gz")
set(MD5 "44c43e4a9fb352f47090804529317c88")
set(REQ_URL "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.4.tar.gz")
set(MD5 "44c43e4a9fb352f47090804529317c88")
endif() endif()


if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(jpeg_turbo_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -D_FORTIFY_SOURCE=2 \
set(jpeg_turbo_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -D_FORTIFY_SOURCE=2 \
-O2") -O2")
else() else()
set(jpeg_turbo_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC \
set(jpeg_turbo_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC \
-D_FORTIFY_SOURCE=2 -O2") -D_FORTIFY_SOURCE=2 -O2")
endif() endif()


set(jpeg_turbo_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack,-s") set(jpeg_turbo_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack,-s")



set(jpeg_turbo_USE_STATIC_LIBS ON) set(jpeg_turbo_USE_STATIC_LIBS ON)
set(JPEG_TURBO_PATCHE ${CMAKE_SOURCE_DIR}/third_party/patch/jpeg_turbo/jpeg_turbo.patch001) set(JPEG_TURBO_PATCHE ${CMAKE_SOURCE_DIR}/third_party/patch/jpeg_turbo/jpeg_turbo.patch001)
set(CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_RPATH=TRUE -DWITH_SIMD=ON) set(CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_RPATH=TRUE -DWITH_SIMD=ON)
if(BUILD_LITE) if(BUILD_LITE)
set(jpeg_turbo_USE_STATIC_LIBS OFF)
set(JPEG_TURBO_PATCHE ${TOP_DIR}/third_party/patch/jpeg_turbo/jpeg_turbo.patch001)
if(PLATFORM_ARM64)
set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
-DANDROID_NATIVE_API_LEVEL=19
-DANDROID_NDK=$ENV{ANDROID_NDK}
-DANDROID_ABI=arm64-v8a
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
-DANDROID_STL=c++_shared -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
endif()
if(PLATFORM_ARM32)
set(CMAKE_OPTION -DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
-DANDROID_NATIVE_API_LEVEL=19
-DANDROID_NDK=$ENV{ANDROID_NDK}
-DANDROID_ABI=armeabi-v7a
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
-DANDROID_STL=c++_shared -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
endif()
set(jpeg_turbo_USE_STATIC_LIBS OFF)
set(JPEG_TURBO_PATCHE ${TOP_DIR}/third_party/patch/jpeg_turbo/jpeg_turbo.patch001)
if(PLATFORM_ARM64)
set(CMAKE_OPTION
-DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
-DANDROID_NATIVE_API_LEVEL=19
-DANDROID_NDK=$ENV{ANDROID_NDK}
-DANDROID_ABI=arm64-v8a
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
-DANDROID_STL=c++_shared
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
endif()
if(PLATFORM_ARM32)
set(CMAKE_OPTION
-DCMAKE_TOOLCHAIN_FILE=$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake
-DANDROID_NATIVE_API_LEVEL=19
-DANDROID_NDK=$ENV{ANDROID_NDK}
-DANDROID_ABI=armeabi-v7a
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang
-DANDROID_STL=c++_shared
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
endif()


endif() endif()


mindspore_add_pkg(jpeg_turbo
VER 2.0.4
LIBS jpeg turbojpeg
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION ${CMAKE_OPTION}
PATCHES ${JPEG_TURBO_PATCHE}
)
include_directories(${jpeg_turbo_INC})
add_library(mindspore::jpeg_turbo ALIAS jpeg_turbo::jpeg)
add_library(mindspore::turbojpeg ALIAS jpeg_turbo::turbojpeg)
mindspore_add_pkg(
TurboJPEG
VER 2.0.4
LIBS JPEG TurboJPEG
URL ${REQ_URL}
MD5 ${MD5}
GEN_CMAKE_CONFIG
CMAKE_OPTION ${CMAKE_OPTION}
PATCHES ${JPEG_TURBO_PATCHE}
TARGET_ALIAS mindspore::jpeg_turbo TurboJPEG::JPEG
TARGET_ALIAS mindspore::turbojpeg TurboJPEG::TurboJPEG)

+ 19
- 18
cmake/external_libs/json.cmake View File

@@ -1,26 +1,27 @@
if(MSVC) if(MSVC)
set(flatbuffers_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_CFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(flatbuffers_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_CFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
else() else()
set(nlohmann_json373_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(nlohmann_json373_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(nlohmann_json373_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(nlohmann_json373_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
endif() endif()


if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/JSON-for-Modern-CPP/repository/archive/v3.7.3.zip")
set(MD5 "b758acca4f3e133bacf919e31ca302e3")
set(INCLUDE "./include")
set(REQ_URL "https://gitee.com/mirrors/JSON-for-Modern-CPP/repository/archive/v3.7.3.tar.gz")
set(MD5 "b758acca4f3e133bacf919e31ca302e3")
set(INCLUDE "./include")
else() else()
set(REQ_URL "https://github.com/nlohmann/json/releases/download/v3.7.3/include.zip")
set(MD5 "fb96f95cdf609143e998db401ca4f324")
set(INCLUDE "./include")
set(REQ_URL "https://github.com/nlohmann/json/archive/v3.7.3.tar.gz")
set(MD5 "846bbc611ce9ecd7d45d6554679245e1")
set(INCLUDE "./include")
endif() endif()


mindspore_add_pkg(nlohmann_json373
VER 3.7.3
HEAD_ONLY ${INCLUDE}
URL ${REQ_URL}
MD5 ${MD5})
include_directories(${nlohmann_json373_INC})
add_library(mindspore::json ALIAS nlohmann_json373)
mindspore_add_pkg(
nlohmann_json
VER 3.7.3
CMAKE_PKG_NO_COMPONENTS
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DBUILD_TESTING=OFF -DJSON_MultipleHeaders=ON
TARGET_ALIAS mindspore::json nlohmann_json::nlohmann_json)

+ 19
- 19
cmake/external_libs/libevent.cmake View File

@@ -1,30 +1,30 @@
set(libevent_CFLAGS "-fstack-protector-all -D_FORTIFY_SOURCE=2 -O2") set(libevent_CFLAGS "-fstack-protector-all -D_FORTIFY_SOURCE=2 -O2")
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(libevent_LDFLAGS "-Wl,-z,now")
set(libevent_LDFLAGS "-Wl,-z,now")
endif() endif()


if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/libevent/repository/archive/release-2.1.12-stable.tar.gz")
set(MD5 "0d5a27436bf7ff8253420c8cf09f47ca")
set(REQ_URL "https://gitee.com/mirrors/libevent/repository/archive/release-2.1.12-stable.tar.gz")
set(MD5 "0d5a27436bf7ff8253420c8cf09f47ca")
else() else()
set(REQ_URL
set(REQ_URL
"https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz") "https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz")
set(MD5 "b5333f021f880fe76490d8a799cd79f4")
set(MD5 "b5333f021f880fe76490d8a799cd79f4")
endif() endif()


message("libevent using openssl stub dir: " ${openssl_ROOT}) message("libevent using openssl stub dir: " ${openssl_ROOT})


mindspore_add_pkg(libevent
VER 2.1.12
LIBS event event_pthreads event_core event_openssl
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/libevent/libevent.patch001
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_TESTING=OFF -DOPENSSL_ROOT_DIR:PATH=${openssl_ROOT})
include_directories(${libevent_INC})
add_library(mindspore::event ALIAS libevent::event)
add_library(mindspore::event_pthreads ALIAS libevent::event_pthreads)
add_library(mindspore::event_core ALIAS libevent::event_core)
add_library(mindspore::event_openssl ALIAS libevent::event_openssl)
mindspore_add_pkg(
Libevent
NS_NAME libevent
VER 2.1.12
LIBS event_pthreads event_core event_extra event_openssl
LIBS_CMAKE_NAMES pthreads core extra openssl
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/libevent/libevent.patch001
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_TESTING=OFF -DOPENSSL_ROOT_DIR:PATH=${openssl_ROOT}
TARGET_ALIAS mindspore::event_extra libevent::extra
TARGET_ALIAS mindspore::event_pthreads libevent::pthreads
TARGET_ALIAS mindspore::event_core libevent::core
TARGET_ALIAS mindspore::event_openssl libevent::openssl)

+ 32
- 17
cmake/external_libs/libtiff.cmake View File

@@ -1,34 +1,49 @@
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(tiff_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -Wno-unused-result \
set(tiff_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -Wno-unused-result \
-Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2") -Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2")
set(tiff_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -Wno-unused-result \
set(tiff_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -Wno-unused-result \
-Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2") -Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2")
else() else()
set(tiff_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-unused-result \
set(tiff_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-unused-result \
-Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2") -Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2")
set(tiff_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-unused-result \
set(tiff_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-unused-result \
-Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2") -Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2")
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(tiff_CFLAGS "${tiff_CFLAGS} -Wno-int-to-pointer-cast -Wno-implicit-fallthrough -Wno-pointer-to-int-cast") set(tiff_CFLAGS "${tiff_CFLAGS} -Wno-int-to-pointer-cast -Wno-implicit-fallthrough -Wno-pointer-to-int-cast")
endif()
endif()
endif() endif()


set(tiff_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") set(tiff_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")


if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/libtiff/repository/archive/v4.2.0.tar.gz")
set(MD5 "1b8f32e39940ffbdac3638f7081ba9e0")
set(REQ_URL "https://gitee.com/mirrors/libtiff/repository/archive/v4.2.0.tar.gz")
set(MD5 "1b8f32e39940ffbdac3638f7081ba9e0")
else() else()
set(REQ_URL "http://download.osgeo.org/libtiff/tiff-4.2.0.tar.gz")
set(MD5 "2bbf6db1ddc4a59c89d6986b368fc063")
set(REQ_URL "http://download.osgeo.org/libtiff/tiff-4.2.0.tar.gz")
set(MD5 "2bbf6db1ddc4a59c89d6986b368fc063")
endif() endif()


mindspore_add_pkg(tiff
VER 4.2.0
LIBS tiff
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -Djbig=OFF -Dlzma=OFF -Djpeg12=OFF -Dzstd=OFF -Dpixarlog=OFF
-Dold-jpeg=OFF -Dwebp=OFF -DBUILD_SHARED_LIBS=OFF -Dlibdeflate=OFF)
mindspore_add_pkg(
TIFF
VER 4.2.0
LIBS TIFF
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_PKG_NO_COMPONENTS GEN_CMAKE_CONFIG
CMAKE_OPTION
-DCMAKE_BUILD_TYPE=Release
-Djbig=OFF
-Dlzma=OFF
-Djpeg12=OFF
-Dzstd=OFF
-Dpixarlog=OFF
-Dold-jpeg=OFF
-Dwebp=OFF
-DBUILD_SHARED_LIBS=OFF
-Dlibdeflate=OFF)

set(tiff_INC "${TIFF_INCLUDE_DIR}")
set(tiff_LIB "${TIFF_LIBRARIES}")

message("tiff include = ${tiff_INC}") message("tiff include = ${tiff_INC}")
message("tiff lib = ${tiff_LIB}") message("tiff lib = ${tiff_LIB}")

+ 31
- 28
cmake/external_libs/mkl_dnn.cmake View File

@@ -1,37 +1,40 @@
set(onednn_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(onednn_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(onednn_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(onednn_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")

if(USE_MS_THREADPOOL_FOR_DNNL) if(USE_MS_THREADPOOL_FOR_DNNL)
set(USE_MS_THREADPOOL "-DDNNL_CPU_RUNTIME=THREADPOOL")
set(USE_MS_THREADPOOL "-DDNNL_CPU_RUNTIME=THREADPOOL")
else() else()
set(USE_MS_THREADPOOL "")
set(USE_MS_THREADPOOL "")
endif() endif()

if(CMAKE_SYSTEM_NAME MATCHES "Windows") if(CMAKE_SYSTEM_NAME MATCHES "Windows")
mindspore_add_pkg(onednn
VER 2.2
LIBS dnnl mkldnn
HEAD_ONLY ./include
RELEASE on
URL http://tools.mindspore.cn/libs/dnnl/dnnl_win_2.2.0_cpu_vcomp.zip
MD5 139fcdbd601a970fb86dd15b30ba5ae3)
set(ARGS HEAD_ONLY ./include RELEASE on)
set(VERSION 2.2)
set(REQ_URL https://github.com/oneapi-src/oneDNN/releases/download/v2.2/dnnl_win_2.2.0_cpu_vcomp.zip)
set(MD5 fa12c693b2ec07700d174e1e99d60a7e)
else() else()
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/MKL-DNN/repository/archive/v2.2.tar.gz")
set(MD5 "49c650e0cc24ef9ae7033d4cb22ebfad")
else()
set(REQ_URL "https://github.com/oneapi-src/oneDNN/archive/v2.2.tar.gz")
set(MD5 "6a062e36ea1bee03ff55bf44ee243e27")
endif()
mindspore_add_pkg(onednn
VER 2.2
LIBS dnnl mkldnn
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/onednn/0001-fix-user-threadpool-bug.patch
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/onednn/0002-fix-pool-nthr-bug.patch
CMAKE_OPTION -DDNNL_ARCH_OPT_FLAGS='' -DDNNL_BUILD_EXAMPLES=OFF -DDNNL_BUILD_TESTS=OFF
${USE_MS_THREADPOOL} -DDNNL_ENABLE_CONCURRENT_EXEC=ON)
set(VERSION 2.5.0)
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/MKL-DNN/repository/archive/v2.5.2.tar.gz")
set(MD5 "fe4819264dcac225596bd30a1756ce8c")
else()
set(REQ_URL "https://github.com/oneapi-src/oneDNN/archive/v2.5.2.tar.gz")
set(MD5 "fff1c259d9f0bc87f2b3ca257acd472e")
endif()
set(ARGS
CMAKE_OPTION
-DDNNL_ARCH_OPT_FLAGS=''
-DDNNL_BUILD_EXAMPLES=OFF
-DDNNL_BUILD_TESTS=OFF
${USE_MS_THREADPOOL}
-DDNNL_ENABLE_CONCURRENT_EXEC=ON)
endif() endif()


include_directories(${onednn_INC})
add_library(mindspore::dnnl ALIAS onednn::dnnl)
add_library(mindspore::mkldnn ALIAS onednn::mkldnn)
mindspore_add_pkg(
DNNL
VER ${VERSION}
LIBS dnnl
URL ${REQ_URL}
MD5 ${MD5} ${ARGS}
TARGET_ALIAS mindspore::dnnl DNNL::dnnl
TARGET_ALIAS mindspore::mkldnn DNNL::dnnl)

+ 14
- 14
cmake/external_libs/nccl.cmake View File

@@ -1,19 +1,19 @@
if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/nccl/repository/archive/v2.7.6-1.tar.gz")
set(MD5 "6884364c2b1cf229f0bdaf94efcb5782")
set(REQ_URL "https://gitee.com/mirrors/nccl/repository/archive/v2.7.6-1.tar.gz")
set(MD5 "6884364c2b1cf229f0bdaf94efcb5782")
else() else()
set(REQ_URL "https://github.com/NVIDIA/nccl/archive/v2.7.6-1.tar.gz")
set(MD5 "073b19899f374c5ba07d2db02dc38f9f")
set(REQ_URL "https://github.com/NVIDIA/nccl/archive/v2.7.6-1.tar.gz")
set(MD5 "073b19899f374c5ba07d2db02dc38f9f")
endif() endif()


set(nccl_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(nccl_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(nccl
VER 2.7.6-1
LIBS nccl
URL ${REQ_URL}
MD5 ${MD5}
BUILD_OPTION src.build
INSTALL_INCS build/include/*
INSTALL_LIBS build/lib/*)
include_directories(${nccl_INC})
add_library(mindspore::nccl ALIAS nccl::nccl)
mindspore_add_pkg(
nccl
VER 2.7.6
LIBS nccl
URL ${REQ_URL}
MD5 ${MD5}
BUILD_OPTION src.install
BUILD_OPTION_PASS_PREFIX
GEN_CMAKE_CONFIG
TARGET_ALIAS mindspore::nccl nccl::nccl)

+ 14
- 13
cmake/external_libs/ompi.cmake View File

@@ -1,18 +1,19 @@
if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/ompi/repository/archive/v4.0.3.tar.gz")
set(MD5 "70f764c26ab6cd99487d58be0cd8c409")
set(REQ_URL "https://gitee.com/mirrors/ompi/repository/archive/v4.0.3.tar.gz")
set(MD5 "70f764c26ab6cd99487d58be0cd8c409")
else() else()
set(REQ_URL "https://github.com/open-mpi/ompi/archive/v4.0.3.tar.gz")
set(MD5 "86cb724e8fe71741ad3be4e7927928a2")
set(REQ_URL "https://github.com/open-mpi/ompi/archive/v4.0.3.tar.gz")
set(MD5 "86cb724e8fe71741ad3be4e7927928a2")
endif() endif()


set(ompi_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(ompi_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(ompi
VER 4.0.3
LIBS mpi
URL ${REQ_URL}
MD5 ${MD5}
PRE_CONFIGURE_COMMAND ./autogen.pl
CONFIGURE_COMMAND ./configure)
include_directories(${ompi_INC})
add_library(mindspore::ompi ALIAS ompi::mpi)
mindspore_add_pkg(
MPI
VER 3.0 # NB: in the case of MPI, this is the MPI standard version, not the actual library version
LIBS mpi
LIBS_CMAKE_NAMES C
URL ${REQ_URL}
MD5 ${MD5}
PRE_CONFIGURE_COMMAND ./autogen.pl
CONFIGURE_COMMAND ./configure
TARGET_ALIAS mindspore::ompi MPI::MPI_C)

+ 63
- 115
cmake/external_libs/opencv.cmake View File

@@ -1,130 +1,78 @@
if(MSVC) if(MSVC)
set(opencv_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(opencv_CFLAGS "${CMAKE_C_FLAGS}")
set(opencv_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(opencv_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(opencv_CFLAGS "${CMAKE_C_FLAGS}")
set(opencv_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_LDFLAGS "-Wl")
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_LDFLAGS "-Wl")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -Wno-attributes -Wno-unknown-pragmas")
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -Wno-unused-value -Wno-implicit-fallthrough")
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -Wno-attributes -Wno-unknown-pragmas")
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -Wno-unused-value -Wno-implicit-fallthrough")
else() else()
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2")
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -O2")
if(NOT ENABLE_GLIBCXX)
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
set(opencv_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack -s")
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2")
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -O2")
if(NOT ENABLE_GLIBCXX)
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
set(opencv_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack -s")
endif() endif()


if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/opencv/repository/archive/4.5.2.tar.gz")
set(MD5 "d3141f649ab2d76595fdd8991ee15c55")
set(REQ_URL "https://gitee.com/mirrors/opencv/repository/archive/4.5.2.tar.gz")
set(MD5 "d3141f649ab2d76595fdd8991ee15c55")
else() else()
set(REQ_URL "https://github.com/opencv/opencv/archive/4.5.2.tar.gz")
set(MD5 "d3141f649ab2d76595fdd8991ee15c55")
set(REQ_URL "https://github.com/opencv/opencv/archive/4.5.2.tar.gz")
set(MD5 "d3141f649ab2d76595fdd8991ee15c55")
endif() endif()


if(MSVC)
mindspore_add_pkg(opencv
VER 4.5.2
LIBS opencv_core452.lib opencv_imgcodecs452.lib opencv_imgproc452.lib
LIB_PATH x64/*/lib
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF
-DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=OFF
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DBUILD_opencv_videoio=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DCV_TRACE=OFF # cause memory usage increacing
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})
elseif(WIN32)
mindspore_add_pkg(opencv
VER 4.5.2
LIBS libopencv_core452.dll.a libopencv_imgcodecs452.dll.a libopencv_imgproc452.dll.a
LIB_PATH x64/mingw/lib
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF
-DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=OFF
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DBUILD_opencv_videoio=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DCV_TRACE=OFF # cause memory usage increacing
-DWITH_LAPACK=OFF
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})
else()
mindspore_add_pkg(opencv
VER 4.5.2
LIBS opencv_core opencv_imgcodecs opencv_imgproc
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF
-DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=OFF
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DCV_TRACE=OFF # cause memory usage increacing
-DWITH_LAPACK=OFF
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})
endif()
set(CMAKE_OPTION
-DCMAKE_BUILD_TYPE=Release
-DWITH_PROTOBUF=OFF
-DWITH_WEBP=OFF
-DWITH_IPP=OFF
-DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=OFF
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DCV_TRACE=OFF # cause memory usage increacing
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})


if(MSVC) if(MSVC)
include_directories(${opencv_INC})
add_library(mindspore::opencv_core ALIAS opencv::opencv_core452.lib)
add_library(mindspore::opencv_imgcodecs ALIAS opencv::opencv_imgcodecs452.lib)
add_library(mindspore::opencv_imgproc ALIAS opencv::opencv_imgproc452.lib)
set(LIBS opencv_core452.lib opencv_imgcodecs452.lib opencv_imgproc452.lib)
set(LIB_PATH LIB_PATH x64/*/lib)
list(APPEND CMAKE OPTION -DBUILD_opencv_videoio=OFF)
elseif(WIN32) elseif(WIN32)
include_directories(${opencv_INC})
add_library(mindspore::opencv_core ALIAS opencv::libopencv_core452.dll.a)
add_library(mindspore::opencv_imgcodecs ALIAS opencv::libopencv_imgcodecs452.dll.a)
add_library(mindspore::opencv_imgproc ALIAS opencv::libopencv_imgproc452.dll.a)
set(LIBS libopencv_core452.dll.a libopencv_imgcodecs452.dll.a libopencv_imgproc452.dll.a)
set(LIB_PATH LIB_PATH x64/mingw/lib)
list(APPEND CMAKE_OPTION -DBUILD_opencv_videoio=OFF -DWITH_LAPACK=OFF)
else() else()
include_directories(${opencv_INC}/opencv4)
add_library(mindspore::opencv_core ALIAS opencv::opencv_core)
add_library(mindspore::opencv_imgcodecs ALIAS opencv::opencv_imgcodecs)
add_library(mindspore::opencv_imgproc ALIAS opencv::opencv_imgproc)
list(APPEND CMAKE_OPTION -DWITH_LAPACK=OFF)
endif() endif()

mindspore_add_pkg(
OpenCV
VER 4.5.2
LIBS opencv_core opencv_imgcodecs opencv_imgproc
LIBS_CMAKE_NAMES core imgcodecs imgproc ${LIB_PATH}
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION ${CMAKE_OPTION}
TARGET_ALIAS mindspore::opencv_core opencv_core
TARGET_ALIAS mindspore::opencv_imgcodecs opencv_imgcodecs
TARGET_ALIAS mindspore::opencv_imgproc opencv_imgproc)

+ 18
- 19
cmake/external_libs/openssl.cmake View File

@@ -1,28 +1,27 @@
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/openssl/repository/archive/OpenSSL_1_1_1k.tar.gz")
set(MD5 "bdd51a68ad74618dd2519da8e0bcc759")
else()
set(REQ_URL "https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1k.tar.gz")
set(MD5 "bdd51a68ad74618dd2519da8e0bcc759")
endif()
set(VER 1.1.1m)


if(BUILD_LITE)
set(OPENSSL_PATCH_ROOT ${TOP_DIR}/third_party/patch/openssl)
# patch 'm' -> 0d -> 13 ('a' -> 01 -> 1, 'f' -> 06 -> 6, 'p' -> 10 -> 16, etc.)
set(VER_FOR_COMP 1.1.1.13)

string(REPLACE "." "_" _url_ver ${VER})

if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/openssl/repository/archive/OpenSSL_${_url_ver}.tar.gz")
set(MD5 "710c2368d28f1a25ab92e25b5b9b11ec")
else() else()
set(OPENSSL_PATCH_ROOT ${CMAKE_SOURCE_DIR}/third_party/patch/openssl)
set(REQ_URL "https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_${_url_ver}.tar.gz")
set(MD5 "710c2368d28f1a25ab92e25b5b9b11ec")
endif() endif()


if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR APPLE) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR APPLE)
mindspore_add_pkg(openssl
VER 1.1.1k
LIBS ssl crypto
mindspore_add_pkg(
OpenSSL
VER ${VER_FOR_COMP}
LIBS SSL Crypto
URL ${REQ_URL} URL ${REQ_URL}
MD5 ${MD5} MD5 ${MD5}
CONFIGURE_COMMAND ./config no-zlib no-shared CONFIGURE_COMMAND ./config no-zlib no-shared
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3711.patch
PATCHES ${OPENSSL_PATCH_ROOT}/CVE-2021-3712.patch
)
include_directories(${openssl_INC})
add_library(mindspore::ssl ALIAS openssl::ssl)
add_library(mindspore::crypto ALIAS openssl::crypto)
GEN_CMAKE_CONFIG
TARGET_ALIAS mindspore::ssl OpenSSL::SSL
TARGET_ALIAS mindspore::crypto OpenSSL::Crypto)
endif() endif()

+ 134
- 117
cmake/external_libs/protobuf.cmake View File

@@ -1,34 +1,34 @@
set(protobuf_USE_STATIC_LIBS ON) set(protobuf_USE_STATIC_LIBS ON)
if(BUILD_LITE) if(BUILD_LITE)
if(MSVC)
set(protobuf_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(protobuf_CFLAGS "${CMAKE_C_FLAGS}")
set(protobuf_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
else()
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
if(MSVC)
set(protobuf_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(protobuf_CFLAGS "${CMAKE_C_FLAGS}")
set(protobuf_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
else()
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
-fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2") -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
if(NOT ENABLE_GLIBCXX)
set(protobuf_CXXFLAGS "${protobuf_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
if(NOT ENABLE_GLIBCXX)
set(protobuf_CXXFLAGS "${protobuf_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif() endif()
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif()
else() else()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC \
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC \
-fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2") -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
-fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2") -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
else()
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
else()
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
-fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2") -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
if(NOT ENABLE_GLIBCXX)
set(protobuf_CXXFLAGS "${protobuf_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
if(NOT ENABLE_GLIBCXX)
set(protobuf_CXXFLAGS "${protobuf_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif() endif()
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif()
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif() endif()


set(_ms_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) set(_ms_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
@@ -37,120 +37,137 @@ string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")


if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/protobuf_source/repository/archive/v3.13.0.tar.gz")
set(MD5 "53ab10736257b3c61749de9800b8ce97")
set(REQ_URL "https://gitee.com/mirrors/protobuf_source/repository/archive/v3.13.0.tar.gz")
set(MD5 "53ab10736257b3c61749de9800b8ce97")
else() else()
set(REQ_URL "https://github.com/protocolbuffers/protobuf/archive/v3.13.0.tar.gz")
set(MD5 "1a6274bc4a65b55a6fa70e264d796490")
set(REQ_URL "https://github.com/protocolbuffers/protobuf/archive/v3.13.0.tar.gz")
set(MD5 "1a6274bc4a65b55a6fa70e264d796490")
endif() endif()


mindspore_add_pkg(protobuf
VER 3.13.0
LIBS protobuf
EXE protoc
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_PATH cmake/
CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release)
mindspore_add_pkg(
Protobuf
VER 3.13.0
NS_NAME protobuf
LIBS protobuf
LIBS_CMAKE_NAMES libprotobuf
FORCE_CONFIG_SEARCH
EXE protoc
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_PATH cmake/
CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
TARGET_ALIAS mindspore::protobuf protobuf::libprotobuf)


include_directories(${protobuf_INC})
add_library(mindspore::protobuf ALIAS protobuf::protobuf)
set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS})
if(MSVC) if(MSVC)
set(CMAKE_STATIC_LIBRARY_PREFIX, ${_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX})
set(CMAKE_STATIC_LIBRARY_PREFIX, ${_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX})
endif() endif()


function(common_protobuf_generate path c_var h_var) function(common_protobuf_generate path c_var h_var)
if(NOT ARGN)
message(SEND_ERROR "Error: ms_protobuf_generate() called without any proto files")
return()
endif()
if(NOT ARGN)
message(SEND_ERROR "Error: ms_protobuf_generate() called without any proto files")
return()
endif()


set(${c_var})
set(${h_var})
set(${c_var})
set(${h_var})


foreach(file ${ARGN})
get_filename_component(abs_file ${file} ABSOLUTE)
get_filename_component(file_name ${file} NAME_WE)
get_filename_component(file_dir ${abs_file} PATH)
file(RELATIVE_PATH rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${file_dir})
foreach(file ${ARGN})
get_filename_component(abs_file ${file} ABSOLUTE)
get_filename_component(file_name ${file} NAME_WE)
get_filename_component(file_dir ${abs_file} PATH)
file(RELATIVE_PATH rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${file_dir})


list(APPEND ${c_var} "${path}/${file_name}.pb.cc")
list(APPEND ${h_var} "${path}/${file_name}.pb.h")
add_custom_command(
OUTPUT "${path}/${file_name}.pb.cc" "${path}/${file_name}.pb.h"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${path}"
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${path} ${abs_file}
DEPENDS protobuf::protoc ${abs_file}
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM)
endforeach()
list(APPEND ${c_var} "${path}/${file_name}.pb.cc")
list(APPEND ${h_var} "${path}/${file_name}.pb.h")
add_custom_command(
OUTPUT "${path}/${file_name}.pb.cc" "${path}/${file_name}.pb.h"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${path}"
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${path} ${abs_file}
DEPENDS protobuf::protoc ${abs_file}
COMMENT "Running C++ protocol buffer compiler on ${file}"
VERBATIM)
endforeach()


set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE)
set(${c_var} ${${c_var}} PARENT_SCOPE)
set(${h_var} ${${h_var}} PARENT_SCOPE)
set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE)
set(${c_var}
${${c_var}}
PARENT_SCOPE)
set(${h_var}
${${h_var}}
PARENT_SCOPE)
endfunction() endfunction()


function(ms_protobuf_generate c_var h_var) function(ms_protobuf_generate c_var h_var)
common_protobuf_generate(${CMAKE_BINARY_DIR}/proto ${c_var} ${h_var} ${ARGN})
set(${c_var} ${${c_var}} PARENT_SCOPE)
set(${h_var} ${${h_var}} PARENT_SCOPE)
common_protobuf_generate(${CMAKE_BINARY_DIR}/proto ${c_var} ${h_var} ${ARGN})
set(${c_var}
${${c_var}}
PARENT_SCOPE)
set(${h_var}
${${h_var}}
PARENT_SCOPE)
endfunction() endfunction()


function(ms_protobuf_generate_py c_var h_var py_var) function(ms_protobuf_generate_py c_var h_var py_var)
if(NOT ARGN)
message(SEND_ERROR "Error: ms_protobuf_generate() called without any proto files")
return()
endif()
if(NOT ARGN)
message(SEND_ERROR "Error: ms_protobuf_generate() called without any proto files")
return()
endif()


set(${c_var})
set(${h_var})
set(${py_var})
set(${c_var})
set(${h_var})
set(${py_var})


foreach(file ${ARGN})
get_filename_component(abs_file ${file} ABSOLUTE)
get_filename_component(file_name ${file} NAME_WE)
get_filename_component(file_dir ${abs_file} PATH)
foreach(file ${ARGN})
get_filename_component(abs_file ${file} ABSOLUTE)
get_filename_component(file_name ${file} NAME_WE)
get_filename_component(file_dir ${abs_file} PATH)


list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc")
list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h")
list(APPEND ${py_var} "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py")
if(WIN32)
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc"
"${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h"
"${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto"
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND perl -pi.bak -e "s/import (.+_pb2.*)/from . import \\1/"
"${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
"${PROJECT_SOURCE_DIR}/mindspore/python/mindspore/train/"
DEPENDS protobuf::protoc ${abs_file}
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM)
else()
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc"
"${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h"
"${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto"
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND perl -pi -e "s/import (.+_pb2.*)/from . import \\1/"
"${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
COMMAND cp "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
"${PROJECT_SOURCE_DIR}/mindspore/python/mindspore/train/"
DEPENDS protobuf::protoc ${abs_file}
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM)
endif()
endforeach()
set_source_files_properties(${${c_var}} ${${h_var}} ${${py_var}} PROPERTIES GENERATED TRUE)
set(${c_var} ${${c_var}} PARENT_SCOPE)
set(${h_var} ${${h_var}} PARENT_SCOPE)
set(${py_var} ${${py_var}} PARENT_SCOPE)
list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc")
list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h")
list(APPEND ${py_var} "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py")
if(WIN32)
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc" "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h"
"${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto"
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND perl -pi.bak -e "s/import (.+_pb2.*)/from . import \\1/" "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
"${PROJECT_SOURCE_DIR}/mindspore/python/mindspore/train/"
DEPENDS protobuf::protoc ${abs_file}
COMMENT "Running C++ protocol buffer compiler on ${file}"
VERBATIM)
else()
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.cc" "${CMAKE_BINARY_DIR}/proto/${file_name}.pb.h"
"${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto"
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND protobuf::protoc -I${file_dir} --python_out=${CMAKE_BINARY_DIR}/proto ${abs_file}
COMMAND perl -pi -e "s/import (.+_pb2.*)/from . import \\1/" "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
COMMAND cp "${CMAKE_BINARY_DIR}/proto/${file_name}_pb2.py"
"${PROJECT_SOURCE_DIR}/mindspore/python/mindspore/train/"
DEPENDS protobuf::protoc ${abs_file}
COMMENT "Running C++ protocol buffer compiler on ${file}"
VERBATIM)
endif()
endforeach()
set_source_files_properties(${${c_var}} ${${h_var}} ${${py_var}} PROPERTIES GENERATED TRUE)
set(${c_var}
${${c_var}}
PARENT_SCOPE)
set(${h_var}
${${h_var}}
PARENT_SCOPE)
set(${py_var}
${${py_var}}
PARENT_SCOPE)
endfunction() endfunction()

+ 32
- 50
cmake/external_libs/pybind11.cmake View File

@@ -1,61 +1,43 @@
set(PYTHON_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}) set(PYTHON_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})


if(ENABLE_GITEE) if(ENABLE_GITEE)
if(PYTHON_VERSION MATCHES "3.9")
set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.6.1.tar.gz")
set(MD5 "cd04f7bd275fedb97e8b583c115769e6")
elseif(PYTHON_VERSION MATCHES "3.8")
set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.6.1.tar.gz")
set(MD5 "cd04f7bd275fedb97e8b583c115769e6")
elseif(PYTHON_VERSION MATCHES "3.7")
set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.4.3.tar.gz")
set(MD5 "8f69438201bc824c63e5774bf8c1d422")
else()
message("Could not find 'Python 3.8' or 'Python 3.7' or 'Python 3.9'")
return()
endif()
if(PYTHON_VERSION VERSION_GREATER_EQUAL 3.8.0)
set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.6.1.tar.gz")
set(MD5 "cd04f7bd275fedb97e8b583c115769e6")
elseif(PYTHON_VERSION VERSION_GREATER_EQUAL 3.7.0)
set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.4.3.tar.gz")
set(MD5 "8f69438201bc824c63e5774bf8c1d422")
else()
message("Could not find 'Python 3.8' or 'Python 3.7' or 'Python 3.9'")
return()
endif()
else() else()
if(PYTHON_VERSION MATCHES "3.9")
set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.6.1.tar.gz")
set(MD5 "32a7811f3db423df4ebfc731a28e5901")
elseif(PYTHON_VERSION MATCHES "3.8")
set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.6.1.tar.gz")
set(MD5 "32a7811f3db423df4ebfc731a28e5901")
elseif(PYTHON_VERSION MATCHES "3.7")
set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.4.3.tar.gz")
set(MD5 "62254c40f89925bb894be421fe4cdef2")
else()
message("Could not find 'Python 3.8' or 'Python 3.7' or 'Python 3.9'")
return()
endif()
if(PYTHON_VERSION VERSION_GREATER_EQUAL 3.8.0)
set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.6.1.tar.gz")
set(MD5 "32a7811f3db423df4ebfc731a28e5901")
elseif(PYTHON_VERSION VERSION_GREATER_EQUAL 3.7.0)
set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.4.3.tar.gz")
set(MD5 "62254c40f89925bb894be421fe4cdef2")
else()
message("Could not find 'Python 3.8' or 'Python 3.7' or 'Python 3.9'")
return()
endif()
endif() endif()
set(pybind11_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(pybind11_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(pybind11_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(pybind11_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")


if(PYTHON_VERSION MATCHES "3.9")
mindspore_add_pkg(pybind11
VER 2.6.1
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE
)
elseif(PYTHON_VERSION MATCHES "3.8")
mindspore_add_pkg(pybind11
VER 2.6.1
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE
)
if(PYTHON_VERSION VERSION_GREATER_EQUAL 3.8.0)
set(VER 2.6.1)
elseif(PYTHON_VERSION VERSION_GREATER_EQUAL 3.7.0)
set(VER 2.4.3)
else() else()
mindspore_add_pkg(pybind11
VER 2.4.3
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE
)
set(VER NOT-FOUND)
endif() endif()


include_directories(${pybind11_INC})
find_package(pybind11 REQUIRED)
set_property(TARGET pybind11::module PROPERTY IMPORTED_GLOBAL TRUE)
add_library(mindspore::pybind11_module ALIAS pybind11::module)
mindspore_add_pkg(
pybind11
VER ${VER}
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE
TARGET_ALIAS mindspore::pybind11_module pybind11::module)

+ 15
- 15
cmake/external_libs/re2.cmake View File

@@ -1,22 +1,22 @@
if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/re2/repository/archive/2019-12-01.tar.gz")
set(MD5 "527eab0c75d6a1a0044c6eefd816b2fb")
set(REQ_URL "https://gitee.com/mirrors/re2/repository/archive/2019-12-01.tar.gz")
set(MD5 "527eab0c75d6a1a0044c6eefd816b2fb")
else() else()
set(REQ_URL "https://github.com/google/re2/archive/2019-12-01.tar.gz")
set(MD5 "527eab0c75d6a1a0044c6eefd816b2fb")
set(REQ_URL "https://github.com/google/re2/archive/2019-12-01.tar.gz")
set(MD5 "527eab0c75d6a1a0044c6eefd816b2fb")
endif() endif()


if(NOT ENABLE_GLIBCXX) if(NOT ENABLE_GLIBCXX)
set(re2_CXXFLAGS "${re2_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
set(re2_CXXFLAGS "${re2_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif() endif()


mindspore_add_pkg(re2
VER 20191201
LIBS re2
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=TRUE)
include_directories(${re2_INC})
add_library(mindspore::re2 ALIAS re2::re2)
mindspore_add_pkg(
re2
VER 20191201
LIBS re2
URL ${REQ_URL}
MD5 ${MD5}
PATCHES ${TOP_DIR}/third_party/patch/re2/re2.patch001
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release -DRE2_BUILD_TESTING:BOOL=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=TRUE
TARGET_ALIAS mindspore::re2 re2::re2)

+ 34
- 39
cmake/external_libs/sentencepiece.cmake View File

@@ -1,49 +1,44 @@
if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/sentencepiece/repository/archive/v0.1.92.tar.gz")
set(MD5 "0fc99de9f09b9184398f49647791799f")
set(REQ_URL "https://gitee.com/mirrors/sentencepiece/repository/archive/v0.1.92.tar.gz")
set(MD5 "0fc99de9f09b9184398f49647791799f")
else() else()
set(REQ_URL "https://github.com/google/sentencepiece/archive/v0.1.92.tar.gz")
set(MD5 "5dfd2241914b5598a68b2a8542ed8e91")
set(REQ_URL "https://github.com/google/sentencepiece/archive/v0.1.92.tar.gz")
set(MD5 "5dfd2241914b5598a68b2a8542ed8e91")
endif() endif()


set(CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_ENABLE_SHARED=OFF)


if(WIN32) if(WIN32)
set(sentencepiece_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result -Wno-stringop-overflow \
set(sentencepiece_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result -Wno-stringop-overflow \
-Wno-format-extra-args -Wno-format") -Wno-format-extra-args -Wno-format")
set(sentencepiece_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(sentencepiece
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_USE_BUILTIN_PROTOBUF=ON -DSPM_ENABLE_SHARED=OFF
MD5 ${MD5}
)
set(sentencepiece_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
list(APPEND CMAKE_OPTION -DSPM_USE_BUILTIN_PROTOBUF=ON)
else() else()
set(sentencepiece_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result -Wno-sign-compare")
set(sentencepiece_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
if(ENABLE_GLIBCXX)
mindspore_add_pkg(sentencepiece
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_USE_BUILTIN_PROTOBUF=OFF -DSPM_ENABLE_SHARED=OFF
-DPROTOBUF_INC=${protobuf_INC} -DCMAKE_CXX_STANDARD=11
MD5 ${MD5}
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/sentencepiece/sentencepiece.patch001_cpu
)
else()
mindspore_add_pkg(sentencepiece
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_USE_BUILTIN_PROTOBUF=OFF -DSPM_ENABLE_SHARED=OFF
-DPROTOBUF_INC=${protobuf_INC}
MD5 ${MD5}
PATCHES ${TOP_DIR}/third_party/patch/sentencepiece/sentencepiece.patch001
)
endif()
set(sentencepiece_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result -Wno-sign-compare")
set(sentencepiece_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
list(APPEND CMAKE_OPTION -DSPM_USE_BUILTIN_PROTOBUF=OFF)
if(ENABLE_GLIBCXX)
set(PATCHES PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/sentencepiece/sentencepiece.patch001_cpu)
list(APPEND CMAKE_OPTION -DPROTOBUF_INC=${Protobuf_INC} -DCMAKE_CXX_STANDARD=11)
else()
set(PATCHES PATCHES ${TOP_DIR}/third_party/patch/sentencepiece/sentencepiece.patch001)
list(APPEND CMAKE_OPTION -DPROTOBUF_INC=${Protobuf_INC})
endif()
endif() endif()
include_directories(${sentencepiece_INC})
add_library(mindspore::sentencepiece ALIAS sentencepiece::sentencepiece)
add_library(mindspore::sentencepiece_train ALIAS sentencepiece::sentencepiece_train)


if(NOT MS_PREFER_SYSTEM_PKGS AND NOT MS_PROTOBUF_PREFER_SYSTEM)
list(APPEND CMAKE_OPTION -DCMAKE_PREFIX_PATH=${Protobuf_ROOT})
else()
# We rely on system discovery anyway so should work when building sentencepiece
endif()

mindspore_add_pkg(
sentencepiece
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
CMAKE_OPTION ${CMAKE_OPTION}
GEN_CMAKE_CONFIG
MD5 ${MD5} ${PATCHES}
TARGET_ALIAS mindspore::sentencepiece sentencepiece::sentencepiece
TARGET_ALIAS mindspore::sentencepiece_train sentencepiece::sentencepiece_train)

+ 26
- 31
cmake/external_libs/sqlite.cmake View File

@@ -1,40 +1,35 @@
if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/sqlite/repository/archive/version-3.36.0.tar.gz")
set(MD5 "715df9c2d2ccf6207158d6c087f711cf")
set(REQ_URL "https://gitee.com/mirrors/sqlite/repository/archive/version-3.36.0.tar.gz")
set(MD5 "715df9c2d2ccf6207158d6c087f711cf")
else() else()
set(REQ_URL "https://github.com/sqlite/sqlite/archive/version-3.36.0.tar.gz")
set(MD5 "715df9c2d2ccf6207158d6c087f711cf")
set(REQ_URL "https://github.com/sqlite/sqlite/archive/version-3.36.0.tar.gz")
set(MD5 "715df9c2d2ccf6207158d6c087f711cf")
endif() endif()



if(WIN32) if(WIN32)
mindspore_add_pkg(sqlite
VER 3.36.0
LIBS sqlite3
URL https://sqlite.org/2021/sqlite-amalgamation-3360000.zip
MD5 c5d360c74111bafae1b704721ff18fe6
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/sqlite/sqlite.windows.patch002
CMAKE_OPTION " "
)

set(REQ_URL https://sqlite.org/2021/sqlite-amalgamation-3360000.zip)
set(MD5 c5d360c74111bafae1b704721ff18fe6)
set(PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/sqlite/sqlite.windows.patch002)
else() else()
set(sqlite_USE_STATIC_LIBS ON)
set(sqlite_CXXFLAGS)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(sqlite_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -D_FORTIFY_SOURCE=2 \
set(SQLite3_USE_STATIC_LIBS ON)
set(SQLite3_CXXFLAGS "")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(SQLite3_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -D_FORTIFY_SOURCE=2 \
-O2") -O2")
else()
set(sqlite_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC \
else()
set(SQLite3_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC \
-D_FORTIFY_SOURCE=2 -O2") -D_FORTIFY_SOURCE=2 -O2")
set(sqlite_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif()
mindspore_add_pkg(sqlite
VER 3.36.0
LIBS sqlite3
URL ${REQ_URL}
MD5 ${MD5}
CONFIGURE_COMMAND ./configure --enable-shared=no --disable-tcl --disable-editline --enable-json1)
set(SQLite3_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif()
set(CONFIGURE_COMMAND CONFIGURE_COMMAND ./configure --enable-shared=no --disable-tcl --disable-editline
--enable-json1)
endif() endif()

include_directories(${sqlite_INC})
add_library(mindspore::sqlite ALIAS sqlite::sqlite3)
mindspore_add_pkg(
SQLite3
NS_NAME SQLite
VER 3.36.0
LIBS SQLite3
URL ${REQ_URL}
MD5 ${MD5} ${PATCHES} ${CONFIGURE_COMMAND}
GEN_CMAKE_CONFIG
TARGET_ALIAS mindspore::sqlite SQLite::SQLite3)

+ 14
- 14
cmake/external_libs/tinyxml2.cmake View File

@@ -2,23 +2,23 @@ set(tinyxml2_CXXFLAGS "-fstack-protector -D_FORTIFY_SOURCE=2 -O2 -Wno-unused-res
set(tinyxml2_CFLAGS "-fstack-protector -D_FORTIFY_SOURCE=2 -O2") set(tinyxml2_CFLAGS "-fstack-protector -D_FORTIFY_SOURCE=2 -O2")


if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/tinyxml2/repository/archive/8.0.0.tar.gz")
set(MD5 "5dc535c8b34ee621fe2128f072d275b5")
set(REQ_URL "https://gitee.com/mirrors/tinyxml2/repository/archive/8.0.0.tar.gz")
set(MD5 "5dc535c8b34ee621fe2128f072d275b5")
else() else()
set(REQ_URL "https://github.com/leethomason/tinyxml2/archive/8.0.0.tar.gz")
set(MD5 "5dc535c8b34ee621fe2128f072d275b5")
set(REQ_URL "https://github.com/leethomason/tinyxml2/archive/8.0.0.tar.gz")
set(MD5 "5dc535c8b34ee621fe2128f072d275b5")
endif() endif()



if(NOT WIN32 AND NOT APPLE) if(NOT WIN32 AND NOT APPLE)
set(tinyxml2_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
set(tinyxml2_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif() endif()


mindspore_add_pkg(tinyxml2
VER 8.0.0
LIBS tinyxml2
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release
MD5 ${MD5})
include_directories(${tinyxml2_INC})
add_library(mindspore::tinyxml2 ALIAS tinyxml2::tinyxml2)
mindspore_add_pkg(
tinyxml2
VER 8.0.0
LIBS tinyxml2
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release
CMAKE_PKG_NO_COMPONENTS
MD5 ${MD5}
TARGET_ALIAS mindspore::tinyxml2 tinyxml2::tinyxml2)

+ 14
- 13
cmake/external_libs/zlib.cmake View File

@@ -1,17 +1,18 @@
if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/zlib/repository/archive/v1.2.11.tar.gz")
set(MD5 "b0ecd8eda7c5d6ed9b4a4187363482fe")
set(REQ_URL "https://gitee.com/mirrors/zlib/repository/archive/v1.2.11.tar.gz")
set(MD5 "b0ecd8eda7c5d6ed9b4a4187363482fe")
else() else()
set(REQ_URL "https://github.com/madler/zlib/archive/v1.2.11.tar.gz")
set(MD5 "0095d2d2d1f3442ce1318336637b695f")
set(REQ_URL "https://github.com/madler/zlib/archive/v1.2.11.tar.gz")
set(MD5 "0095d2d2d1f3442ce1318336637b695f")
endif() endif()


mindspore_add_pkg(zlib
VER 1.2.11
LIBS z
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release)

include_directories(${zlib_INC})
add_library(mindspore::z ALIAS zlib::z)
mindspore_add_pkg(
ZLIB
VER 1.2.11
LIBS z
LIBS_CMAKE_NAMES ZLIB
GEN_CMAKE_CONFIG
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release
TARGET_ALIAS mindspore::z ZLIB::ZLIB)

+ 26
- 7
cmake/mind_expression.cmake View File

@@ -14,17 +14,34 @@ include(cmake/utils.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/eigen.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/eigen.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/json.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/json.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/dependency_securec.cmake) include(${CMAKE_SOURCE_DIR}/cmake/dependency_securec.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/openssl.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/zlib.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/protobuf.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/protobuf.cmake)


if(MS_BUILD_GRPC) if(MS_BUILD_GRPC)
# build dependencies of gRPC
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/openssl.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/absl.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/c-ares.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/zlib.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/re2.cmake)
if(NOT MS_PREFER_SYSTEM_PKGS AND NOT MS_GRPC_PREFER_SYSTEM)
# build dependencies of gRPC
if(NOT MS_PREFER_SYSTEM_PKGS AND NOT MS_ABSL_PREFER_SYSTEM)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/absl.cmake)
endif()
if(NOT MS_PREFER_SYSTEM_PKGS AND NOT MS_C-ARES_PREFER_SYSTEM)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/c-ares.cmake)
endif()
if(NOT MS_PREFER_SYSTEM_PKGS AND NOT MS_RE2_PREFER_SYSTEM)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/re2.cmake)
endif()
endif()
# build gRPC # build gRPC
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/grpc.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/grpc.cmake)

if(MS_PREFER_SYSTEM_PKGS OR MS_GRPC_PREFER_SYSTEM)
foreach(_lib strings throw_delegate raw_logging_internal int128 bad_optional_access)
if(NOT TARGET ${_lib})
add_library(mindspore::absl_${_lib} ALIAS absl::${_lib})
endif()
endforeach()
endif()

# build event # build event
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/libevent.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/libevent.cmake)
endif() endif()
@@ -66,7 +83,9 @@ endif()


if(ENABLE_MINDDATA) if(ENABLE_MINDDATA)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/icu4c.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/icu4c.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/libtiff.cmake)
if(NOT MS_OPENCV_PREFER_SYSTEM)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/libtiff.cmake)
endif()
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/opencv.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/opencv.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/sqlite.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/sqlite.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/external_libs/tinyxml2.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/tinyxml2.cmake)


+ 231
- 0
cmake/modules/FindEigen3.cmake View File

@@ -0,0 +1,231 @@
# ==============================================================================
#
# Copyright 2021 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ==============================================================================

#[=======================================================================[.rst:
FindEigen3
---------

Find Eigen3 include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(Eigen3
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if Eigen3 is not found
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "Eigen3
CMake" build. For the latter case skip to the :ref:`Eigen3 CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``Eigen3_FOUND``
True if headers and requested libraries were found.

``Eigen3_INCLUDE_DIRS``
Eigen3 include directories.

``Eigen3_LIBRARY_DIRS``
Link directories for Eigen3 libraries.

``Eigen3_LIBRARIES``
Eigen3 component libraries to be linked.

``Eigen3_VERSION``
Eigen3 version number in ``X.Y`` format.

``Eigen3_VERSION_MAJOR``
Eigen3 major version number (``X`` in ``X.Y``).

``Eigen3_VERSION_MINOR``
Eigen3 minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``Eigen3_INCLUDE_DIR``
Directory containing Eigen3 headers.

``Eigen3_LIBRARY_DIR_RELEASE``
Directory containing release Eigen3 libraries.

``Eigen3_LIBRARY_DIR_DEBUG``
Directory containing debug Eigen3 libraries.

Hints
^^^^^

This module reads hints about search locations from variables:

``Eigen3_ROOT``, ``Eigen3ROOT``
Preferred installation prefix.

``Eigen3_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``Eigen3_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``Eigen3_NO_CMAKE``
Set to ``ON`` to disable searching for CMake configuration files.Default is ``OFF``.

``Eigen3_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``Eigen3``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the Eigen3 header files using the above hint variables (excluding ``Eigen3_LIBRARYDIR``) and
saves the result in ``Eigen3_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``Eigen3_INCLUDEDIR``), "lib" directories near ``Eigen3_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``Eigen3_LIBRARY_DIR_DEBUG`` and ``Eigen3_LIBRARY_DIR_RELEASE`` and
individual library locations in ``Eigen3_<COMPONENT>_LIBRARY_DEBUG`` and ``Eigen3_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``Eigen3::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(Eigen3)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

Other variables one may set to control this module are:

``Eigen3_DEBUG``
Set to ``ON`` to enable debug output from ``FindEigen3``. Please enable this before filing any bug report.

``Eigen3_LIBRARY_DIR``
Default value for ``Eigen3_LIBRARY_DIR_RELEASE`` and ``Eigen3_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find Eigen3 headers only:

.. code-block:: cmake

find_package(Eigen3 3.4.0)
if(Eigen3_FOUND)
include_directories(${Eigen3_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC Eigen3::Eigen3)
endif()

Find Eigen3 libraries and use imported targets:

.. code-block:: cmake

find_package(Eigen3 6.2.1 REQUIRED)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC Eigen3::Eigen3)

.. _`Eigen3 CMake`:

Eigen3 CMake
^^^^^^^^^^^^

If Eigen3 was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``Eigen3Config.cmake`` and stores the result in ``CACHE``
entry ``Eigen3_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the Eigen3 CMake package configuration for details on what it provides.

Set ``Eigen3_NO_CMAKE`` to ``ON``, to disable the search for Eigen3-cmake.

Eigen3 PkgConfig
^^^^^^^^^^^^^^^^

If Eigen3 was installed with its pkg-config files, this module may attempt to look for Eigen3 by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``Eigen3_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg Eigen3)
set(${_pkg}_INCLUDE_FILE signature_of_eigen3_matrix_library)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/${_pkg} ${_pkg} include/eigen3 eigen3)
set(${_pkg}_DEFAULT_COMPONENTS Eigen)
set(${_pkg}_Eigen_NAMES Eigen)
set(${_pkg}_Eigen_HEADER_ONLY TRUE)

# Extract EIGEN3 version from include directory
function(Eigen3_version_function include_dir)
set(_paths ${include_dir}/Eigen/src/Core/util/)

_debug_print_var("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_paths")

find_file(
_Eigen3_h Macros.h
PATHS ${_paths}
NO_DEFAULT_PATH)

if(_Eigen3_h)
file(READ ${_Eigen3_h} _Eigen3_version_file)
string(REGEX REPLACE ".*#define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+).*" "\\1" Eigen3_VERSION_MAJOR
"${_Eigen3_version_file}")
string(REGEX REPLACE ".*#define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" Eigen3_VERSION_MINOR
"${_Eigen3_version_file}")
string(REGEX REPLACE ".*#define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" Eigen3_VERSION_PATCH
"${_Eigen3_version_file}")
else()
message(WARNING "Unable to determine Eigen3's version since Eigen/src/Core/util/Macros.h file cannot be found!")
set(Eigen3_VERSION_MAJOR 99)
set(Eigen3_VERSION_MINOR 99)
set(Eigen3_VERSION_PATCH 99)
endif()
set(Eigen3_VERSION "${Eigen3_VERSION_MAJOR}.${Eigen3_VERSION_MINOR}.${Eigen3_VERSION_PATCH}")

set(Eigen3_VERSION_MAJOR
${Eigen3_VERSION_MAJOR}
PARENT_SCOPE)
set(Eigen3_VERSION_MINOR
${Eigen3_VERSION_MINOR}
PARENT_SCOPE)
set(Eigen3_VERSION_PATCH
${Eigen3_VERSION_PATCH}
PARENT_SCOPE)
set(Eigen3_VERSION
${Eigen3_VERSION}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 94
- 0
cmake/modules/FindFlatbuffers.cmake View File

@@ -0,0 +1,94 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

include(_find_utils_begin)

set(_pkg Flatbuffers)
string(TOLOWER ${_pkg} _pkg_low)
set(${_pkg}_NAMESPACE flatbuffers)
set(${_pkg}_INCLUDE_FILE flatc.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/${_pkg_low} ${_pkg_low})
set(${_pkg}_INCLUDE_DIR_UP_INDEX 1)
set(${_pkg}_DEFAULT_COMPONENTS flatbuffers_shared flatc)
set(${_pkg}_flatbuffers_shared_NAMES flatbuffers)
set(${_pkg}_flatc_NAMES flatc)
set(${_pkg}_flatc_TYPE EXECUTABLE)

# Update RE2 library search directories with pre-built paths
function(flatc_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/lib)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

function(Flatbuffers_version_function include_dir)
find_file(
_flatbuffers_base_h base.h
PATHS ${include_dir}/flatbuffers
NO_DEFAULT_PATH)

if(_flatbuffers_base_h)
file(READ ${_flatbuffers_base_h} _flatbuffers_base_content)
string(REGEX MATCHALL "#define[ \t]+[a-zA-Z0-9_]+VERSION[a-zA-Z0-9_ ]+" _flatbuffers_base_content
"${_flatbuffers_base_content}")
list(APPEND _flatbuffers_base_content "")

if("${_flatbuffers_base_content}" MATCHES "#define[ \t]+FLATBUFFERS_VERSION_MAJOR[ \t]+([0-9]+)[^\\.]")
set(${_pkg}_VERSION_MAJOR ${CMAKE_MATCH_1})
endif()
if("${_flatbuffers_base_content}" MATCHES "#define[ \t]+FLATBUFFERS_VERSION_MINOR[ \t]+([0-9]+)[^\\.]")
set(${_pkg}_VERSION_MINOR ${CMAKE_MATCH_1})
endif()
if("${_flatbuffers_base_content}" MATCHES "#define[ \t]+FLATBUFFERS_VERSION_REVISION[ \t]+([0-9]+)[^\\.]")
set(${_pkg}_VERSION_PATCH ${CMAKE_MATCH_1})
endif()
endif()

if("${${_pkg}_VERSION_MAJOR}" STREQUAL "" AND "${${_pkg}_VERSION_MINOR}" STREQUAL "")
message(WARNING "Unable to determine Flatbuffers's version since flatbuffers/base.h file cannot be found!")
set(${_pkg}_VERSION_MAJOR 99)
set(${_pkg}_VERSION_MINOR 99)
set(${_pkg}_VERSION_PATCH 99)
endif()
set(${_pkg}_VERSION "${${_pkg}_VERSION_MAJOR}.${${_pkg}_VERSION_MINOR}.${${_pkg}_VERSION_PATCH}")

set(${_pkg}_VERSION_MAJOR
${${_pkg}_VERSION_MAJOR}
PARENT_SCOPE)
set(${_pkg}_VERSION_MINOR
${${_pkg}_VERSION_MINOR}
PARENT_SCOPE)
set(${_pkg}_VERSION_PATCH
${${_pkg}_VERSION_PATCH}
PARENT_SCOPE)
set(${_pkg}_VERSION
${${_pkg}_VERSION}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 246
- 0
cmake/modules/FindGTest.cmake View File

@@ -0,0 +1,246 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
FindGTest
---------

Find GTest include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(GTest
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if GTest is not found
[COMPONENTS <libs>...] # GTest libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "GTest
CMake" build. For the latter case skip to the :ref:`GTest CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``GTest_FOUND``
True if headers and requested libraries were found.

``GTest_INCLUDE_DIRS``
GTest include directories.

``GTest_LIBRARY_DIRS``
Link directories for GTest libraries.

``GTest_LIBRARIES``
GTest component libraries to be linked.

``GTest_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``GTest_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``GTest_VERSION``
GTest version number in ``X.Y`` format.

``GTest_VERSION_MAJOR``
GTest major version number (``X`` in ``X.Y``).

``GTest_VERSION_MINOR``
GTest minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``GTest_INCLUDE_DIR``
Directory containing GTest headers.

``GTest_LIBRARY_DIR_RELEASE``
Directory containing release GTest libraries.

``GTest_LIBRARY_DIR_DEBUG``
Directory containing debug GTest libraries.

``GTest_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``GTest_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``GTest_ROOT``, ``GTestROOT``
Preferred installation prefix.

``GTest_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``GTest_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``GTest_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``GTest``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the GTest header files using the above hint variables (excluding ``GTest_LIBRARYDIR``) and
saves the result in ``GTest_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``GTest_INCLUDEDIR``), "lib" directories near ``GTest_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``GTest_LIBRARY_DIR_DEBUG`` and ``GTest_LIBRARY_DIR_RELEASE`` and
individual library locations in ``GTest_<COMPONENT>_LIBRARY_DEBUG`` and ``GTest_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``GTest::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(GTest)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

GTest libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``GTest_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``GTest_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
GTest_FIND_RELEASE_ONLY is ``ON``).

``GTest_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``GTest_DEBUG``
Set to ``ON`` to enable debug output from ``FindGTest``. Please enable this before filing any bug report.

``GTest_LIBRARY_DIR``
Default value for ``GTest_LIBRARY_DIR_RELEASE`` and ``GTest_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find GTest headers only:

.. code-block:: cmake

find_package(GTest 2.0.0)
if(GTest_FOUND)
include_directories(${GTest_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC GTest::GTest)
endif()

Find GTest libraries and use imported targets:

.. code-block:: cmake

find_package(GTest 2.0.0 REQUIRED COMPONENTS GTest)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC GTest::GTest)

Find GTest headers and some *static* (release only) libraries:

.. code-block:: cmake

set(GTest_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(GTest_USE_RELEASE_LIBS ON) # only find release libs
find_package(GTest 2.0.0 COMPONENTS GTest)
if(GTest_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC GTest::GTest)
endif()

.. _`GTest CMake`:

GTest CMake
^^^^^^^^^^^

If GTest was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``GTestConfig.cmake`` and stores the result in ``CACHE``
entry ``GTest_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the GTest CMake package configuration for details on what it provides.

Set ``GTest_NO_CMAKE`` to ``ON``, to disable the search for the package using the CONFIG method.

.. _`GTest pkg-config`:

GTest CMake
^^^^^^^^^^^

If GTest was installed with its pkg-config files, this module may attempt to look for GTest by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``GTest_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg GTest)
string(TOLOWER ${_pkg} _pkg_lower)
set(${_pkg}_INCLUDE_FILE gtest.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/${_pkg_lower} ${_pkg_lower})
set(${_pkg}_DEFAULT_COMPONENTS gtest gmock)
set(${_pkg}_gtest_NAMES gtest)
set(${_pkg}_gmock_NAMES gmock)
set(${_pkg}_gtest_main_NAMES gtest_main)
set(${_pkg}_gmock_main_NAMES gmock_main)

# Update GTEST library search directories with pre-built paths
function(GTest_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/lib)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 290
- 0
cmake/modules/FindLibevent.cmake View File

@@ -0,0 +1,290 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
FindLibevent
---------

Find Libevent include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(Libevent
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if Libevent is not found
[COMPONENTS <libs>...] # Libevent libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "Libevent
CMake" build. For the latter case skip to the :ref:`Libevent CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``Libevent_FOUND``
True if headers and requested libraries were found.

``Libevent_INCLUDE_DIRS``
Libevent include directories.

``Libevent_LIBRARY_DIRS``
Link directories for Libevent libraries.

``Libevent_LIBRARIES``
Libevent component libraries to be linked.

``Libevent_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``Libevent_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``Libevent_VERSION``
Libevent version number in ``X.Y`` format.

``Libevent_VERSION_MAJOR``
Libevent major version number (``X`` in ``X.Y``).

``Libevent_VERSION_MINOR``
Libevent minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``Libevent_INCLUDE_DIR``
Directory containing Libevent headers.

``Libevent_LIBRARY_DIR_RELEASE``
Directory containing release Libevent libraries.

``Libevent_LIBRARY_DIR_DEBUG``
Directory containing debug Libevent libraries.

``Libevent_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``Libevent_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``Libevent_ROOT``, ``LibeventROOT``
Preferred installation prefix.

``Libevent_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``Libevent_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``Libevent_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``Libevent``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the Libevent header files using the above hint variables (excluding ``Libevent_LIBRARYDIR``) and
saves the result in ``Libevent_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``Libevent_INCLUDEDIR``), "lib" directories near ``Libevent_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``Libevent_LIBRARY_DIR_DEBUG`` and ``Libevent_LIBRARY_DIR_RELEASE`` and
individual library locations in ``Libevent_<COMPONENT>_LIBRARY_DEBUG`` and ``Libevent_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``Libevent::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(Libevent)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

Libevent libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``Libevent_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``Libevent_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
Libevent_FIND_RELEASE_ONLY is ``ON``).

``Libevent_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``Libevent_DEBUG``
Set to ``ON`` to enable debug output from ``FindLibevent``. Please enable this before filing any bug report.

``Libevent_LIBRARY_DIR``
Default value for ``Libevent_LIBRARY_DIR_RELEASE`` and ``Libevent_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find Libevent headers only:

.. code-block:: cmake

find_package(Libevent 2.0.0)
if(Libevent_FOUND)
include_directories(${Libevent_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC Libevent::Libevent)
endif()

Find Libevent libraries and use imported targets:

.. code-block:: cmake

find_package(Libevent 2.0.0 REQUIRED COMPONENTS Libevent)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC Libevent::Libevent)

Find Libevent headers and some *static* (release only) libraries:

.. code-block:: cmake

set(Libevent_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(Libevent_USE_RELEASE_LIBS ON) # only find release libs
find_package(Libevent 2.0.0 COMPONENTS Libevent)
if(Libevent_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC Libevent::Libevent)
endif()

.. _`Libevent CMake`:

Libevent CMake
^^^^^^^^^^^

If Libevent was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``LibeventConfig.cmake`` and stores the result in ``CACHE``
entry ``Libevent_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the Libevent CMake package configuration for details on what it provides.

Set ``Libevent_NO_CMAKE`` to ``ON``, to disable the search for the package using the CONFIG method.

.. _`Libevent pkg-config`:

Libevent CMake
^^^^^^^^^^^

If Libevent was installed with its pkg-config files, this module may attempt to look for Libevent by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``Libevent_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg Libevent)
set(${_pkg}_NAMESPACE libevent)
set(${_pkg}_INCLUDE_FILE event.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/${_pkg} ${_pkg})
set(${_pkg}_DEFAULT_COMPONENTS core extra pthreads openssl)
set(${_pkg}_core_NAMES event_core)
set(${_pkg}_extra_NAMES event_extra)
set(${_pkg}_pthreads_NAMES event_pthreads)
set(${_pkg}_openssl_NAMES event_openssl)

# Extract LIBEVENT version from include directory
function(Libevent_version_function include_dir)
set(_paths ${include_dir}/event2 ${include_dir}/event)

_debug_print_var("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_paths")

find_file(
_event_config_h event-config.h
PATHS ${_paths}
NO_DEFAULT_PATH)

if(_event_config_h)
file(READ ${_event_config_h} _event_config_file)
set(_ver_type MAJOR MINOR PATCH)
foreach(_type ${_ver_type})
set(_var EVENT__VERSION_${_type})
if("${_event_config_file}" MATCHES ".*#define[ \t]+${_var}[ \t]+([0-9]+).*")
_debug_print("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" " ${_type} version read from ${_var}")
set(${_pkg}_VERSION_${_type} ${CMAKE_MATCH_1})
endif()
endforeach()
else()
message(WARNING "Unable to determine Libevent's version since event-config.h file cannot be found!")
set(${_pkg}_VERSION_MAJOR 99)
set(${_pkg}_VERSION_MINOR 99)
set(${_pkg}_VERSION_PATCH 99)
endif()

set(${_pkg}_VERSION "${${_pkg}_VERSION_MAJOR}.${${_pkg}_VERSION_MINOR}.${${_pkg}_VERSION_PATCH}")

set(${_pkg}_VERSION_MAJOR
${${_pkg}_VERSION_MAJOR}
PARENT_SCOPE)
set(${_pkg}_VERSION_MINOR
${${_pkg}_VERSION_MINOR}
PARENT_SCOPE)
set(${_pkg}_VERSION_PATCH
${${_pkg}_VERSION_PATCH}
PARENT_SCOPE)
set(${_pkg}_VERSION
${${_pkg}_VERSION}
PARENT_SCOPE)
endfunction()

# Update LIBEVENT library search directories with pre-built paths
function(Libevent_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/lib)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 271
- 0
cmake/modules/FindOpenCV.cmake View File

@@ -0,0 +1,271 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
FindOpenCV
---------

Find OpenCV include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(OpenCV
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if OpenCV is not found
[COMPONENTS <libs>...] # OpenCV libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "OpenCV
CMake" build. For the latter case skip to the :ref:`OpenCV CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``OpenCV_FOUND``
True if headers and requested libraries were found.

``OpenCV_INCLUDE_DIRS``
OpenCV include directories.

``OpenCV_LIBRARY_DIRS``
Link directories for OpenCV libraries.

``OpenCV_LIBRARIES``
OpenCV component libraries to be linked.

``OpenCV_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``OpenCV_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``OpenCV_VERSION``
OpenCV version number in ``X.Y`` format.

``OpenCV_VERSION_MAJOR``
OpenCV major version number (``X`` in ``X.Y``).

``OpenCV_VERSION_MINOR``
OpenCV minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``OpenCV_INCLUDE_DIR``
Directory containing OpenCV headers.

``OpenCV_LIBRARY_DIR_RELEASE``
Directory containing release OpenCV libraries.

``OpenCV_LIBRARY_DIR_DEBUG``
Directory containing debug OpenCV libraries.

``OpenCV_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``OpenCV_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``OpenCV_ROOT``, ``OpenCVROOT``
Preferred installation prefix.

``OpenCV_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``OpenCV_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``OpenCV_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``OpenCV``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the OpenCV header files using the above hint variables (excluding ``OpenCV_LIBRARYDIR``) and
saves the result in ``OpenCV_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``OpenCV_INCLUDEDIR``), "lib" directories near ``OpenCV_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``OpenCV_LIBRARY_DIR_DEBUG`` and ``OpenCV_LIBRARY_DIR_RELEASE`` and
individual library locations in ``OpenCV_<COMPONENT>_LIBRARY_DEBUG`` and ``OpenCV_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``OpenCV::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(OpenCV)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

OpenCV libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``OpenCV_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``OpenCV_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
OpenCV_FIND_RELEASE_ONLY is ``ON``).

``OpenCV_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``OpenCV_DEBUG``
Set to ``ON`` to enable debug output from ``FindOpenCV``. Please enable this before filing any bug report.

``OpenCV_LIBRARY_DIR``
Default value for ``OpenCV_LIBRARY_DIR_RELEASE`` and ``OpenCV_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find OpenCV headers only:

.. code-block:: cmake

find_package(OpenCV 2.0.0)
if(OpenCV_FOUND)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC OpenCV::OpenCV)
endif()

Find OpenCV libraries and use imported targets:

.. code-block:: cmake

find_package(OpenCV 2.0.0 REQUIRED COMPONENTS OpenCV)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC OpenCV::OpenCV)

Find OpenCV headers and some *static* (release only) libraries:

.. code-block:: cmake

set(OpenCV_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(OpenCV_USE_RELEASE_LIBS ON) # only find release libs
find_package(OpenCV 2.0.0 COMPONENTS OpenCV)
if(OpenCV_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC OpenCV::OpenCV)
endif()

.. _`OpenCV CMake`:

OpenCV CMake
^^^^^^^^^^^

If OpenCV was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``OpenCVConfig.cmake`` and stores the result in ``CACHE``
entry ``OpenCV_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the OpenCV CMake package configuration for details on what it provides.

Set ``OpenCV_NO_CMAKE`` to ``ON``, to disable the search for the package using the CONFIG method.

.. _`OpenCV pkg-config`:

OpenCV CMake
^^^^^^^^^^^

If OpenCV was installed with its pkg-config files, this module may attempt to look for OpenCV by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``OpenCV_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg OpenCV)
set(${_pkg}_INCLUDE_FILE version.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include/opencv2/core opencv2/core)
set(${_pkg}_DEFINE_PREFIX CV)
set(${_pkg}_INCLUDE_DIR_UP_INDEX 2)
set(${_pkg}_DEFAULT_COMPONENTS core)

if(WIN32)
# Extensions:
#
# * .ddl.a: shared libraries, MinGW flavor
# * .lib: shared libraries, MSVC flavor (static are *-static.a)
if(MSVC)
set(${_pkg}_FIND_LIBRARY_SUFFIXES .lib .a)
else()
set(${_pkg}_FIND_LIBRARY_SUFFIXES .dll .ddl.a .lib .a)
endif()
endif()

if(NOT OpenCV_FIND_VERSION_MAJOR)
set(OpenCV_FIND_VERSION_MAJOR 4)
endif()
if(NOT OpenCV_FIND_VERSION_MINOR)
set(OpenCV_FIND_VERSION_MINOR 5)
endif()
include(${CMAKE_CURRENT_LIST_DIR}/opencv/${OpenCV_FIND_VERSION_MAJOR}.${OpenCV_FIND_VERSION_MINOR}.cmake)

# Update OPENCV library search directories with pre-built paths
function(OpenCV_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/lib)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

function(OpenCV_post_process pkg)
foreach(_comp ${OpenCV_FIND_COMPONENTS})
if(NOT TARGET ${pkg}::${_comp} AND TARGET opencv_${_comp})
add_library(${pkg}::${_comp} ALIAS opencv_${_comp})
endif()
endforeach()
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 639
- 0
cmake/modules/FindOpenSSL.cmake View File

@@ -0,0 +1,639 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

#[=======================================================================[.rst:
FindOpenSSL
-----------

Find the OpenSSL encryption library.

This module finds an installed OpenSSL library and determines its version.

.. versionadded:: 3.19
When a version is requested, it can be specified as a simple value or as a
range. For a detailed description of version range usage and capabilities,
refer to the :command:`find_package` command.

.. versionadded:: 3.18
Support for OpenSSL 3.0.

Optional COMPONENTS
^^^^^^^^^^^^^^^^^^^

.. versionadded:: 3.12

This module supports two optional COMPONENTS: ``Crypto`` and ``SSL``. Both
components have associated imported targets, as described below.

Imported Targets
^^^^^^^^^^^^^^^^

.. versionadded:: 3.4

This module defines the following :prop_tgt:`IMPORTED` targets:

``OpenSSL::SSL``
The OpenSSL ``ssl`` library, if found.
``OpenSSL::Crypto``
The OpenSSL ``crypto`` library, if found.
``OpenSSL::applink``
.. versionadded:: 3.18

The OpenSSL ``applink`` components that might be need to be compiled into
projects under MSVC. This target is available only if found OpenSSL version
is not less than 0.9.8. By linking this target the above OpenSSL targets can
be linked even if the project has different MSVC runtime configurations with
the above OpenSSL targets. This target has no effect on platforms other than
MSVC.

NOTE: Due to how ``INTERFACE_SOURCES`` are consumed by the consuming target,
unless you certainly know what you are doing, it is always preferred to link
``OpenSSL::applink`` target as ``PRIVATE`` and to make sure that this target is
linked at most once for the whole dependency graph of any library or
executable:

.. code-block:: cmake

target_link_libraries(myTarget PRIVATE OpenSSL::applink)

Otherwise you would probably encounter unexpected random problems when building
and linking, as both the ISO C and the ISO C++ standard claims almost nothing
about what a link process should be.

Result Variables
^^^^^^^^^^^^^^^^

This module will set the following variables in your project:

``OPENSSL_FOUND``
System has the OpenSSL library. If no components are requested it only
requires the crypto library.
``OPENSSL_INCLUDE_DIR``
The OpenSSL include directory.
``OPENSSL_CRYPTO_LIBRARY``
The OpenSSL crypto library.
``OPENSSL_CRYPTO_LIBRARIES``
The OpenSSL crypto library and its dependencies.
``OPENSSL_SSL_LIBRARY``
The OpenSSL SSL library.
``OPENSSL_SSL_LIBRARIES``
The OpenSSL SSL library and its dependencies.
``OPENSSL_LIBRARIES``
All OpenSSL libraries and their dependencies.
``OPENSSL_VERSION``
This is set to ``$major.$minor.$revision$patch`` (e.g. ``0.9.8s``).
``OPENSSL_APPLINK_SOURCE``
The sources in the target ``OpenSSL::applink`` that is mentioned above. This
variable shall always be undefined if found openssl version is less than
0.9.8 or if platform is not MSVC.

Hints
^^^^^

Set ``OPENSSL_ROOT_DIR`` to the root directory of an OpenSSL installation.

.. versionadded:: 3.4
Set ``OPENSSL_USE_STATIC_LIBS`` to ``TRUE`` to look for static libraries.

.. versionadded:: 3.5
Set ``OPENSSL_MSVC_STATIC_RT`` set ``TRUE`` to choose the MT version of the lib.
#]=======================================================================]

macro(_OpenSSL_test_and_find_dependencies ssl_library crypto_library)
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (("${ssl_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
OR ("${crypto_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")))
set(_OpenSSL_has_dependencies TRUE)
find_package(Threads)
else()
set(_OpenSSL_has_dependencies FALSE)
endif()
endmacro()

function(_OpenSSL_add_dependencies libraries_var)
if(CMAKE_THREAD_LIBS_INIT)
list(APPEND ${libraries_var} ${CMAKE_THREAD_LIBS_INIT})
endif()
list(APPEND ${libraries_var} ${CMAKE_DL_LIBS})
set(${libraries_var}
${${libraries_var}}
PARENT_SCOPE)
endfunction()

function(_OpenSSL_target_add_dependencies target)
if(_OpenSSL_has_dependencies)
set_property(
TARGET ${target}
APPEND
PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads)
set_property(
TARGET ${target}
APPEND
PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS})
endif()
if(WIN32 AND OPENSSL_USE_STATIC_LIBS)
set_property(
TARGET ${target}
APPEND
PROPERTY INTERFACE_LINK_LIBRARIES ws2_32)
set_property(
TARGET ${target}
APPEND
PROPERTY INTERFACE_LINK_LIBRARIES crypt32)
endif()
endfunction()

if(UNIX)
find_package(PkgConfig QUIET)
pkg_check_modules(_OPENSSL QUIET openssl)
endif()

# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
if(OPENSSL_USE_STATIC_LIBS)
set(_openssl_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif()
endif()

if(WIN32)
# http://www.slproweb.com/products/Win32OpenSSL.html
set(_OPENSSL_ROOT_HINTS
${OPENSSL_ROOT_DIR}
${OPENSSL_ROOT}
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
ENV
OPENSSL_ROOT_DIR
OPENSSL_ROOT)

if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
set(_arch "Win64")
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
else()
set(_arch "Win32")
set(_progfiles_x86 "ProgramFiles(x86)")
if(NOT "$ENV{${_progfiles_x86}}" STREQUAL "")
# under windows 64 bit machine
file(TO_CMAKE_PATH "$ENV{${_progfiles_x86}}" _programfiles)
else()
# under windows 32 bit machine
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" _programfiles)
endif()
endif()

set(_OPENSSL_ROOT_PATHS "${_programfiles}/OpenSSL" "${_programfiles}/OpenSSL-${_arch}" "C:/OpenSSL/"
"C:/OpenSSL-${_arch}/")
unset(_programfiles)
unset(_arch)
else()
set(_OPENSSL_ROOT_HINTS ${OPENSSL_ROOT_DIR} ${OPENSSL_ROOT} ENV OPENSSL_ROOT_DIR OPENSSL_ROOT)
endif()

set(_OPENSSL_ROOT_HINTS_AND_PATHS HINTS ${_OPENSSL_ROOT_HINTS} PATHS ${_OPENSSL_ROOT_PATHS})

find_path(
OPENSSL_INCLUDE_DIR
NAMES openssl/ssl.h ${_OPENSSL_ROOT_HINTS_AND_PATHS}
HINTS ${_OPENSSL_INCLUDEDIR} ${_OPENSSL_INCLUDE_DIRS}
PATH_SUFFIXES include)

if(WIN32 AND NOT CYGWIN)
if(MSVC)
# /MD and /MDd are the standard values - if someone wants to use others, the libnames have to change here too use
# also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b enable OPENSSL_MSVC_STATIC_RT to get the libs
# build /MT (Multithreaded no-DLL) In Visual C++ naming convention each of these four kinds of Windows libraries has
# it's standard suffix: * MD for dynamic-release * MDd for dynamic-debug * MT for static-release * MTd for
# static-debug

# Implementation details: We are using the libraries located in the VC subdir instead of the parent directory even
# though : libeay32MD.lib is identical to ../libeay32.lib, and ssleay32MD.lib is identical to ../ssleay32.lib enable
# OPENSSL_USE_STATIC_LIBS to use the static libs located in lib/VC/static

if(OPENSSL_MSVC_STATIC_RT)
set(_OPENSSL_MSVC_RT_MODE "MT")
else()
set(_OPENSSL_MSVC_RT_MODE "MD")
endif()

# Since OpenSSL 1.1, lib names are like libcrypto32MTd.lib and libssl32MTd.lib
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
set(_OPENSSL_MSVC_ARCH_SUFFIX "64")
else()
set(_OPENSSL_MSVC_ARCH_SUFFIX "32")
endif()

if(OPENSSL_USE_STATIC_LIBS)
set(_OPENSSL_STATIC_SUFFIX "_static")
set(_OPENSSL_PATH_SUFFIXES "lib/VC/static" "VC/static" "lib")
else()
set(_OPENSSL_STATIC_SUFFIX "")
set(_OPENSSL_PATH_SUFFIXES "lib/VC" "VC" "lib")
endif()

find_library(
LIB_EAY_DEBUG
NAMES # When OpenSSL is built with default options, the static library name is suffixed with "_static". Looking
# the "libcrypto_static.lib" with a higher priority than "libcrypto.lib" which is the import library of
# "libcrypto.dll".
libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
libcrypto${_OPENSSL_STATIC_SUFFIX}d
libeay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
libeay32${_OPENSSL_STATIC_SUFFIX}d
crypto${_OPENSSL_STATIC_SUFFIX}d
# When OpenSSL is built with the "-static" option, only the static build is produced, and it is not suffixed
# with "_static".
libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
libcrypto${_OPENSSL_MSVC_RT_MODE}d
libcryptod
libeay32${_OPENSSL_MSVC_RT_MODE}d
libeay32d
cryptod
NAMES_PER_DIR
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES ${_OPENSSL_PATH_SUFFIXES})

find_library(
LIB_EAY_RELEASE
NAMES # When OpenSSL is built with default options, the static library name is suffixed with "_static". Looking
# the "libcrypto_static.lib" with a higher priority than "libcrypto.lib" which is the import library of
# "libcrypto.dll".
libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
libcrypto${_OPENSSL_STATIC_SUFFIX}
libeay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
libeay32${_OPENSSL_STATIC_SUFFIX}
crypto${_OPENSSL_STATIC_SUFFIX}
# When OpenSSL is built with the "-static" option, only the static build is produced, and it is not suffixed
# with "_static".
libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
libcrypto${_OPENSSL_MSVC_RT_MODE}
libcrypto
libeay32${_OPENSSL_MSVC_RT_MODE}
libeay32
crypto
NAMES_PER_DIR
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES ${_OPENSSL_PATH_SUFFIXES})

find_library(
SSL_EAY_DEBUG
NAMES # When OpenSSL is built with default options, the static library name is suffixed with "_static". Looking
# the "libssl_static.lib" with a higher priority than "libssl.lib" which is the import library of
# "libssl.dll".
libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
libssl${_OPENSSL_STATIC_SUFFIX}d
ssleay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
ssleay32${_OPENSSL_STATIC_SUFFIX}d
ssl${_OPENSSL_STATIC_SUFFIX}d
# When OpenSSL is built with the "-static" option, only the static build is produced, and it is not suffixed
# with "_static".
libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
libssl${_OPENSSL_MSVC_RT_MODE}d
libssld
ssleay32${_OPENSSL_MSVC_RT_MODE}d
ssleay32d
ssld
NAMES_PER_DIR
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES ${_OPENSSL_PATH_SUFFIXES})

find_library(
SSL_EAY_RELEASE
NAMES # When OpenSSL is built with default options, the static library name is suffixed with "_static". Looking
# the "libssl_static.lib" with a higher priority than "libssl.lib" which is the import library of
# "libssl.dll".
libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
libssl${_OPENSSL_STATIC_SUFFIX}
ssleay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
ssleay32${_OPENSSL_STATIC_SUFFIX}
ssl${_OPENSSL_STATIC_SUFFIX}
# When OpenSSL is built with the "-static" option, only the static build is produced, and it is not suffixed
# with "_static".
libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
libssl${_OPENSSL_MSVC_RT_MODE}
libssl
ssleay32${_OPENSSL_MSVC_RT_MODE}
ssleay32
ssl
NAMES_PER_DIR
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES ${_OPENSSL_PATH_SUFFIXES})

set(LIB_EAY_LIBRARY_DEBUG "${LIB_EAY_DEBUG}")
set(LIB_EAY_LIBRARY_RELEASE "${LIB_EAY_RELEASE}")
set(SSL_EAY_LIBRARY_DEBUG "${SSL_EAY_DEBUG}")
set(SSL_EAY_LIBRARY_RELEASE "${SSL_EAY_RELEASE}")

include(SelectLibraryConfigurations.cmake)
select_library_configurations(LIB_EAY)
select_library_configurations(SSL_EAY)

mark_as_advanced(LIB_EAY_LIBRARY_DEBUG LIB_EAY_LIBRARY_RELEASE SSL_EAY_LIBRARY_DEBUG SSL_EAY_LIBRARY_RELEASE)
set(OPENSSL_SSL_LIBRARY ${SSL_EAY_LIBRARY})
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY_LIBRARY})
elseif(MINGW)
# same player, for MinGW
set(LIB_EAY_NAMES crypto libeay32)
set(SSL_EAY_NAMES ssl ssleay32)
find_library(
LIB_EAY
NAMES ${LIB_EAY_NAMES} NAMES_PER_DIR ${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES "lib/MinGW" "lib")

find_library(
SSL_EAY
NAMES ${SSL_EAY_NAMES} NAMES_PER_DIR ${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES "lib/MinGW" "lib")

mark_as_advanced(SSL_EAY LIB_EAY)
set(OPENSSL_SSL_LIBRARY ${SSL_EAY})
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY})
unset(LIB_EAY_NAMES)
unset(SSL_EAY_NAMES)
else()
# Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
find_library(
LIB_EAY
NAMES libcrypto libeay32 NAMES_PER_DIR ${_OPENSSL_ROOT_HINTS_AND_PATHS}
HINTS ${_OPENSSL_LIBDIR}
PATH_SUFFIXES lib)

find_library(
SSL_EAY
NAMES libssl ssleay32 NAMES_PER_DIR ${_OPENSSL_ROOT_HINTS_AND_PATHS}
HINTS ${_OPENSSL_LIBDIR}
PATH_SUFFIXES lib)

mark_as_advanced(SSL_EAY LIB_EAY)
set(OPENSSL_SSL_LIBRARY ${SSL_EAY})
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY})
endif()
else()

find_library(
OPENSSL_SSL_LIBRARY
NAMES ssl ssleay32 ssleay32MD NAMES_PER_DIR ${_OPENSSL_ROOT_HINTS_AND_PATHS}
HINTS ${_OPENSSL_LIBDIR} ${_OPENSSL_LIBRARY_DIRS}
PATH_SUFFIXES lib)

find_library(
OPENSSL_CRYPTO_LIBRARY
NAMES crypto NAMES_PER_DIR ${_OPENSSL_ROOT_HINTS_AND_PATHS}
HINTS ${_OPENSSL_LIBDIR} ${_OPENSSL_LIBRARY_DIRS}
PATH_SUFFIXES lib)

mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY)

endif()

set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY})
set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES})
_openssl_test_and_find_dependencies("${OPENSSL_SSL_LIBRARY}" "${OPENSSL_CRYPTO_LIBRARY}")
if(_OpenSSL_has_dependencies)
_openssl_add_dependencies(OPENSSL_SSL_LIBRARIES)
_openssl_add_dependencies(OPENSSL_CRYPTO_LIBRARIES)
_openssl_add_dependencies(OPENSSL_LIBRARIES)
endif()

function(from_hex HEX DEC)
string(TOUPPER "${HEX}" HEX)
set(_res 0)
string(LENGTH "${HEX}" _strlen)

while(_strlen GREATER 0)
math(EXPR _res "${_res} * 16")
string(SUBSTRING "${HEX}" 0 1 NIBBLE)
string(SUBSTRING "${HEX}" 1 -1 HEX)
if(NIBBLE STREQUAL "A")
math(EXPR _res "${_res} + 10")
elseif(NIBBLE STREQUAL "B")
math(EXPR _res "${_res} + 11")
elseif(NIBBLE STREQUAL "C")
math(EXPR _res "${_res} + 12")
elseif(NIBBLE STREQUAL "D")
math(EXPR _res "${_res} + 13")
elseif(NIBBLE STREQUAL "E")
math(EXPR _res "${_res} + 14")
elseif(NIBBLE STREQUAL "F")
math(EXPR _res "${_res} + 15")
else()
math(EXPR _res "${_res} + ${NIBBLE}")
endif()

string(LENGTH "${HEX}" _strlen)
endwhile()

set(${DEC}
${_res}
PARENT_SCOPE)
endfunction()

if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*")

if(openssl_version_str)
# The version number is encoded as 0xMNNFFPPS: major minor fix patch status The status gives if this is a developer
# or prerelease and is ignored here. Major, minor, and fix directly translate into the version numbers shown in the
# string. The patch field translates to the single character suffix that indicates the bug fix state, which 00 ->
# nothing, 01 -> a, 02 -> b and so on.

string(
REGEX
REPLACE
"^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F]).*$"
"\\1;\\2;\\3;\\4;\\5"
OPENSSL_VERSION_LIST
"${openssl_version_str}")
list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
from_hex("${OPENSSL_VERSION_MINOR}" OPENSSL_VERSION_MINOR)
list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_FIX)
from_hex("${OPENSSL_VERSION_FIX}" OPENSSL_VERSION_FIX)
list(GET OPENSSL_VERSION_LIST 3 OPENSSL_VERSION_PATCH)

if(NOT OPENSSL_VERSION_PATCH STREQUAL "00")
from_hex("${OPENSSL_VERSION_PATCH}" _tmp)
# 96 is the ASCII code of 'a' minus 1
math(EXPR OPENSSL_VERSION_PATCH_ASCII "${_tmp} + 96")
unset(_tmp)
# Once anyone knows how OpenSSL would call the patch versions beyond 'z' this should be updated to handle that,
# too. This has not happened yet so it is simply ignored here for now.
string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING)
endif()

set(OPENSSL_VERSION
"${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}")

# DNguyen: version for CMake comparison is major.minor.fix.patch with 'patch' in decimal e.g. 'l' == 0c == 12 e.g.
# 'm' == 0d == 13
from_hex(${OPENSSL_VERSION_PATCH} _patch)
set(OPENSSL_VERSION_4_COMPONENTS
"${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}.${_patch}")
set(_openssl_version_var OPENSSL_VERSION_4_COMPONENTS)

if(NOT OpenSSL_FIND_QUIETLY)
message(STATUS "OpenSSL version: ${OPENSSL_VERSION}, \
patch component: '${OPENSSL_VERSION_PATCH_STRING}' (${OPENSSL_VERSION_PATCH} -> ${_patch})")
message(STATUS "OpenSSL version in major.minor.fix.patch format: ${OPENSSL_VERSION_4_COMPONENTS}")
endif()

else()
# Since OpenSSL 3.0.0, the new version format is MAJOR.MINOR.PATCH and a new OPENSSL_VERSION_STR macro contains
# exactly that
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" OPENSSL_VERSION_STR
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_STR[\t ]+\"([0-9])+\\.([0-9])+\\.([0-9])+\".*")
string(REGEX REPLACE "^.*OPENSSL_VERSION_STR[\t ]+\"([0-9]+\\.[0-9]+\\.[0-9]+)\".*$" "\\1" OPENSSL_VERSION_STR
"${OPENSSL_VERSION_STR}")

set(OPENSSL_VERSION "${OPENSSL_VERSION_STR}")
set(_openssl_version_var OPENSSL_VERSION)

unset(OPENSSL_VERSION_STR)
endif()
endif()

foreach(_comp IN LISTS OpenSSL_FIND_COMPONENTS)
if(_comp STREQUAL "Crypto")
if(EXISTS "${OPENSSL_INCLUDE_DIR}"
AND (EXISTS "${OPENSSL_CRYPTO_LIBRARY}"
OR EXISTS "${LIB_EAY_LIBRARY_DEBUG}"
OR EXISTS "${LIB_EAY_LIBRARY_RELEASE}"))
set(OpenSSL_${_comp}_FOUND TRUE)
else()
set(OpenSSL_${_comp}_FOUND FALSE)
endif()
elseif(_comp STREQUAL "SSL")
if(EXISTS "${OPENSSL_INCLUDE_DIR}"
AND (EXISTS "${OPENSSL_SSL_LIBRARY}"
OR EXISTS "${SSL_EAY_LIBRARY_DEBUG}"
OR EXISTS "${SSL_EAY_LIBRARY_RELEASE}"))
set(OpenSSL_${_comp}_FOUND TRUE)
else()
set(OpenSSL_${_comp}_FOUND FALSE)
endif()
else()
message(WARNING "${_comp} is not a valid OpenSSL component")
set(OpenSSL_${_comp}_FOUND FALSE)
endif()
endforeach()
unset(_comp)

include(FindPackageHandleStandardArgs)

if("${_openssl_version_var}" STREQUAL "OPENSSL_VERSION_4_COMPONENTS")
set(_fail_msg
"Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR \
or OPENSSL_ROOT.
Found version ${OPENSSL_VERSION} (${OPENSSL_VERSION_4_COMPONENTS})
")
else()
set(_fail_msg
"Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR \
or OPENSSL_ROOT")
endif()

find_package_handle_standard_args(
OpenSSL
REQUIRED_VARS OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR
VERSION_VAR ${_openssl_version_var} HANDLE_VERSION_RANGE
HANDLE_COMPONENTS
FAIL_MESSAGE "${_fail_msg}")

mark_as_advanced(OPENSSL_INCLUDE_DIR)

if(OPENSSL_FOUND)
if(NOT TARGET OpenSSL::Crypto
AND (EXISTS "${OPENSSL_CRYPTO_LIBRARY}"
OR EXISTS "${LIB_EAY_LIBRARY_DEBUG}"
OR EXISTS "${LIB_EAY_LIBRARY_RELEASE}"))
add_library(OpenSSL::Crypto UNKNOWN IMPORTED)
set_target_properties(OpenSSL::Crypto PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}")
if(EXISTS "${OPENSSL_CRYPTO_LIBRARY}")
set_target_properties(OpenSSL::Crypto PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${OPENSSL_CRYPTO_LIBRARY}")
endif()
if(EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
set_property(
TARGET OpenSSL::Crypto
APPEND
PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(OpenSSL::Crypto PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
IMPORTED_LOCATION_RELEASE "${LIB_EAY_LIBRARY_RELEASE}")
endif()
if(EXISTS "${LIB_EAY_LIBRARY_DEBUG}")
set_property(
TARGET OpenSSL::Crypto
APPEND
PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(OpenSSL::Crypto PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${LIB_EAY_LIBRARY_DEBUG}")
endif()
_openssl_target_add_dependencies(OpenSSL::Crypto)
endif()

if(NOT TARGET OpenSSL::SSL
AND (EXISTS "${OPENSSL_SSL_LIBRARY}"
OR EXISTS "${SSL_EAY_LIBRARY_DEBUG}"
OR EXISTS "${SSL_EAY_LIBRARY_RELEASE}"))
add_library(OpenSSL::SSL UNKNOWN IMPORTED)
set_target_properties(OpenSSL::SSL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}")
if(EXISTS "${OPENSSL_SSL_LIBRARY}")
set_target_properties(OpenSSL::SSL PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION
"${OPENSSL_SSL_LIBRARY}")
endif()
if(EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
set_property(
TARGET OpenSSL::SSL
APPEND
PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(OpenSSL::SSL PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
IMPORTED_LOCATION_RELEASE "${SSL_EAY_LIBRARY_RELEASE}")
endif()
if(EXISTS "${SSL_EAY_LIBRARY_DEBUG}")
set_property(
TARGET OpenSSL::SSL
APPEND
PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(OpenSSL::SSL PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${SSL_EAY_LIBRARY_DEBUG}")
endif()
if(TARGET OpenSSL::Crypto)
set_target_properties(OpenSSL::SSL PROPERTIES INTERFACE_LINK_LIBRARIES OpenSSL::Crypto)
endif()
_openssl_target_add_dependencies(OpenSSL::SSL)
endif()

if("${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_FIX}" VERSION_GREATER_EQUAL "0.9.8")
if(MSVC)
if(EXISTS "${OPENSSL_INCLUDE_DIR}")
set(_OPENSSL_applink_paths PATHS ${OPENSSL_INCLUDE_DIR})
endif()
find_file(
OPENSSL_APPLINK_SOURCE
NAMES openssl/applink.c ${_OPENSSL_applink_paths}
NO_DEFAULT_PATH)
if(OPENSSL_APPLINK_SOURCE)
set(_OPENSSL_applink_interface_srcs ${OPENSSL_APPLINK_SOURCE})
endif()
endif()
if(NOT TARGET OpenSSL::applink)
add_library(OpenSSL::applink INTERFACE IMPORTED)
set_property(
TARGET OpenSSL::applink
APPEND
PROPERTY INTERFACE_SOURCES ${_OPENSSL_applink_interface_srcs})
endif()
endif()
endif()

# Restore the original find library ordering
if(OPENSSL_USE_STATIC_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_openssl_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
endif()

+ 285
- 0
cmake/modules/FindTIFF.cmake View File

@@ -0,0 +1,285 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
FindTIFF
---------

Find TIFF include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(TIFF
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if TIFF is not found
[COMPONENTS <libs>...] # TIFF libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "TIFF
CMake" build. For the latter case skip to the :ref:`TIFF CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``TIFF_FOUND``
True if headers and requested libraries were found.

``TIFF_INCLUDE_DIRS``
TIFF include directories.

``TIFF_LIBRARY_DIRS``
Link directories for TIFF libraries.

``TIFF_LIBRARIES``
TIFF component libraries to be linked.

``TIFF_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``TIFF_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``TIFF_VERSION``
TIFF version number in ``X.Y`` format.

``TIFF_VERSION_MAJOR``
TIFF major version number (``X`` in ``X.Y``).

``TIFF_VERSION_MINOR``
TIFF minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``TIFF_INCLUDE_DIR``
Directory containing TIFF headers.

``TIFF_LIBRARY_DIR_RELEASE``
Directory containing release TIFF libraries.

``TIFF_LIBRARY_DIR_DEBUG``
Directory containing debug TIFF libraries.

``TIFF_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``TIFF_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``TIFF_ROOT``, ``TIFFROOT``
Preferred installation prefix.

``TIFF_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``TIFF_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``TIFF_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``TIFF``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the TIFF header files using the above hint variables (excluding ``TIFF_LIBRARYDIR``) and
saves the result in ``TIFF_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``TIFF_INCLUDEDIR``), "lib" directories near ``TIFF_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``TIFF_LIBRARY_DIR_DEBUG`` and ``TIFF_LIBRARY_DIR_RELEASE`` and
individual library locations in ``TIFF_<COMPONENT>_LIBRARY_DEBUG`` and ``TIFF_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``TIFF::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(TIFF)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

TIFF libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``TIFF_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``TIFF_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
TIFF_FIND_RELEASE_ONLY is ``ON``).

``TIFF_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``TIFF_DEBUG``
Set to ``ON`` to enable debug output from ``FindTIFF``. Please enable this before filing any bug report.

``TIFF_LIBRARY_DIR``
Default value for ``TIFF_LIBRARY_DIR_RELEASE`` and ``TIFF_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find TIFF headers only:

.. code-block:: cmake

find_package(TIFF 2.0.0)
if(TIFF_FOUND)
include_directories(${TIFF_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC TIFF::TIFF)
endif()

Find TIFF libraries and use imported targets:

.. code-block:: cmake

find_package(TIFF 2.0.0 REQUIRED COMPONENTS TIFF)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC TIFF::TIFF)

Find TIFF headers and some *static* (release only) libraries:

.. code-block:: cmake

set(TIFF_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(TIFF_USE_RELEASE_LIBS ON) # only find release libs
find_package(TIFF 2.0.0 COMPONENTS TIFF)
if(TIFF_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC TIFF::TIFF)
endif()

.. _`TIFF CMake`:

TIFF CMake
^^^^^^^^^^^

If TIFF was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``TIFFConfig.cmake`` and stores the result in ``CACHE``
entry ``TIFF_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the TIFF CMake package configuration for details on what it provides.

Set ``TIFF_NO_CMAKE`` to ``ON``, to disable the search for the package using the CONFIG method.

.. _`TIFF pkg-config`:

TIFF CMake
^^^^^^^^^^^

If TIFF was installed with its pkg-config files, this module may attempt to look for TIFF by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``TIFF_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg TIFF)
set(${_pkg}_INCLUDE_FILE tiff.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/${_pkg} ${_pkg})
set(${_pkg}_DEFAULT_COMPONENTS TIFF)
set(${_pkg}_TIFF_NAMES tiff libtiff tiff3 libtiff3)
if(MSVC)
# C++ bindings are built into the main tiff library.
set(${_pkg}_CXX_NAMES ${${_pkg}_TIFF_NAMES})
else()
set(${_pkg}_CXX_NAMES tiffxx libtiffxx tiff3xx libtiff3xx)
endif()

function(TIFF_version_function include_dir)
message(STATUS "${include_dir}")
find_file(
_tiffvers_h tiffvers.h
PATHS ${include_dir}
NO_DEFAULT_PATH)

if(_tiffvers_h)
file(STRINGS "${_tiffvers_h}" tiff_version_str REGEX "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version .*")
string(REGEX REPLACE "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version +([^ \\n]*).*" "\\1"
${_pkg}_VERSION "${tiff_version_str}")
endif()

if(${_pkg}_VERSION MATCHES "([0-9]+)\.([0-9]+)\.([0-9]+)")
set(${_pkg}_VERSION_MAJOR ${CMAKE_MATCH_1})
set(${_pkg}_VERSION_MINOR ${CMAKE_MATCH_2})
set(${_pkg}_VERSION_PATCH ${CMAKE_MATCH_3})
else()
message(WARNING "Unable to determine TIFF's version since tiffvers.h file cannot be found!")
set(${_pkg}_VERSION_MAJOR 99999999)
set(${_pkg}_VERSION_MINOR 99)
set(${_pkg}_VERSION_PATCH 0)
endif()

set(${_pkg}_VERSION_MAJOR
${${_pkg}_VERSION_MAJOR}
PARENT_SCOPE)
set(${_pkg}_VERSION_MINOR
${${_pkg}_VERSION_MINOR}
PARENT_SCOPE)
set(${_pkg}_VERSION_PATCH
${${_pkg}_VERSION_PATCH}
PARENT_SCOPE)
set(${_pkg}_VERSION
${${_pkg}_VERSION}
PARENT_SCOPE)
endfunction()

function(TIFF_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/lib)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 1497
- 0
cmake/modules/FindTemplate.cmake
File diff suppressed because it is too large
View File


+ 334
- 0
cmake/modules/FindTurboJPEG.cmake View File

@@ -0,0 +1,334 @@
#.rst:
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
FindTurboJPEG
---------

Find TurboJPEG include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(TurboJPEG
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if TurboJPEG is not found
[COMPONENTS <libs>...] # TurboJPEG libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "TurboJPEG
CMake" build. For the latter case skip to the :ref:`TurboJPEG CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``TurboJPEG_FOUND``
True if headers and requested libraries were found.

``TurboJPEG_INCLUDE_DIRS``
TurboJPEG include directories.

``TurboJPEG_LIBRARY_DIRS``
Link directories for TurboJPEG libraries.

``TurboJPEG_LIBRARIES``
TurboJPEG component libraries to be linked.

``TurboJPEG_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``TurboJPEG_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``TurboJPEG_VERSION``
TurboJPEG version number in ``X.Y`` format.

``TurboJPEG_VERSION_MAJOR``
TurboJPEG major version number (``X`` in ``X.Y``).

``TurboJPEG_VERSION_MINOR``
TurboJPEG minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``TurboJPEG_INCLUDE_DIR``
Directory containing TurboJPEG headers.

``TurboJPEG_LIBRARY_DIR_RELEASE``
Directory containing release TurboJPEG libraries.

``TurboJPEG_LIBRARY_DIR_DEBUG``
Directory containing debug TurboJPEG libraries.

``TurboJPEG_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``TurboJPEG_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``TurboJPEG_ROOT``, ``TurboJPEGROOT``
Preferred installation prefix.

``TurboJPEG_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``TurboJPEG_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``TurboJPEG_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``TurboJPEG``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the TurboJPEG header files using the above hint variables (excluding ``TurboJPEG_LIBRARYDIR``) and
saves the result in ``TurboJPEG_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``TurboJPEG_INCLUDEDIR``), "lib" directories near ``TurboJPEG_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``TurboJPEG_LIBRARY_DIR_DEBUG`` and ``TurboJPEG_LIBRARY_DIR_RELEASE`` and
individual library locations in ``TurboJPEG_<COMPONENT>_LIBRARY_DEBUG`` and ``TurboJPEG_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``TurboJPEG::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(TurboJPEG)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

TurboJPEG libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``TurboJPEG_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``TurboJPEG_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
TurboJPEG_FIND_RELEASE_ONLY is ``ON``).

``TurboJPEG_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``TurboJPEG_DEBUG``
Set to ``ON`` to enable debug output from ``FindTurboJPEG``. Please enable this before filing any bug report.

``TurboJPEG_LIBRARY_DIR``
Default value for ``TurboJPEG_LIBRARY_DIR_RELEASE`` and ``TurboJPEG_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find TurboJPEG headers only:

.. code-block:: cmake

find_package(TurboJPEG 2.0.0)
if(TurboJPEG_FOUND)
include_directories(${TurboJPEG_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC TurboJPEG::TurboJPEG)
endif()

Find TurboJPEG libraries and use imported targets:

.. code-block:: cmake

find_package(TurboJPEG 2.0.0 REQUIRED COMPONENTS TurboJPEG)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC TurboJPEG::TurboJPEG)

Find TurboJPEG headers and some *static* (release only) libraries:

.. code-block:: cmake

set(TurboJPEG_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(TurboJPEG_USE_RELEASE_LIBS ON) # only find release libs
find_package(TurboJPEG 2.0.0 COMPONENTS TurboJPEG)
if(TurboJPEG_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC TurboJPEG::TurboJPEG)
endif()

.. _`TurboJPEG CMake`:

TurboJPEG CMake
^^^^^^^^^^^^^^^

If TurboJPEG was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``TurboJPEGConfig.cmake`` and stores the result in ``CACHE``
entry ``TurboJPEG_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the TurboJPEG CMake package configuration for details on what it provides.

Set ``TurboJPEG_NO_CMAKE`` to ``ON``, to disable the search for $the package using the CONFIG method.

.. _`TurboJPEG pkg-config`:

TurboJPEG PkgConfig
^^^^^^^^^^^^^^^^^^^

If TurboJPEG was installed with its pkg-config files, this module may attempt to look for TurboJPEG by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``TurboJPEG_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

.. _`TurboJpeg pkg-config`:

TurboJpeg CMake
^^^^^^^^^^^

If TurboJpeg was installed with its pkg-config files, this module may attempt to look for TurboJpeg by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``TurboJpeg_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg TurboJPEG)
set(${_pkg}_INCLUDE_FILE turbojpeg.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/${_pkg} ${_pkg})
set(${_pkg}_DEFAULT_COMPONENTS JPEG TurboJPEG)
set(${_pkg}_TurboJPEG_NAMES turbojpeg) # names for the library
set(${_pkg}_JPEG_NAMES jpeg) # names for the library

if(WIN32)
# Extensions:
#
# * .ddl.a: shared libraries, MinGW flavor
# * .lib: shared libraries, MSVC flavor (static are *-static.a)
set(${_pkg}_FIND_LIBRARY_SUFFIXES .dll .ddl.a .lib .a)

set(win32_paths)
if(MSVC)
list(APPEND ${_pkg}_TurboJPEG_NAMES turbojpeg-static)
list(APPEND ${_pkg}_JPEG_NAMES jpeg-static)

list(APPEND win32_paths "$ENV{LOCALAPPDATA}/libjpeg-turbo64")
list(APPEND win32_paths "$ENV{LOCALAPPDATA}/libjpeg-turbo")
list(APPEND win32_paths "$ENV{ALLUSERSPROFILE}/libjpeg-turbo64")
list(APPEND win32_paths "$ENV{ALLUSERSPROFILE}/libjpeg-turbo")
list(APPEND win32_paths "C:/libjpeg-turbo64")
list(APPEND win32_paths "C:/libjpeg-turbo")
elseif(MINGW)
list(APPEND ${_pkg}_TurboJPEG_NAMES libturbojpeg)
list(APPEND ${_pkg}_JPEG_NAMES libjpeg)

list(APPEND win32_paths "$ENV{LOCALAPPDATA}/libjpeg-turbo-gcc64")
list(APPEND win32_paths "$ENV{LOCALAPPDATA}/libjpeg-turbo-gcc")
list(APPEND win32_paths "$ENV{ALLUSERSPROFILE}/libjpeg-turbo-gcc64")
list(APPEND win32_paths "$ENV{ALLUSERSPROFILE}/libjpeg-turbo-gcc")
list(APPEND win32_paths "C:/libjpeg-turbo-gcc64")
list(APPEND win32_paths "C:/libjpeg-turbo-gcc")
endif()

set(${_pkg}_INC_SYSTEM_PATHS)
set(${_pkg}_LIB_SYSTEM_PATHS)
foreach(_path ${win32_paths})
to_cmake_path(_path)
list(APPEND ${_pkg}_INC_SYSTEM_PATHS "${_path}")
list(APPEND ${_pkg}_LIB_SYSTEM_PATHS "${_path}")
endforeach()
endif()

# Extract TURBOJPEG version from include directory
function(TurboJPEG_version_function include_dir)
set(_paths ${include_dir}/)

_debug_print_var("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_paths")

find_file(
_jconfig_h jconfig.h
PATHS ${_paths}
NO_DEFAULT_PATH)

if(_jconfig_h)
file(READ ${_jconfig_h} _jconfig_h_file)
endif()

if("${_jconfig_h_file}" MATCHES ".*#define LIBJPEG_TURBO_VERSION +([0-9]+)\\.([0-9]+)\\.*([0-9]+).*")
set(${_pkg}_VERSION_MAJOR ${CMAKE_MATCH_1})
set(${_pkg}_VERSION_MINOR ${CMAKE_MATCH_2})
set(${_pkg}_VERSION_PATCH ${CMAKE_MATCH_3})
else()
message(WARNING "Unable to determine TurboJPEG's version since jconfig.h file cannot be found!")
set(${_pkg}_VERSION_MAJOR 99)
set(${_pkg}_VERSION_MINOR 99)
set(${_pkg}_VERSION_PATCH 99)
endif()
set(${_pkg}_VERSION "${${_pkg}_VERSION_MAJOR}.${${_pkg}_VERSION_MINOR}.${${_pkg}_VERSION_PATCH}")

set(${_pkg}_VERSION_MAJOR
${${_pkg}_VERSION_MAJOR}
PARENT_SCOPE)
set(${_pkg}_VERSION_MINOR
${${_pkg}_VERSION_MINOR}
PARENT_SCOPE)
set(${_pkg}_VERSION_PATCH
${${_pkg}_VERSION_PATCH}
PARENT_SCOPE)
set(${_pkg}_VERSION
${${_pkg}_VERSION}
PARENT_SCOPE)
endfunction()

# Update TURBOJPEG library search directories with pre-built paths
function(TurboJPEG_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/lib)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 289
- 0
cmake/modules/Findabsl.cmake View File

@@ -0,0 +1,289 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
Findabsl
---------

Find absl include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(absl
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if absl is not found
[COMPONENTS <libs>...] # absl libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "absl
CMake" build. For the latter case skip to the :ref:`absl CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``absl_FOUND``
True if headers and requested libraries were found.

``absl_INCLUDE_DIRS``
absl include directories.

``absl_LIBRARY_DIRS``
Link directories for absl libraries.

``absl_LIBRARIES``
absl component libraries to be linked.

``absl_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``absl_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``absl_VERSION``
absl version number in ``X.Y`` format.

``absl_VERSION_MAJOR``
absl major version number (``X`` in ``X.Y``).

``absl_VERSION_MINOR``
absl minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``absl_INCLUDE_DIR``
Directory containing absl headers.

``absl_LIBRARY_DIR_RELEASE``
Directory containing release absl libraries.

``absl_LIBRARY_DIR_DEBUG``
Directory containing debug absl libraries.

``absl_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``absl_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``absl_ROOT``, ``abslROOT``
Preferred installation prefix.

``absl_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``absl_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``absl_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``absl``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the absl header files using the above hint variables (excluding ``absl_LIBRARYDIR``) and
saves the result in ``absl_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``absl_INCLUDEDIR``), "lib" directories near ``absl_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``absl_LIBRARY_DIR_DEBUG`` and ``absl_LIBRARY_DIR_RELEASE`` and
individual library locations in ``absl_<COMPONENT>_LIBRARY_DEBUG`` and ``absl_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``absl::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(absl)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

absl libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``absl_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``absl_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
absl_FIND_RELEASE_ONLY is ``ON``).

``absl_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``absl_DEBUG``
Set to ``ON`` to enable debug output from ``Findabsl``. Please enable this before filing any bug report.

``absl_LIBRARY_DIR``
Default value for ``absl_LIBRARY_DIR_RELEASE`` and ``absl_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find absl headers only:

.. code-block:: cmake

find_package(absl 2.0.0)
if(absl_FOUND)
include_directories(${absl_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC absl::absl)
endif()

Find absl libraries and use imported targets:

.. code-block:: cmake

find_package(absl 2.0.0 REQUIRED COMPONENTS absl)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC absl::absl)

Find absl headers and some *static* (release only) libraries:

.. code-block:: cmake

set(absl_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(absl_USE_RELEASE_LIBS ON) # only find release libs
find_package(absl 2.0.0 COMPONENTS absl)
if(absl_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC absl::absl)
endif()

.. _`absl CMake`:

absl CMake
^^^^^^^^^^^

If absl was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``abslConfig.cmake`` and stores the result in ``CACHE``
entry ``absl_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the absl CMake package configuration for details on what it provides.

Set ``absl_NO_CMAKE`` to ``ON``, to disable the search for the package using the CONFIG method.

.. _`absl pkg-config`:

absl CMake
^^^^^^^^^^^

If absl was installed with its pkg-config files, this module may attempt to look for absl by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``absl_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg absl)
set(${_pkg}_INCLUDE_FILE config.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include/${_pkg}/base ${_pkg}/base)
set(${_pkg}_INCLUDE_DIR_UP_INDEX 1)
set(${_pkg}_DEFAULT_COMPONENTS absl)

if(NOT absl_FIND_VERSION_MAJOR)
set(absl_FIND_VERSION_MAJOR 20200923)
endif()
include(${CMAKE_CURRENT_LIST_DIR}/absl/${absl_FIND_VERSION_MAJOR}.cmake)

function(absl_version_function include_dir)
find_file(
_absl_config_h config.h
PATHS ${include_dir}/base
NO_DEFAULT_PATH)

if(_absl_config_h)
file(READ ${_absl_config_h} _absl_content)
string(REGEX MATCHALL "#define[ \t]+[a-zA-Z0-9_]+LTS_RELEASE[a-zA-Z0-9_ ]+" _absl_content "${_absl_content}")
list(APPEND _absl_content "")

if("${_absl_content}" MATCHES "#define[ \t]+ABSL_LTS_RELEASE_VERSION[ \t]+([0-9]+)[^\\.]")
set(${_pkg}_VERSION_MAJOR ${CMAKE_MATCH_1})
endif()
if("${_absl_content}" MATCHES "#define[ \t]+ABSL_LTS_RELEASE_PATCH_LEVEL[ \t]+([0-9]+)[^\\.]")
set(${_pkg}_VERSION_MINOR ${CMAKE_MATCH_1})
endif()
set(${_pkg}_VERSION_PATCH 0)
endif()

if("${${_pkg}_VERSION_MAJOR}" STREQUAL "" AND "${${_pkg}_VERSION_MINOR}" STREQUAL "")
message(WARNING "Unable to determine absl's version since absl/base/config.h file cannot be found!")
set(${_pkg}_VERSION_MAJOR 99999999)
set(${_pkg}_VERSION_MINOR 99)
set(${_pkg}_VERSION_PATCH 0)
endif()
set(${_pkg}_VERSION "${${_pkg}_VERSION_MAJOR}.${${_pkg}_VERSION_MINOR}")

set(${_pkg}_VERSION_MAJOR
${${_pkg}_VERSION_MAJOR}
PARENT_SCOPE)
set(${_pkg}_VERSION_MINOR
${${_pkg}_VERSION_MINOR}
PARENT_SCOPE)
set(${_pkg}_VERSION_PATCH
${${_pkg}_VERSION_PATCH}
PARENT_SCOPE)
set(${_pkg}_VERSION
${${_pkg}_VERSION}
PARENT_SCOPE)
endfunction()

# Update ABSL library search directories with pre-built paths
function(absl_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/lib)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 234
- 0
cmake/modules/Findc-ares.cmake View File

@@ -0,0 +1,234 @@
#.rst:
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
Findc-ares
---------

Find c-ares include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(c-ares
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if c-ares is not found
[COMPONENTS <libs>...] # c-ares libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "c-ares
CMake" build. For the latter case skip to the :ref:`c-ares CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``c-ares_FOUND``
True if headers and requested libraries were found.

``c-ares_INCLUDE_DIRS``
c-ares include directories.

``c-ares_LIBRARY_DIRS``
Link directories for c-ares libraries.

``c-ares_LIBRARIES``
c-ares component libraries to be linked.

``c-ares_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``c-ares_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``c-ares_VERSION``
c-ares version number in ``X.Y`` format.

``c-ares_VERSION_MAJOR``
c-ares major version number (``X`` in ``X.Y``).

``c-ares_VERSION_MINOR``
c-ares minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``c-ares_INCLUDE_DIR``
Directory containing c-ares headers.

``c-ares_LIBRARY_DIR_RELEASE``
Directory containing release c-ares libraries.

``c-ares_LIBRARY_DIR_DEBUG``
Directory containing debug c-ares libraries.

``c-ares_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``c-ares_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``c-ares_ROOT``, ``c-aresROOT``
Preferred installation prefix.

``c-ares_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``c-ares_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``c-ares_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``c-ares``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the c-ares header files using the above hint variables (excluding ``c-ares_LIBRARYDIR``) and
saves the result in ``c-ares_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``c-ares_INCLUDEDIR``), "lib" directories near ``c-ares_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``c-ares_LIBRARY_DIR_DEBUG`` and ``c-ares_LIBRARY_DIR_RELEASE`` and
individual library locations in ``c-ares_<COMPONENT>_LIBRARY_DEBUG`` and ``c-ares_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``c-ares::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(c-ares)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

c-ares libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``c-ares_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``c-ares_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
c-ares_FIND_RELEASE_ONLY is ``ON``).

``c-ares_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``c-ares_DEBUG``
Set to ``ON`` to enable debug output from ``Findc-ares``. Please enable this before filing any bug report.

``c-ares_LIBRARY_DIR``
Default value for ``c-ares_LIBRARY_DIR_RELEASE`` and ``c-ares_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find c-ares headers only:

.. code-block:: cmake

find_package(c-ares 2.0.0)
if(c-ares_FOUND)
include_directories(${c-ares_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC c-ares::c-ares)
endif()

Find c-ares libraries and use imported targets:

.. code-block:: cmake

find_package(c-ares 2.0.0 REQUIRED COMPONENTS c-ares)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC c-ares::c-ares)

Find c-ares headers and some *static* (release only) libraries:

.. code-block:: cmake

set(c-ares_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(c-ares_USE_RELEASE_LIBS ON) # only find release libs
find_package(c-ares 2.0.0 COMPONENTS c-ares)
if(c-ares_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC c-ares::c-ares)
endif()

.. _`c-ares CMake`:

c-ares CMake
^^^^^^^^^^^

If c-ares was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``c-aresConfig.cmake`` and stores the result in ``CACHE``
entry ``c-ares_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the c-ares CMake package configuration for details on what it provides.

Set ``c-ares_NO_CMAKE`` to ``ON``, to disable the search for tbb-cmake.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg c-ares)
set(${_pkg}_INCLUDE_FILE ares.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/${_pkg} ${_pkg})
set(${_pkg}_DEFAULT_COMPONENTS cares)
set(${_pkg}_DEFINE_PREFIX ARES)
set(${_pkg}_cares_NAMES cares)

# Update C-ARES library search directories with pre-built paths
function(c-ares_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/lib)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 228
- 0
cmake/modules/Findcppjieba.cmake View File

@@ -0,0 +1,228 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
Findcppjieba
---------

Find cppjieba include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(cppjieba
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if cppjieba is not found
[COMPONENTS <libs>...] # cppjieba libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "cppjieba
CMake" build. For the latter case skip to the :ref:`cppjieba CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``cppjieba_FOUND``
True if headers and requested libraries were found.

``cppjieba_INCLUDE_DIRS``
cppjieba include directories.

``cppjieba_LIBRARY_DIRS``
Link directories for cppjieba libraries.

``cppjieba_LIBRARIES``
cppjieba component libraries to be linked.

``cppjieba_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``cppjieba_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``cppjieba_VERSION``
cppjieba version number in ``X.Y`` format.

``cppjieba_VERSION_MAJOR``
cppjieba major version number (``X`` in ``X.Y``).

``cppjieba_VERSION_MINOR``
cppjieba minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``cppjieba_INCLUDE_DIR``
Directory containing cppjieba headers.

``cppjieba_LIBRARY_DIR_RELEASE``
Directory containing release cppjieba libraries.

``cppjieba_LIBRARY_DIR_DEBUG``
Directory containing debug cppjieba libraries.

``cppjieba_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``cppjieba_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``cppjieba_ROOT``, ``cppjiebaROOT``
Preferred installation prefix.

``cppjieba_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``cppjieba_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``cppjieba_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``cppjieba``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the cppjieba header files using the above hint variables (excluding ``cppjieba_LIBRARYDIR``) and
saves the result in ``cppjieba_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``cppjieba_INCLUDEDIR``), "lib" directories near ``cppjieba_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``cppjieba_LIBRARY_DIR_DEBUG`` and ``cppjieba_LIBRARY_DIR_RELEASE`` and
individual library locations in ``cppjieba_<COMPONENT>_LIBRARY_DEBUG`` and ``cppjieba_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``cppjieba::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(cppjieba)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

cppjieba libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``cppjieba_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``cppjieba_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
cppjieba_FIND_RELEASE_ONLY is ``ON``).

``cppjieba_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``cppjieba_DEBUG``
Set to ``ON`` to enable debug output from ``Findcppjieba``. Please enable this before filing any bug report.

``cppjieba_LIBRARY_DIR``
Default value for ``cppjieba_LIBRARY_DIR_RELEASE`` and ``cppjieba_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find cppjieba headers only:

.. code-block:: cmake

find_package(cppjieba 2.0.0)
if(cppjieba_FOUND)
include_directories(${cppjieba_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC cppjieba::cppjieba)
endif()

Find cppjieba libraries and use imported targets:

.. code-block:: cmake

find_package(cppjieba 2.0.0 REQUIRED COMPONENTS cppjieba)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC cppjieba::cppjieba)

Find cppjieba headers and some *static* (release only) libraries:

.. code-block:: cmake

set(cppjieba_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(cppjieba_USE_RELEASE_LIBS ON) # only find release libs
find_package(cppjieba 2.0.0 COMPONENTS cppjieba)
if(cppjieba_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC cppjieba::cppjieba)
endif()

.. _`cppjieba CMake`:

cppjieba CMake
^^^^^^^^^^^^^^

If cppjieba was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``cppjiebaConfig.cmake`` and stores the result in
``CACHE`` entry ``cppjieba_DIR``. If found, the package configuration file is loaded and this module returns with no
further action. See documentation of the cppjieba CMake package configuration for details on what it provides.

Set ``cppjieba_NO_CMAKE`` to ``ON``, to disable the search for the package using the CONFIG method.

.. _`cppjieba pkg-config`:

cppjieba CMake
^^^^^^^^^^^^^^

If cppjieba was installed with its pkg-config files, this module may attempt to look for cppjieba by relying on
pkg-config. If the components are found using this method, this module returns with no further action.

Set ``cppjieba_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg cppjieba)
set(${_pkg}_INCLUDE_FILE Jieba.hpp)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/${_pkg} ${_pkg})
set(${_pkg}_INCLUDE_DIR_UP_INDEX 1)
set(${_pkg}_DEFAULT_COMPONENTS cppjieba)
set(${_pkg}_cppjieba_HEADER_ONLY TRUE)

include(_find_utils_end)

# ==============================================================================

+ 378
- 0
cmake/modules/FindgRPC.cmake View File

@@ -0,0 +1,378 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
FindgRPC
---------

Find gRPC include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(gRPC
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if gRPC is not found
[COMPONENTS <libs>...] # gRPC libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "gRPC
CMake" build. For the latter case skip to the :ref:`gRPC CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``gRPC_FOUND``
True if headers and requested libraries were found.

``gRPC_INCLUDE_DIRS``
gRPC include directories.

``gRPC_LIBRARY_DIRS``
Link directories for gRPC libraries.

``gRPC_LIBRARIES``
gRPC component libraries to be linked.

``gRPC_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``gRPC_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``gRPC_VERSION``
gRPC version number in ``X.Y`` format.

``gRPC_VERSION_MAJOR``
gRPC major version number (``X`` in ``X.Y``).

``gRPC_VERSION_MINOR``
gRPC minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``gRPC_INCLUDE_DIR``
Directory containing gRPC headers.

``gRPC_LIBRARY_DIR_RELEASE``
Directory containing release gRPC libraries.

``gRPC_LIBRARY_DIR_DEBUG``
Directory containing debug gRPC libraries.

``gRPC_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``gRPC_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``gRPC_ROOT``, ``gRPCROOT``
Preferred installation prefix.

``gRPC_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``gRPC_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``gRPC_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``gRPC``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the gRPC header files using the above hint variables (excluding ``gRPC_LIBRARYDIR``) and
saves the result in ``gRPC_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``gRPC_INCLUDEDIR``), "lib" directories near ``gRPC_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``gRPC_LIBRARY_DIR_DEBUG`` and ``gRPC_LIBRARY_DIR_RELEASE`` and
individual library locations in ``gRPC_<COMPONENT>_LIBRARY_DEBUG`` and ``gRPC_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``gRPC::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(gRPC)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

gRPC libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``gRPC_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``gRPC_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
gRPC_FIND_RELEASE_ONLY is ``ON``).

``gRPC_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``gRPC_DEBUG``
Set to ``ON`` to enable debug output from ``FindgRPC``. Please enable this before filing any bug report.

``gRPC_LIBRARY_DIR``
Default value for ``gRPC_LIBRARY_DIR_RELEASE`` and ``gRPC_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find gRPC headers only:

.. code-block:: cmake

find_package(gRPC 2.0.0)
if(gRPC_FOUND)
include_directories(${gRPC_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC gRPC::gRPC)
endif()

Find gRPC libraries and use imported targets:

.. code-block:: cmake

find_package(gRPC 2.0.0 REQUIRED COMPONENTS gRPC)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC gRPC::gRPC)

Find gRPC headers and some *static* (release only) libraries:

.. code-block:: cmake

set(gRPC_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(gRPC_USE_RELEASE_LIBS ON) # only find release libs
find_package(gRPC 2.0.0 COMPONENTS gRPC)
if(gRPC_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC gRPC::gRPC)
endif()

.. _`gRPC CMake`:

gRPC CMake
^^^^^^^^^^^

If gRPC was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``gRPCConfig.cmake`` and stores the result in ``CACHE``
entry ``gRPC_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the gRPC CMake package configuration for details on what it provides.

Set ``gRPC_NO_CMAKE`` to ``ON``, to disable the search for the package using the CONFIG method.

.. _`gRPC pkg-config`:

gRPC CMake
^^^^^^^^^^^

If gRPC was installed with its pkg-config files, this module may attempt to look for gRPC by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``gRPC_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg gRPC)
string(TOLOWER ${_pkg} _pkg_lower)
set(${_pkg}_INCLUDE_FILE grpc.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include/${_pkg_lower} ${_pkg_lower})
set(${_pkg}_INCLUDE_DIR_UP_INDEX 1)
set(${_pkg}_DEFAULT_COMPONENTS
address_sorting
gpr
grpc
grpc_unsecure
grpc++
grpc++_alts
grpc++_error_details
grpc++_reflection
grpc++_unsecure
grpc_plugin_support
grpcpp_channelz
upb
grpc_cpp_plugin
grpc_csharp_plugin
grpc_node_plugin
grpc_objective_c_plugin
grpc_php_plugin
grpc_python_plugin
grpc_ruby_plugin)

set(_${_pkg}_exec_list
grpc_cpp_plugin
grpc_csharp_plugin
grpc_node_plugin
grpc_objective_c_plugin
grpc_php_plugin
grpc_python_plugin
grpc_ruby_plugin)

foreach(_exec ${_${_pkg}_exec_list})
set(${_pkg}_${_exec}_NAMES ${_exec})
set(${_pkg}_${_exec}_TYPE "EXECUTABLE")
endforeach()

# ==============================================================================
# Depend packages

set(${_pkg}_EXTERNAL_DEPENDENCIES ZLIB Protobuf OpenSSL c-ares absl re2)

set(${_pkg}_EXTERNAL_DEPENDENCY_ZLIB_COMPONENTS ZLIB)
set(${_pkg}_EXTERNAL_DEPENDENCY_ZLIB_FOUND_VARS ZLIB_FOUND)
set(${_pkg}_EXTERNAL_DEPENDENCY_ZLIB_FIND_ARGS)

set(${_pkg}_EXTERNAL_DEPENDENCY_Protobuf_FOUND_VARS Protobuf_FOUND PROTOBUF_FOUND)

set(${_pkg}_EXTERNAL_DEPENDENCY_OpenSSL_FOUND_VARS OPENSSL_FOUND)

set(${_pkg}_EXTERNAL_DEPENDENCY_c-ares_FOUND_VARS c-ares_FOUND)

set(${_pkg}_EXTERNAL_DEPENDENCY_absl_FOUND_VARS absl_FOUND)
set(${_pkg}_EXTERNAL_DEPENDENCY_absl_COMPONENTS
optional
time
synchronization
strings
str_format
status
memory
base
statusor
status
bind_front
inlined_vector
flat_hash_set
flat_hash_map)

set(${_pkg}_EXTERNAL_DEPENDENCY_re2_COMPONENTS re2)
set(${_pkg}_EXTERNAL_DEPENDENCY_re2_FOUND_VARS re2_FOUND)

# ==============================================================================

set(${_pkg}_address_sorting_NAMES address_sorting)
set(${_pkg}_gpr_NAMES gpr)
set(${_pkg}_gpr_EXTERNAL_DEPENDENCIES
absl::optional
absl::time
absl::synchronization
absl::strings
absl::str_format
absl::status
absl::memory
absl::base)
set(${_pkg}_grpc_NAMES grpc)
set(${_pkg}_grpc_DEPENDENCIES address_sorting upb gpr address_sorting upb)
set(${_pkg}_grpc_EXTERNAL_DEPENDENCIES
OpenSSL::SSL
OpenSSL::Crypto
ZLIB::ZLIB
c-ares::cares
re2::re2
dl
rt
m
pthread
absl::optional
absl::strings
absl::statusor
absl::status
absl::bind_front
absl::inlined_vector
absl::flat_hash_set
absl::flat_hash_map)
set(${_pkg}_grpc_unsecure_NAMES grpc_unsecure)
set(${_pkg}_grpc_unsecure_DEPENDENCIES address_sorting upb gpr address_sorting upb)
set(${_pkg}_grpc_unsecure_EXTERNAL_DEPENDENCIES
ZLIB::ZLIB
c-ares::cares
re2::re2
absl::optional
absl::strings
absl::statusor
absl::status
absl::inlined_vector
absl::flat_hash_map)
set(${_pkg}_grpc++_NAMES grpc++)
set(${_pkg}_grpc++_DEPENDENCIES grpc gpr address_sorting upb)
set(${_pkg}_grpc++_EXTERNAL_DEPENDENCIES protobuf::libprotobuf)
set(${_pkg}_grpc++_alts_NAMES grpc++_alts)
set(${_pkg}_grpc++_alts_DEPENDENCIES grpc++ grpc gpr address_sorting upb)
set(${_pkg}_grpc++_alts_EXTERNAL_DEPENDENCIES protobuf::libprotobuf)
set(${_pkg}_grpc++_error_details_NAMES grpc++_error_details)
set(${_pkg}_grpc++_error_details_DEPENDENCIES grpc++ grpc gpr address_sorting upb)
set(${_pkg}_grpc++_error_details_EXTERNAL_DEPENDENCIES protobuf::libprotobuf)
set(${_pkg}_grpc++_reflection_NAMES grpc++_reflection)
set(${_pkg}_grpc++_reflection_DEPENDENCIES grpc++ grpc gpr address_sorting upb)
set(${_pkg}_grpc++_reflection_EXTERNAL_DEPENDENCIES protobuf::libprotobuf)
set(${_pkg}_grpc++_unsecure_NAMES grpc++_unsecure)
set(${_pkg}_grpc++_unsecure_DEPENDENCIES grpc_unsecure gpr address_sorting upb)
set(${_pkg}_grpc++_unsecure_EXTERNAL_DEPENDENCIES protobuf::libprotobuf)
set(${_pkg}_grpc_plugin_support_NAMES grpc_plugin_support)
set(${_pkg}_grpc_plugin_support_EXTERNAL_DEPENDENCIES protobuf::libprotoc protobuf::libprotobuf)
set(${_pkg}_grpcpp_channelz_NAMES grpcpp_channelz)
set(${_pkg}_grpcpp_channelz_DEPENDENCIES grpc++ grpc gpr address_sorting upb)
set(${_pkg}_grpcpp_channelz_EXTERNAL_DEPENDENCIES protobuf::libprotobuf)
set(${_pkg}_upb_NAMES upb)

# Update GRPC library search directories with pre-built paths
function(gRPC_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/lib)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 242
- 0
cmake/modules/Findglog.cmake View File

@@ -0,0 +1,242 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
Findglog
---------

Find glog include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(glog
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if glog is not found
[COMPONENTS <libs>...] # glog libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "glog
CMake" build. For the latter case skip to the :ref:`glog CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``glog_FOUND``
True if headers and requested libraries were found.

``glog_INCLUDE_DIRS``
glog include directories.

``glog_LIBRARY_DIRS``
Link directories for glog libraries.

``glog_LIBRARIES``
glog component libraries to be linked.

``glog_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``glog_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``glog_VERSION``
glog version number in ``X.Y`` format.

``glog_VERSION_MAJOR``
glog major version number (``X`` in ``X.Y``).

``glog_VERSION_MINOR``
glog minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``glog_INCLUDE_DIR``
Directory containing glog headers.

``glog_LIBRARY_DIR_RELEASE``
Directory containing release glog libraries.

``glog_LIBRARY_DIR_DEBUG``
Directory containing debug glog libraries.

``glog_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``glog_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``glog_ROOT``, ``glogROOT``
Preferred installation prefix.

``glog_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``glog_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``glog_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``glog``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the glog header files using the above hint variables (excluding ``glog_LIBRARYDIR``) and
saves the result in ``glog_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``glog_INCLUDEDIR``), "lib" directories near ``glog_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``glog_LIBRARY_DIR_DEBUG`` and ``glog_LIBRARY_DIR_RELEASE`` and
individual library locations in ``glog_<COMPONENT>_LIBRARY_DEBUG`` and ``glog_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``glog::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(glog)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

glog libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``glog_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``glog_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
glog_FIND_RELEASE_ONLY is ``ON``).

``glog_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``glog_DEBUG``
Set to ``ON`` to enable debug output from ``Findglog``. Please enable this before filing any bug report.

``glog_LIBRARY_DIR``
Default value for ``glog_LIBRARY_DIR_RELEASE`` and ``glog_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find glog headers only:

.. code-block:: cmake

find_package(glog 0.5.0)
if(glog_FOUND)
include_directories(${glog_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC glog::glog)
endif()

Find glog libraries and use imported targets:

.. code-block:: cmake

find_package(glog 0.5.0 REQUIRED COMPONENTS glog)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC glog::glog)

Find glog headers and some *static* (release only) libraries:

.. code-block:: cmake

set(glog_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(glog_USE_RELEASE_LIBS ON) # only find release libs
find_package(glog 0.5.0 COMPONENTS glog)
if(glog_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC glog::glog)
endif()

.. _`glog CMake`:

glog CMake
^^^^^^^^^^^

If glog was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``glogConfig.cmake`` and stores the result in ``CACHE``
entry ``glog_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the glog CMake package configuration for details on what it provides.

Set ``glog_NO_CMAKE`` to ``ON``, to disable the search for the package using the CONFIG method.

.. _`glog pkg-config`:

glog CMake
^^^^^^^^^^^

If glog was installed with its pkg-config files, this module may attempt to look for glog by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``glog_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

include(_find_utils_begin)

set(_pkg glog)
set(${_pkg}_INCLUDE_FILE stl_logging.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/${_pkg} ${_pkg})
set(${_pkg}_DEFAULT_COMPONENTS glog)
set(${_pkg}_glog_NAMES glog)

function(glog_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/Relase)
list(APPEND ${componentlibvar} ${basedir}/MinSizeRel)
list(APPEND ${componentlibvar} ${basedir}/RelWithDebInfo)
list(APPEND ${componentlibvar} ${basedir}/Debug)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 242
- 0
cmake/modules/Findnccl.cmake View File

@@ -0,0 +1,242 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
Findnccl
---------

Find nccl include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(nccl
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if nccl is not found
[COMPONENTS <libs>...] # nccl libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "nccl
CMake" build. For the latter case skip to the :ref:`nccl CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``nccl_FOUND``
True if headers and requested libraries were found.

``nccl_INCLUDE_DIRS``
nccl include directories.

``nccl_LIBRARY_DIRS``
Link directories for nccl libraries.

``nccl_LIBRARIES``
nccl component libraries to be linked.

``nccl_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``nccl_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``nccl_VERSION``
nccl version number in ``X.Y`` format.

``nccl_VERSION_MAJOR``
nccl major version number (``X`` in ``X.Y``).

``nccl_VERSION_MINOR``
nccl minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``nccl_INCLUDE_DIR``
Directory containing nccl headers.

``nccl_LIBRARY_DIR_RELEASE``
Directory containing release nccl libraries.

``nccl_LIBRARY_DIR_DEBUG``
Directory containing debug nccl libraries.

``nccl_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``nccl_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``nccl_ROOT``, ``ncclROOT``
Preferred installation prefix.

``nccl_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``nccl_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``nccl_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``nccl``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the nccl header files using the above hint variables (excluding ``nccl_LIBRARYDIR``) and
saves the result in ``nccl_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``nccl_INCLUDEDIR``), "lib" directories near ``nccl_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``nccl_LIBRARY_DIR_DEBUG`` and ``nccl_LIBRARY_DIR_RELEASE`` and
individual library locations in ``nccl_<COMPONENT>_LIBRARY_DEBUG`` and ``nccl_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``nccl::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(nccl)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

nccl libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``nccl_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``nccl_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
nccl_FIND_RELEASE_ONLY is ``ON``).

``nccl_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``nccl_DEBUG``
Set to ``ON`` to enable debug output from ``Findnccl``. Please enable this before filing any bug report.

``nccl_LIBRARY_DIR``
Default value for ``nccl_LIBRARY_DIR_RELEASE`` and ``nccl_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find nccl headers only:

.. code-block:: cmake

find_package(nccl 2.0.0)
if(nccl_FOUND)
include_directories(${nccl_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC nccl::nccl)
endif()

Find nccl libraries and use imported targets:

.. code-block:: cmake

find_package(nccl 2.0.0 REQUIRED COMPONENTS nccl)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC nccl::nccl)

Find nccl headers and some *static* (release only) libraries:

.. code-block:: cmake

set(nccl_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(nccl_USE_RELEASE_LIBS ON) # only find release libs
find_package(nccl 2.0.0 COMPONENTS nccl)
if(nccl_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC nccl::nccl)
endif()

.. _`nccl CMake`:

nccl CMake
^^^^^^^^^^

If nccl was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``ncclConfig.cmake`` and stores the result in ``CACHE``
entry ``nccl_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the nccl CMake package configuration for details on what it provides.

Set ``nccl_NO_CMAKE`` to ``ON``, to disable the search for the package using the CONFIG method.

.. _`nccl pkg-config`:

nccl CMake
^^^^^^^^^^

If nccl was installed with its pkg-config files, this module may attempt to look for nccl by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``nccl_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg nccl)
set(${_pkg}_INCLUDE_FILE nccl.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/${_pkg} ${_pkg})
set(${_pkg}_DEFAULT_COMPONENTS nccl)
set(${_pkg}_nccl_NAMES nccl)

# Update NCCL library search directories with pre-built paths
function(nccl_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/lib)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 228
- 0
cmake/modules/Findnlohmann_json.cmake View File

@@ -0,0 +1,228 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
Findnlohmann_json
---------

Find nlohmann_json include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(nlohmann_json
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if nlohmann_json is not found
[COMPONENTS <libs>...] # nlohmann_json libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "nlohmann_json
CMake" build. For the latter case skip to the :ref:`nlohmann_json CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``nlohmann_json_FOUND``
True if headers and requested libraries were found.

``nlohmann_json_INCLUDE_DIRS``
nlohmann_json include directories.

``nlohmann_json_LIBRARY_DIRS``
Link directories for nlohmann_json libraries.

``nlohmann_json_LIBRARIES``
nlohmann_json component libraries to be linked.

``nlohmann_json_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``nlohmann_json_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``nlohmann_json_VERSION``
nlohmann_json version number in ``X.Y`` format.

``nlohmann_json_VERSION_MAJOR``
nlohmann_json major version number (``X`` in ``X.Y``).

``nlohmann_json_VERSION_MINOR``
nlohmann_json minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``nlohmann_json_INCLUDE_DIR``
Directory containing nlohmann_json headers.

``nlohmann_json_LIBRARY_DIR_RELEASE``
Directory containing release nlohmann_json libraries.

``nlohmann_json_LIBRARY_DIR_DEBUG``
Directory containing debug nlohmann_json libraries.

``nlohmann_json_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``nlohmann_json_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``nlohmann_json_ROOT``, ``nlohmann_jsonROOT``
Preferred installation prefix.

``nlohmann_json_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``nlohmann_json_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``nlohmann_json_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``nlohmann_json``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the nlohmann_json header files using the above hint variables (excluding ``nlohmann_json_LIBRARYDIR``) and
saves the result in ``nlohmann_json_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``nlohmann_json_INCLUDEDIR``), "lib" directories near ``nlohmann_json_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``nlohmann_json_LIBRARY_DIR_DEBUG`` and ``nlohmann_json_LIBRARY_DIR_RELEASE`` and
individual library locations in ``nlohmann_json_<COMPONENT>_LIBRARY_DEBUG`` and ``nlohmann_json_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``nlohmann_json::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(nlohmann_json)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

nlohmann_json libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``nlohmann_json_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``nlohmann_json_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
nlohmann_json_FIND_RELEASE_ONLY is ``ON``).

``nlohmann_json_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``nlohmann_json_DEBUG``
Set to ``ON`` to enable debug output from ``Findnlohmann_json``. Please enable this before filing any bug report.

``nlohmann_json_LIBRARY_DIR``
Default value for ``nlohmann_json_LIBRARY_DIR_RELEASE`` and ``nlohmann_json_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find nlohmann_json headers only:

.. code-block:: cmake

find_package(nlohmann_json 2.0.0)
if(nlohmann_json_FOUND)
include_directories(${nlohmann_json_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC nlohmann_json::nlohmann_json)
endif()

Find nlohmann_json libraries and use imported targets:

.. code-block:: cmake

find_package(nlohmann_json 2.0.0 REQUIRED COMPONENTS nlohmann_json)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC nlohmann_json::nlohmann_json)

Find nlohmann_json headers and some *static* (release only) libraries:

.. code-block:: cmake

set(nlohmann_json_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(nlohmann_json_USE_RELEASE_LIBS ON) # only find release libs
find_package(nlohmann_json 2.0.0 COMPONENTS nlohmann_json)
if(nlohmann_json_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC nlohmann_json::nlohmann_json)
endif()

.. _`nlohmann_json CMake`:

nlohmann_json CMake
^^^^^^^^^^^^^^^^^^^

If nlohmann_json was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``nlohmann_jsonConfig.cmake`` and stores the result in ``CACHE``
entry ``nlohmann_json_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the nlohmann_json CMake package configuration for details on what it provides.

Set ``nlohmann_json_NO_CMAKE`` to ``ON``, to disable the search for the package using the CONFIG method.

.. _`nlohmann_json pkg-config`:

nlohmann_json CMake
^^^^^^^^^^^^^^^^^^^

If nlohmann_json was installed with its pkg-config files, this module may attempt to look for nlohmann_json by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``nlohmann_json_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg nlohmann_json)
set(${_pkg}_INCLUDE_FILE json.hpp)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/nlohmann nlohmann)
set(${_pkg}_DEFAULT_COMPONENTS nlohmann_json)
set(${_pkg}_nlohmann_json_NAMES nlohmann_json)
set(${_pkg}_nlohmann_json_HEADER_ONLY TRUE)

include(_find_utils_end)

# ==============================================================================

+ 288
- 0
cmake/modules/Findpybind11.cmake View File

@@ -0,0 +1,288 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
# ==============================================================================
#
# Looking for pybind11 can be somewhat complicated now that there are two
# possible packages: - pybind11 - pybind11-global
#
# Here we try our best to look for pybind11 in all possible locations and in a
# meaningful way. In practice, this means that we look for a valid package in
# the following order: 1. First we look in a virtualenv (if one is active) for
# a) pybind11-global b) pybind11 >= 2.6.0 c) pybind11 < 2.6.0 && pybind11-cmake
# 2. pybind11-gobal in user site (if not in a virtualenv) 3. pybind11-gobal in
# global site package (also done if within a virtualenv) 4. pybind11 >= 2.6.0 in
# user and global sites NB: if the version of pybind11 is more recent than
# pybind11-global, we choose pybind11 5. pybind11 < 2.6.0 && pybind11-cmake in
# user and global sites
#
# ==============================================================================

# ~~~
# Make sure that pybind11 finds the correct python version
# - pybind11 < 2.6.0 uses find_package(PythonInterp ...)
# - pybind11 >= 2.6.0 looks for the `python` command or PYTHON_EXECUTABLE
# => specify PYTHON_EXECUTABLE manually to guarantee we find the same
# interpreter and libraries as for other python packages
# ~~~
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
set(PYBIND11_PYTHON_VERSION ${Python_VERSION}) # maybe not strictly required

macro(_pybind11_message)
if(NOT pybind11_FIND_QUIETLY)
message(${ARGN})
endif()
endmacro()

_pybind11_message(CHECK_START "Looking for pybind11")
list(APPEND CMAKE_MESSAGE_INDENT " ")

# ==============================================================================
# First detect whether we are in a virtualenv or not

execute_process(
COMMAND ${Python_EXECUTABLE} -c "import sys; print(int(sys.prefix != sys.base_prefix))"
OUTPUT_VARIABLE _is_virtualenv
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)

if(_is_virtualenv)
# ~~~
# Try to find in order within the virtualenv:
# - pybind11-global
# - pybind11 >= 2.6.0
# - pybind11 < 2.6.0 with pybind11-cmake
# - if all of that fails, revert to user and global sites (as far as is possible)
# ~~~

_pybind11_message(CHECK_START "Looking for pybind11-global in virtualenv")

# Look for pybind11-global
execute_process(
COMMAND ${Python_EXECUTABLE} -c "import sys, os; print(os.path.join(sys.prefix, 'share', 'cmake', 'pybind11'))"
OUTPUT_VARIABLE pybind11_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(NOT EXISTS pybind11_DIR)
_pybind11_message(CHECK_FAIL "Not-found")

# Could not find pybind11-global, try pybind11 >= 2.6.0
_pybind11_message(CHECK_START "Looking for pybind11 >= 2.6.0 in virtualenv")

__find_python_module(pybind11 VERSION 2.6.0)
if(PYMOD_PYBIND11_FOUND)
_pybind11_message(CHECK_PASS "Found")
execute_process(
COMMAND ${Python_EXECUTABLE} -m pybind11 --cmakedir
OUTPUT_VARIABLE pybind11_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
_pybind11_message(CHECK_FAIL "Not-found")
# Now try pybind11 < 2.6.0 && pybind11-cmake
__find_python_module(pybind11-cmake)
if(PYMOD_PYBIND11_CMAKE_FOUND)
execute_process(
COMMAND ${Python_EXECUTABLE} -c "import pybind11_cmake; print(pybind11_cmake.__path__[0])"
OUTPUT_VARIABLE pybind11_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
endif()
else()
_pybind11_message(CHECK_PASS "Found")
endif()

# Try to find some valid pybind11 config within the virtualenv
find_package(pybind11 2.6.0 CONFIG QUIET NO_DEFAULT_PATH)
endif()

# ------------------------------------------------------------------------------

if(NOT pybind11_FOUND)
_pybind11_message(CHECK_START "Looking for pybind11-global in global and user sites")

if(NOT _is_virtualenv)
# Try pybind11-global in user site
execute_process(
COMMAND ${Python_EXECUTABLE} -m site --user-base
RESULT_VARIABLE _status
OUTPUT_VARIABLE _user_base
OUTPUT_STRIP_TRAILING_WHITESPACE)

# NB: _status == 0 means user site enabled. Anything else and we really should not consider it
if(_status EQUAL 0 AND EXISTS "${_user_base}/share/cmake/pybind11/")
# cmake-lint: disable=C0103
set(pybind11_DIR "${_user_base}/share/cmake/pybind11/")
endif()
endif()

# Try to find pybind11-global either in user-site or global-site (even in the case of a virtualenv since we did not
# find anything useful in it previously)
find_package(pybind11 2.6.0 CONFIG QUIET)

if(pybind11_FOUND)
_pybind11_message(CHECK_PASS "Found")
else()
_pybind11_message(CHECK_PASS "Not-found")
endif()

if(NOT _is_virtualenv)
_pybind11_message(CHECK_START "Looking for pybind11 Python module")

# Try to find pybind11 either in user-site or global-site
if(pybind11_FIND_QUIETLY)
set(_args QUIET)
endif()
__find_python_module(pybind11 VERSION 2.6.0 ${_args})
unset(_args)

if(PYMOD_PYBIND11_FOUND)
_pybind11_message(CHECK_PASS "Found")
else()
_pybind11_message(CHECK_PASS "Not-found")
endif()

if(PYMOD_PYBIND11_FOUND AND PYMOD_PYBIND11_VERSION VERSION_GREATER pybind11_VERSION)
# We prefer pybind11 over pybind11 global if its version is more recent. This could typically be the case if a
# user installs a more recent version of pybind11 in its user site.
execute_process(
COMMAND ${Python_EXECUTABLE} -m pybind11 --cmakedir
OUTPUT_VARIABLE pybind11_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()

_pybind11_message(CHECK_START "Looking for pybind11 (final)")

# Look for pybind11 again in case we have pybind11 more recent than pybind11-global
find_package(pybind11 2.6.0 CONFIG QUIET NO_DEFAULT_PATH)

# If we are not in a virtualenv, we should still try to look for pybind11 < 2.6.0 && pybind11-cmake
if(NOT pybind11_FOUND)
_pybind11_message(CHECK_PASS "Not-found")

_pybind11_message(CHECK_START "Looking for pybind11-cmake")
# If everything else fails, rely on the pybind11_cmake package
__find_python_module(pybind11-cmake)
if(PYMOD_PYBIND11_CMAKE_FOUND)
_pybind11_message(CHECK_PASS "Done")
execute_process(
COMMAND ${Python_EXECUTABLE} -c "import pybind11_cmake; print(pybind11_cmake.__path__[0])"
OUTPUT_VARIABLE pybind11_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
_pybind11_message(CHECK_FAIL "Failed")
endif()
else()
_pybind11_message(CHECK_PASS "Found")
endif()
endif()
endif()

# ------------------------------------------------------------------------------
# Now look for pybind11 using the CONFIG method one last time. This would typically only be useful in the case of
# pybind11 < 2.6.0 located in either user or global sites.

list(POP_BACK CMAKE_MESSAGE_INDENT)
if(pybind11_DIR)
_pybind11_message(CHECK_PASS "Done")
else()
_pybind11_message(CHECK_FAIL "Failed")
endif()
find_package(pybind11 2.6.0 CONFIG NO_DEFAULT_PATH)

# ==============================================================================

# With pybind11-cmake 1.0.0 we might need to fix the include path
if(PYMOD_PYBIND11_CMAKE_FOUND)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("#include <pybind11/pybind11.h>
int main() {return 0;}" pybind11_compiles)

if(NOT pybind11_compiles)
# This could happen with pybind11_cmake == 1.0.0 because there is a typo in the pybind11Config.cmake
execute_process(
COMMAND ${Python_EXECUTABLE} -c "import pybind11
print(pybind11.get_include(False) + ';' + pybind11.get_include(True))"
OUTPUT_VARIABLE _pybind11_inc_dir
OUTPUT_STRIP_TRAILING_WHITESPACE)
get_directory_property(_inc_dirs INCLUDE_DIRECTORIES)
list(FILTER _inc_dirs EXCLUDE REGEX .*pybind11_INCLUDE_DIR$)
list(APPEND _inc_dirs ${_pybind11_inc_dir})
set_directory_properties(PROPERTIES INCLUDE_DIRECTORIES "${_inc_dirs}")
endif()
endif()

# ==============================================================================

if(pybind11_FOUND)
if(NOT TARGET pybind11::headers)
_pybind11_message(SEND_ERROR
"Target pybind11::headers was not defined! Perhaps try updating pybind11 on your system?")
endif()
if(NOT TARGET pybind11::pybind11)
_pybind11_message(SEND_ERROR
"Target pybind11::pybind11 was not defined! Perhaps try updating pybind11 on your system?")
endif()
if(NOT TARGET pybind11::module)
_pybind11_message(SEND_ERROR
"Target pybind11::module was not defined! Perhaps try updating pybind11 on your system?")
endif()

# NB: workardound for NVHPC compiler that requires -isystem (e.g. for /usr/include)
get_target_property(_include_dir pybind11::pybind11_headers INTERFACE_INCLUDE_DIRECTORIES)

if(_include_dir)
target_include_directories(pybind11::pybind11_headers SYSTEM INTERFACE ${_include_dir})
endif()
else()
_pybind11_message(STATUS "pybind11 was not found on your system or it is an incompatible version")
_pybind11_message(STATUS " -> will be fetching pybind11 from an external Git repository")

set(PKG_NAME pybind11)
set(PKG_ROOT ${DEP_DIR}/${PKG_NAME}-src)

set(URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.9.0.tar.gz")

FetchContent_Declare(${PKG_NAME} URL ${URL})
FetchContent_GetProperties(${PKG_NAME})
if(NOT ${PKG_NAME}_POPULATED)
FetchContent_Populate(${PKG_NAME})
endif()

include_directories(${PKG_ROOT}/include)
add_subdirectory(${PKG_ROOT} pybind11-build)
endif()

# ------------------------------------------------------------------------------

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
pybind11
REQUIRED_VARS pybind11_INCLUDE_DIR
VERSION_VAR pybind11_VERSION)

# ------------------------------------------------------------------------------

# For debugging
if(pybind11_FOUND)
_pybind11_message(STATUS "Found pybind11 using the CONFIG method in ${pybind11_DIR}")
_pybind11_message(STATUS "Found pybind11 and defined the pybind11::pybind11 imported target:")
_pybind11_message(STATUS " - include: ${pybind11_INCLUDE_DIR}")
_pybind11_message(STATUS " - version: ${pybind11_VERSION}")
endif()

# ==============================================================================

mark_as_advanced(pybind11_DIR)

# ==============================================================================

+ 242
- 0
cmake/modules/Findre2.cmake View File

@@ -0,0 +1,242 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
Findre2
---------

Find re2 include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(re2
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if re2 is not found
[COMPONENTS <libs>...] # re2 libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "re2
CMake" build. For the latter case skip to the :ref:`re2 CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``re2_FOUND``
True if headers and requested libraries were found.

``re2_INCLUDE_DIRS``
re2 include directories.

``re2_LIBRARY_DIRS``
Link directories for re2 libraries.

``re2_LIBRARIES``
re2 component libraries to be linked.

``re2_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``re2_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``re2_VERSION``
re2 version number in ``X.Y`` format.

``re2_VERSION_MAJOR``
re2 major version number (``X`` in ``X.Y``).

``re2_VERSION_MINOR``
re2 minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``re2_INCLUDE_DIR``
Directory containing re2 headers.

``re2_LIBRARY_DIR_RELEASE``
Directory containing release re2 libraries.

``re2_LIBRARY_DIR_DEBUG``
Directory containing debug re2 libraries.

``re2_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``re2_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``re2_ROOT``, ``re2ROOT``
Preferred installation prefix.

``re2_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``re2_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``re2_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``re2``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the re2 header files using the above hint variables (excluding ``re2_LIBRARYDIR``) and
saves the result in ``re2_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``re2_INCLUDEDIR``), "lib" directories near ``re2_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``re2_LIBRARY_DIR_DEBUG`` and ``re2_LIBRARY_DIR_RELEASE`` and
individual library locations in ``re2_<COMPONENT>_LIBRARY_DEBUG`` and ``re2_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``re2::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(re2)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

re2 libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``re2_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``re2_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
re2_FIND_RELEASE_ONLY is ``ON``).

``re2_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``re2_DEBUG``
Set to ``ON`` to enable debug output from ``Findre2``. Please enable this before filing any bug report.

``re2_LIBRARY_DIR``
Default value for ``re2_LIBRARY_DIR_RELEASE`` and ``re2_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find re2 headers only:

.. code-block:: cmake

find_package(re2 2.0.0)
if(re2_FOUND)
include_directories(${re2_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC re2::re2)
endif()

Find re2 libraries and use imported targets:

.. code-block:: cmake

find_package(re2 2.0.0 REQUIRED COMPONENTS re2)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC re2::re2)

Find re2 headers and some *static* (release only) libraries:

.. code-block:: cmake

set(re2_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(re2_USE_RELEASE_LIBS ON) # only find release libs
find_package(re2 2.0.0 COMPONENTS re2)
if(re2_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC re2::re2)
endif()

.. _`re2 CMake`:

re2 CMake
^^^^^^^^^^^

If re2 was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``re2Config.cmake`` and stores the result in ``CACHE``
entry ``re2_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the re2 CMake package configuration for details on what it provides.

Set ``re2_NO_CMAKE`` to ``ON``, to disable the search for the package using the CONFIG method.

.. _`re2 pkg-config`:

re2 CMake
^^^^^^^^^^^

If re2 was installed with its pkg-config files, this module may attempt to look for re2 by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``re2_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg re2)
set(${_pkg}_INCLUDE_FILE re2.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/${_pkg} ${_pkg})
set(${_pkg}_DEFAULT_COMPONENTS re2)
set(${_pkg}_re2_NAMES re2) # names for the library

# Update RE2 library search directories with pre-built paths
function(re2_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/lib)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 302
- 0
cmake/modules/Findsentencepiece.cmake View File

@@ -0,0 +1,302 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
Findsentencepiece
---------

Find sentencepiece include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(sentencepiece
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if sentencepiece is not found
[COMPONENTS <libs>...] # sentencepiece libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "sentencepiece
CMake" build. For the latter case skip to the :ref:`sentencepiece CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``sentencepiece_FOUND``
True if headers and requested libraries were found.

``sentencepiece_INCLUDE_DIRS``
sentencepiece include directories.

``sentencepiece_LIBRARY_DIRS``
Link directories for sentencepiece libraries.

``sentencepiece_LIBRARIES``
sentencepiece component libraries to be linked.

``sentencepiece_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``sentencepiece_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``sentencepiece_VERSION``
sentencepiece version number in ``X.Y`` format.

``sentencepiece_VERSION_MAJOR``
sentencepiece major version number (``X`` in ``X.Y``).

``sentencepiece_VERSION_MINOR``
sentencepiece minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``sentencepiece_INCLUDE_DIR``
Directory containing sentencepiece headers.

``sentencepiece_LIBRARY_DIR_RELEASE``
Directory containing release sentencepiece libraries.

``sentencepiece_LIBRARY_DIR_DEBUG``
Directory containing debug sentencepiece libraries.

``sentencepiece_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``sentencepiece_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``sentencepiece_ROOT``, ``sentencepieceROOT``
Preferred installation prefix.

``sentencepiece_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``sentencepiece_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``sentencepiece_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``sentencepiece``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the sentencepiece header files using the above hint variables (excluding ``sentencepiece_LIBRARYDIR``) and
saves the result in ``sentencepiece_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``sentencepiece_INCLUDEDIR``), "lib" directories near ``sentencepiece_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``sentencepiece_LIBRARY_DIR_DEBUG`` and ``sentencepiece_LIBRARY_DIR_RELEASE`` and
individual library locations in ``sentencepiece_<COMPONENT>_LIBRARY_DEBUG`` and ``sentencepiece_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``sentencepiece::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(sentencepiece)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

sentencepiece libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``sentencepiece_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``sentencepiece_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
sentencepiece_FIND_RELEASE_ONLY is ``ON``).

``sentencepiece_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``sentencepiece_DEBUG``
Set to ``ON`` to enable debug output from ``Findsentencepiece``. Please enable this before filing any bug report.

``sentencepiece_LIBRARY_DIR``
Default value for ``sentencepiece_LIBRARY_DIR_RELEASE`` and ``sentencepiece_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find sentencepiece headers only:

.. code-block:: cmake

find_package(sentencepiece 2.0.0)
if(sentencepiece_FOUND)
include_directories(${sentencepiece_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC sentencepiece::sentencepiece)
endif()

Find sentencepiece libraries and use imported targets:

.. code-block:: cmake

find_package(sentencepiece 2.0.0 REQUIRED COMPONENTS sentencepiece)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC sentencepiece::sentencepiece)

Find sentencepiece headers and some *static* (release only) libraries:

.. code-block:: cmake

set(sentencepiece_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(sentencepiece_USE_RELEASE_LIBS ON) # only find release libs
find_package(sentencepiece 2.0.0 COMPONENTS sentencepiece)
if(sentencepiece_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC sentencepiece::sentencepiece)
endif()

.. _`sentencepiece CMake`:

sentencepiece CMake
^^^^^^^^^^^

If sentencepiece was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``sentencepieceConfig.cmake`` and stores the result in ``CACHE``
entry ``sentencepiece_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the sentencepiece CMake package configuration for details on what it provides.

Set ``sentencepiece_NO_CMAKE`` to ``ON``, to disable the search for the package using the CONFIG method.

.. _`sentencepiece pkg-config`:

sentencepiece CMake
^^^^^^^^^^^

If sentencepiece was installed with its pkg-config files, this module may attempt to look for sentencepiece by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``sentencepiece_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

# cmake-lint: disable=C0103

include(_find_utils_begin)

set(_pkg sentencepiece)
set(${_pkg}_INCLUDE_FILE sentencepiece_processor.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/${_pkg} ${_pkg})
set(${_pkg}_DEFAULT_COMPONENTS sentencepiece sentencepiece_train)
set(${_pkg}_sentencepiece_NAMES sentencepiece)
set(${_pkg}_sentencepiece_train_NAMES sentencepiece_train)
set(${_pkg}_sentencepiece_train_PKGCONFIG_NAMES sentencepiece)
set(_${_pkg}_exec_names spm_decode spm_encode spm_export_vocab spm_normalize spm_train)

foreach(_exec _${_pkg}_exec_names)
set(${_pkg}_${exec}_NAMES ${_exec})
set(${_pkg}_${exec}_TYPE "EXECUTABLE")
endforeach()

function(sentencepiece_version_function include_dir)
find_program(
_spm_exec
NAMES ${_${_pkg}_exec_names}
PATHS ${include_dir}/../bin
NO_DEFAULT_PATH)

if(_spm_exec)
# NB: workaround possible issue with library loading issues
if(APPLE)
set(ENV{DYLD_LIBRARY_PATH} "${include_dir}/../lib;$ENV{DYLD_LIBRARY_PATH}")
elseif(UNIX)
set(ENV{LD_LIBRARY_PATH} "${include_dir}/../lib;$ENV{LD_LIBRARY_PATH}")
endif()

execute_process(
COMMAND ${_spm_exec} --version
RESULT_VARIABLE _has_sentencepiece_version
OUTPUT_VARIABLE _sentencepiece_version)

if(_has_sentencepiece_version EQUAL 0 AND _sentencepiece_version MATCHES
"sentencepiece[ \t]+([0-9]+)\\.([0-9]+)\\.([0-9]+)")
set(${_pkg}_VERSION_MAJOR ${CMAKE_MATCH_1})
set(${_pkg}_VERSION_MINOR ${CMAKE_MATCH_2})
set(${_pkg}_VERSION_PATCH ${CMAKE_MATCH_3})
endif()
endif()

if("${${_pkg}_VERSION_MAJOR}" STREQUAL "" AND "${${_pkg}_VERSION_MINOR}" STREQUAL "")
message(
WARNING
"Unable to determine sentencepiece's version since google/sentencepiece/stubs/common.h file cannot be found!")
set(${_pkg}_VERSION_MAJOR 99)
set(${_pkg}_VERSION_MINOR 99)
set(${_pkg}_VERSION_PATCH 99)
endif()
set(${_pkg}_VERSION "${${_pkg}_VERSION_MAJOR}.${${_pkg}_VERSION_MINOR}.${${_pkg}_VERSION_PATCH}")

set(${_pkg}_VERSION_MAJOR
${${_pkg}_VERSION_MAJOR}
PARENT_SCOPE)
set(${_pkg}_VERSION_MINOR
${${_pkg}_VERSION_MINOR}
PARENT_SCOPE)
set(${_pkg}_VERSION_PATCH
${${_pkg}_VERSION_PATCH}
PARENT_SCOPE)
set(${_pkg}_VERSION
${${_pkg}_VERSION}
PARENT_SCOPE)
endfunction()

# Update SENTENCEPIECE library search directories with pre-built paths
function(sentencepiece_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/lib)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 242
- 0
cmake/modules/Findtinyxml2.cmake View File

@@ -0,0 +1,242 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

#[=======================================================================[.rst:
Findtinyxml2
---------

Find tinyxml2 include dirs and libraries

Use this module by invoking :command:`find_package` with the form:

.. code-block:: cmake

find_package(tinyxml2
[version] [EXACT] # Minimum or EXACT version e.g. 2020.03
[REQUIRED] # Fail with error if tinyxml2 is not found
[COMPONENTS <libs>...] # tinyxml2 libraries by their canonical name
)

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "tinyxml2
CMake" build. For the latter case skip to the :ref:`tinyxml2 CMake` section below.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``tinyxml2_FOUND``
True if headers and requested libraries were found.

``tinyxml2_INCLUDE_DIRS``
tinyxml2 include directories.

``tinyxml2_LIBRARY_DIRS``
Link directories for tinyxml2 libraries.

``tinyxml2_LIBRARIES``
tinyxml2 component libraries to be linked.

``tinyxml2_<COMPONENT>_FOUND``
True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case).

``tinyxml2_<COMPONENT>_LIBRARY``
Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized
keywords).

``tinyxml2_VERSION``
tinyxml2 version number in ``X.Y`` format.

``tinyxml2_VERSION_MAJOR``
tinyxml2 major version number (``X`` in ``X.Y``).

``tinyxml2_VERSION_MINOR``
tinyxml2 minor version number (``Y`` in ``X.Y``).

Cache variables
^^^^^^^^^^^^^^^

Search results are saved persistently in CMake cache entries:

``tinyxml2_INCLUDE_DIR``
Directory containing tinyxml2 headers.

``tinyxml2_LIBRARY_DIR_RELEASE``
Directory containing release tinyxml2 libraries.

``tinyxml2_LIBRARY_DIR_DEBUG``
Directory containing debug tinyxml2 libraries.

``tinyxml2_<COMPONENT>_LIBRARY_DEBUG``
Component ``<COMPONENT>`` library debug variant.

``tinyxml2_<COMPONENT>_LIBRARY_RELEASE``
Component ``<COMPONENT>`` library release variant.

Hints
^^^^^

This module reads hints about search locations from variables:

``tinyxml2_ROOT``, ``tinyxml2ROOT``
Preferred installation prefix.

``tinyxml2_INCLUDEDIR``
Preferred include directory e.g. ``<prefix>/include``.

``tinyxml2_LIBRARYDIR``
Preferred library directory e.g. ``<prefix>/lib``.

``tinyxml2_NO_SYSTEM_PATHS``
Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``.

Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but
instead use the above result variables. Note that some hint names start in upper-case ``tinyxml2``. One may specify these
as environment variables if they are not specified as CMake variables or cache entries.

This module first searches for the tinyxml2 header files using the above hint variables (excluding ``tinyxml2_LIBRARYDIR``) and
saves the result in ``tinyxml2_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints
(excluding ``tinyxml2_INCLUDEDIR``), "lib" directories near ``tinyxml2_INCLUDE_DIR``, and the library name configuration
settings below. It saves the library directories in ``tinyxml2_LIBRARY_DIR_DEBUG`` and ``tinyxml2_LIBRARY_DIR_RELEASE`` and
individual library locations in ``tinyxml2_<COMPONENT>_LIBRARY_DEBUG`` and ``tinyxml2_<COMPONENT>_LIBRARY_RELEASE``. When one
changes settings used by previous searches in the same build tree (excluding environment variables) this module
discards previous search results affected by the changes and searches again.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``tinyxml2::<component>``
Target for specific component dependency (shared or static library); ``<component>`` name is lower-case.

It is important to note that the imported targets behave differently than variables created by this module: multiple
calls to :command:`find_package(tinyxml2)` in the same directory or sub-directories with different options (e.g. static or
shared) will not override the values of the targets created by the first call.

Other Variables
^^^^^^^^^^^^^^^

tinyxml2 libraries come in many variants encoded in their file name. Users or projects may tell this module which variant
to find by setting variables:

``tinyxml2_FIND_RELEASE_ONLY``
Set to ``ON`` or ``OFF`` to specify whether to restrict the search to release libraries only. Default is ``OFF``.

``tinyxml2_USE_DEBUG_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON`` (except when
tinyxml2_FIND_RELEASE_ONLY is ``ON``).

``tinyxml2_USE_RELEASE_LIBS``
Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``.

Other variables one may set to control this module are:

``tinyxml2_DEBUG``
Set to ``ON`` to enable debug output from ``Findtinyxml2``. Please enable this before filing any bug report.

``tinyxml2_LIBRARY_DIR``
Default value for ``tinyxml2_LIBRARY_DIR_RELEASE`` and ``tinyxml2_LIBRARY_DIR_DEBUG``.


Examples
^^^^^^^^

Find tinyxml2 headers only:

.. code-block:: cmake

find_package(tinyxml2 0.5.0)
if(tinyxml2_FOUND)
include_directories(${tinyxml2_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC tinyxml2::tinyxml2)
endif()

Find tinyxml2 libraries and use imported targets:

.. code-block:: cmake

find_package(tinyxml2 0.5.0 REQUIRED COMPONENTS tinyxml2)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC tinyxml2::tinyxml2)

Find tinyxml2 headers and some *static* (release only) libraries:

.. code-block:: cmake

set(tinyxml2_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(tinyxml2_USE_RELEASE_LIBS ON) # only find release libs
find_package(tinyxml2 0.5.0 COMPONENTS tinyxml2)
if(tinyxml2_FOUND)
add_executable(foo foo.cc)
target_link_libraries(foo PUBLIC tinyxml2::tinyxml2)
endif()

.. _`tinyxml2 CMake`:

tinyxml2 CMake
^^^^^^^^^^^

If tinyxml2 was built using CMake, it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called ``tinyxml2Config.cmake`` and stores the result in ``CACHE``
entry ``tinyxml2_DIR``. If found, the package configuration file is loaded and this module returns with no further action.
See documentation of the tinyxml2 CMake package configuration for details on what it provides.

Set ``tinyxml2_NO_CMAKE`` to ``ON``, to disable the search for the package using the CONFIG method.

.. _`tinyxml2 pkg-config`:

tinyxml2 CMake
^^^^^^^^^^^

If tinyxml2 was installed with its pkg-config files, this module may attempt to look for tinyxml2 by relying on pkg-config.
If the components are found using this method, this module returns with no further action.

Set ``tinyxml2_NO_PKGCONFIG`` to ``ON``, to disable the search for the package using the pkg-config method.

#]=======================================================================]

include(_find_utils_begin)

set(_pkg tinyxml2)
set(${_pkg}_INCLUDE_FILE tinyxml2.h)
set(${_pkg}_INCLUDE_PATH_SUFFIXES include include/${_pkg} ${_pkg})
set(${_pkg}_DEFAULT_COMPONENTS tinyxml2)
set(${_pkg}_tinyxml2_NAMES tinyxml2)

function(tinyxml2_update_library_search_dirs_with_prebuilt_paths componentlibvar basedir)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
list(APPEND ${componentlibvar} ${basedir}/Relase)
list(APPEND ${componentlibvar} ${basedir}/MinSizeRel)
list(APPEND ${componentlibvar} ${basedir}/RelWithDebInfo)
list(APPEND ${componentlibvar} ${basedir}/Debug)
elseif(UNIX)
list(APPEND ${componentlibvar} ${basedir}/lib64)
list(APPEND ${componentlibvar} ${basedir}/lib)
list(APPEND ${componentlibvar} ${basedir}/lib/x86_64-linux-gnu)
endif()

set(${componentlibvar}
${${componentlibvar}}
PARENT_SCOPE)
endfunction()

include(_find_utils_end)

# ==============================================================================

+ 34
- 0
cmake/modules/_find_utils_begin.cmake View File

@@ -0,0 +1,34 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

set(_find_utils_vars _pkg)

# ==============================================================================
# find_utils_push()

if(NOT DEFINED _find_utils_push_counter)
set(_find_utils_push_counter 0)
endif()

math(EXPR _find_utils_push_counter "${_find_utils_push_counter}+1")

foreach(_var ${_find_utils_vars})
set(_${_var}_${_find_utils_push_counter} ${${_var}})
endforeach()

# ==============================================================================

+ 29
- 0
cmake/modules/_find_utils_end.cmake View File

@@ -0,0 +1,29 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

include(FindTemplate)

# ==============================================================================
# find_utils_pop()

if("${_find_utils_push_counter}" GREATER "0")
foreach(_var ${_find_utils_vars})
set(${_var} ${_${_var}_${_find_utils_push_counter}})
endforeach()
math(EXPR _find_utils_push_counter "${_find_utils_push_counter}-1")
endif()

+ 514
- 0
cmake/modules/absl/20200923.cmake View File

@@ -0,0 +1,514 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

# Set names of each component of abseil-cpp
foreach(
comp
algorithm
algorithm_container
any
atomic_hook
bad_any_cast
bad_any_cast_impl
bad_optional_access
bad_variant_access
base
base_internal
bind_front
bits
btree
city
civil_time
compare
compressed_tuple
config
container
container_common
container_memory
cord
core_headers
counting_allocator
debugging
debugging_internal
demangle_internal
dynamic_annotations
endian
errno_saver
examine_stack
exponential_biased
failure_signal_handler
fast_type_id
fixed_array
flags
flags_commandlineflag
flags_commandlineflag_internal
flags_config
flags_internal
flags_marshalling
flags_parse
flags_path_util
flags_private_handle_accessor
flags_program_name
flags_reflection
flags_usage
flags_usage_internal
flat_hash_map
flat_hash_set
function_ref
graphcycles_internal
hash
hash_function_defaults
hash_policy_traits
hashtable_debug
hashtable_debug_hooks
hashtablez_sampler
have_sse
inlined_vector
inlined_vector_internal
int128
kernel_timeout_internal
layout
leak_check
leak_check_disable
log_severity
malloc_internal
memory
meta
node_hash_map
node_hash_policy
node_hash_set
numeric
optional
periodic_sampler
pretty_function
random_bit_gen_ref
random_distributions
random_internal_distribution_caller
random_internal_distribution_test_util
random_internal_fast_uniform_bits
random_internal_fastmath
random_internal_generate_real
random_internal_iostream_state_saver
random_internal_mock_helpers
random_internal_nonsecure_base
random_internal_pcg_engine
random_internal_platform
random_internal_pool_urbg
random_internal_randen
random_internal_randen_engine
random_internal_randen_hwaes
random_internal_randen_hwaes_impl
random_internal_randen_slow
random_internal_salted_seed_seq
random_internal_seed_material
random_internal_traits
random_internal_uniform_helper
random_internal_wide_multiply
random_random
random_seed_gen_exception
random_seed_sequences
raw_hash_map
raw_hash_set
raw_logging_internal
scoped_set_env
span
spinlock_wait
stacktrace
status
statusor
str_format
str_format_internal
strerror
strings
strings_internal
symbolize
synchronization
throw_delegate
time
time_zone
type_traits
utility
variant)
set(${_pkg}_${comp}_NAMES absl_${comp})
endforeach()

set(${_pkg}_algorithm_DEPENDENCIES config)
set(${_pkg}_algorithm_container_DEPENDENCIES algorithm core_headers meta)
set(${_pkg}_any_DEPENDENCIES bad_any_cast config core_headers fast_type_id type_traits utility)
set(${_pkg}_atomic_hook_DEPENDENCIES config core_headers)
set(${_pkg}_bad_any_cast_DEPENDENCIES bad_any_cast_impl config)
set(${_pkg}_bad_any_cast_impl_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_bad_optional_access_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_bad_variant_access_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_base_DEPENDENCIES
atomic_hook
base_internal
config
core_headers
dynamic_annotations
log_severity
raw_logging_internal
spinlock_wait
type_traits)
set(${_pkg}_base_EXTERNAL_DEPENDENCIES Threads::Threads)
set(${_pkg}_base_internal_DEPENDENCIES config type_traits)
set(${_pkg}_bind_front_DEPENDENCIES base_internal compressed_tuple)
set(${_pkg}_bits_DEPENDENCIES config core_headers)
set(${_pkg}_btree_DEPENDENCIES
container_common
compare
compressed_tuple
container_memory
cord
core_headers
layout
memory
strings
throw_delegate
type_traits
utility)
set(${_pkg}_city_DEPENDENCIES config core_headers endian)
set(${_pkg}_compare_DEPENDENCIES core_headers type_traits)
set(${_pkg}_compressed_tuple_DEPENDENCIES utility)
set(${_pkg}_container_common_DEPENDENCIES type_traits)
set(${_pkg}_container_memory_DEPENDENCIES config memory type_traits utility)
set(${_pkg}_cord_DEPENDENCIES
base
base_internal
compressed_tuple
core_headers
endian
fixed_array
function_ref
inlined_vector
optional
raw_logging_internal
strings
strings_internal
type_traits)
set(${_pkg}_core_headers_DEPENDENCIES config)
set(${_pkg}_counting_allocator_DEPENDENCIES config)
set(${_pkg}_debugging_DEPENDENCIES stacktrace leak_check)
set(${_pkg}_debugging_internal_DEPENDENCIES core_headers config dynamic_annotations errno_saver raw_logging_internal)
set(${_pkg}_demangle_internal_DEPENDENCIES base core_headers)
set(${_pkg}_dynamic_annotations_DEPENDENCIES config)
set(${_pkg}_endian_DEPENDENCIES config core_headers)
set(${_pkg}_errno_saver_DEPENDENCIES config)
set(${_pkg}_examine_stack_DEPENDENCIES stacktrace symbolize config core_headers raw_logging_internal)
set(${_pkg}_exponential_biased_DEPENDENCIES config core_headers)
set(${_pkg}_failure_signal_handler_DEPENDENCIES
examine_stack
stacktrace
base
config
core_headers
errno_saver
raw_logging_internal)
set(${_pkg}_fast_type_id_DEPENDENCIES config)
set(${_pkg}_fixed_array_DEPENDENCIES
compressed_tuple
algorithm
config
core_headers
dynamic_annotations
throw_delegate
memory)
set(${_pkg}_flags_DEPENDENCIES
config
flags_commandlineflag
flags_config
flags_internal
flags_reflection
base
core_headers
strings)
set(${_pkg}_flags_commandlineflag_DEPENDENCIES config fast_type_id flags_commandlineflag_internal optional strings)
set(${_pkg}_flags_commandlineflag_internal_DEPENDENCIES config fast_type_id)
set(${_pkg}_flags_config_DEPENDENCIES config flags_path_util flags_program_name core_headers strings synchronization)
set(${_pkg}_flags_internal_DEPENDENCIES
base
config
flags_commandlineflag
flags_commandlineflag_internal
flags_config
flags_marshalling
synchronization
meta
utility)
set(${_pkg}_flags_marshalling_DEPENDENCIES config core_headers log_severity strings str_format)
set(${_pkg}_flags_parse_DEPENDENCIES
config
core_headers
flags_config
flags
flags_commandlineflag
flags_commandlineflag_internal
flags_internal
flags_private_handle_accessor
flags_program_name
flags_reflection
flags_usage
strings
synchronization)
set(${_pkg}_flags_path_util_DEPENDENCIES config strings)
set(${_pkg}_flags_private_handle_accessor_DEPENDENCIES config flags_commandlineflag flags_commandlineflag_internal
strings)
set(${_pkg}_flags_program_name_DEPENDENCIES config core_headers flags_path_util strings synchronization)
set(${_pkg}_flags_reflection_DEPENDENCIES
config
flags_commandlineflag
flags_private_handle_accessor
flags_config
strings
synchronization
flat_hash_map)
set(${_pkg}_flags_usage_DEPENDENCIES config core_headers flags_usage_internal strings synchronization)
set(${_pkg}_flags_usage_internal_DEPENDENCIES
config
flags_config
flags
flags_commandlineflag
flags_internal
flags_path_util
flags_private_handle_accessor
flags_program_name
flags_reflection
strings
synchronization)
set(${_pkg}_flat_hash_map_DEPENDENCIES container_memory hash_function_defaults raw_hash_map algorithm_container memory)
set(${_pkg}_flat_hash_set_DEPENDENCIES container_memory hash_function_defaults raw_hash_set algorithm_container
core_headers memory)
set(${_pkg}_function_ref_DEPENDENCIES base_internal meta)
set(${_pkg}_graphcycles_internal_DEPENDENCIES base base_internal config core_headers malloc_internal
raw_logging_internal)
set(${_pkg}_hash_DEPENDENCIES
core_headers
endian
fixed_array
meta
int128
strings
optional
variant
utility
city)
set(${_pkg}_hash_function_defaults_DEPENDENCIES config cord hash strings)
set(${_pkg}_hash_policy_traits_DEPENDENCIES meta)
set(${_pkg}_hashtable_debug_DEPENDENCIES hashtable_debug_hooks)
set(${_pkg}_hashtable_debug_hooks_DEPENDENCIES config)
set(${_pkg}_hashtablez_sampler_DEPENDENCIES base exponential_biased have_sse synchronization)
set(${_pkg}_inlined_vector_DEPENDENCIES algorithm core_headers inlined_vector_internal throw_delegate memory)
set(${_pkg}_inlined_vector_internal_DEPENDENCIES compressed_tuple core_headers memory span type_traits)
set(${_pkg}_int128_DEPENDENCIES bits config core_headers)
set(${_pkg}_kernel_timeout_internal_DEPENDENCIES core_headers raw_logging_internal time)
set(${_pkg}_layout_DEPENDENCIES config core_headers meta strings span utility)
set(${_pkg}_leak_check_DEPENDENCIES config core_headers)
set(${_pkg}_log_severity_DEPENDENCIES core_headers)
set(${_pkg}_malloc_internal_DEPENDENCIES base base_internal config core_headers dynamic_annotations
raw_logging_internal)
set(${_pkg}_malloc_internal_EXTERNAL_DEPENDENCIES Threads::Threads)
set(${_pkg}_memory_DEPENDENCIES core_headers meta)
set(${_pkg}_meta_DEPENDENCIES type_traits)
set(${_pkg}_node_hash_map_DEPENDENCIES container_memory hash_function_defaults node_hash_policy raw_hash_map
algorithm_container memory)
set(${_pkg}_node_hash_policy_DEPENDENCIES config)
set(${_pkg}_node_hash_set_DEPENDENCIES hash_function_defaults node_hash_policy raw_hash_set algorithm_container memory)
set(${_pkg}_numeric_DEPENDENCIES int128)
set(${_pkg}_optional_DEPENDENCIES
bad_optional_access
base_internal
config
core_headers
memory
type_traits
utility)
set(${_pkg}_periodic_sampler_DEPENDENCIES core_headers exponential_biased)
set(${_pkg}_random_bit_gen_ref_DEPENDENCIES core_headers random_internal_distribution_caller
random_internal_fast_uniform_bits type_traits)
set(${_pkg}_random_distributions_DEPENDENCIES
base_internal
config
core_headers
random_internal_generate_real
random_internal_distribution_caller
random_internal_fast_uniform_bits
random_internal_fastmath
random_internal_iostream_state_saver
random_internal_traits
random_internal_uniform_helper
random_internal_wide_multiply
strings
type_traits)
set(${_pkg}_random_internal_distribution_caller_DEPENDENCIES config utility fast_type_id)
set(${_pkg}_random_internal_distribution_test_util_DEPENDENCIES config core_headers raw_logging_internal strings
str_format span)
set(${_pkg}_random_internal_fast_uniform_bits_DEPENDENCIES config)
set(${_pkg}_random_internal_fastmath_DEPENDENCIES bits)
set(${_pkg}_random_internal_generate_real_DEPENDENCIES bits random_internal_fastmath random_internal_traits type_traits)
set(${_pkg}_random_internal_iostream_state_saver_DEPENDENCIES int128 type_traits)
set(${_pkg}_random_internal_mock_helpers_DEPENDENCIES fast_type_id optional)
set(${_pkg}_random_internal_nonsecure_base_DEPENDENCIES
core_headers
optional
random_internal_pool_urbg
random_internal_salted_seed_seq
random_internal_seed_material
span
type_traits)
set(${_pkg}_random_internal_pcg_engine_DEPENDENCIES config int128 random_internal_fastmath
random_internal_iostream_state_saver type_traits)
set(${_pkg}_random_internal_platform_DEPENDENCIES config)
set(${_pkg}_random_internal_pool_urbg_DEPENDENCIES
base
config
core_headers
endian
random_internal_randen
random_internal_seed_material
random_internal_traits
random_seed_gen_exception
raw_logging_internal
span)
set(${_pkg}_random_internal_randen_DEPENDENCIES random_internal_platform random_internal_randen_hwaes
random_internal_randen_slow)
set(${_pkg}_random_internal_randen_engine_DEPENDENCIES random_internal_iostream_state_saver random_internal_randen
raw_logging_internal type_traits)
set(${_pkg}_random_internal_randen_hwaes_DEPENDENCIES random_internal_platform random_internal_randen_hwaes_impl config)
set(${_pkg}_random_internal_randen_hwaes_impl_DEPENDENCIES random_internal_platform config)
set(${_pkg}_random_internal_randen_slow_DEPENDENCIES random_internal_platform config)
set(${_pkg}_random_internal_salted_seed_seq_DEPENDENCIES inlined_vector optional span random_internal_seed_material
type_traits)
set(${_pkg}_random_internal_seed_material_DEPENDENCIES core_headers optional random_internal_fast_uniform_bits
raw_logging_internal span strings)
set(${_pkg}_random_internal_traits_DEPENDENCIES config)
set(${_pkg}_random_internal_uniform_helper_DEPENDENCIES config random_internal_traits type_traits)
set(${_pkg}_random_internal_wide_multiply_DEPENDENCIES bits config int128)
set(${_pkg}_random_random_DEPENDENCIES random_distributions random_internal_nonsecure_base random_internal_pcg_engine
random_internal_pool_urbg random_internal_randen_engine random_seed_sequences)
set(${_pkg}_random_seed_gen_exception_DEPENDENCIES config)
set(${_pkg}_random_seed_sequences_DEPENDENCIES
inlined_vector
random_internal_nonsecure_base
random_internal_pool_urbg
random_internal_salted_seed_seq
random_internal_seed_material
random_seed_gen_exception
span)
set(${_pkg}_raw_hash_map_DEPENDENCIES container_memory raw_hash_set throw_delegate)
set(${_pkg}_raw_hash_set_DEPENDENCIES
bits
compressed_tuple
config
container_common
container_memory
core_headers
endian
hash_policy_traits
hashtable_debug_hooks
have_sse
layout
memory
meta
optional
utility
hashtablez_sampler)
set(${_pkg}_raw_logging_internal_DEPENDENCIES atomic_hook config core_headers log_severity)
set(${_pkg}_scoped_set_env_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_span_DEPENDENCIES algorithm core_headers throw_delegate type_traits)
set(${_pkg}_spinlock_wait_DEPENDENCIES base_internal core_headers errno_saver)
set(${_pkg}_stacktrace_DEPENDENCIES debugging_internal config core_headers)
set(${_pkg}_status_DEPENDENCIES
atomic_hook
config
core_headers
raw_logging_internal
inlined_vector
stacktrace
symbolize
strings
cord
str_format
optional)
set(${_pkg}_statusor_DEPENDENCIES
status
core_headers
raw_logging_internal
type_traits
strings
utility
variant)
set(${_pkg}_str_format_DEPENDENCIES str_format_internal)
set(${_pkg}_str_format_internal_DEPENDENCIES
bits
strings
config
core_headers
type_traits
int128
span)
set(${_pkg}_strerror_DEPENDENCIES config core_headers errno_saver)
set(${_pkg}_strings_DEPENDENCIES
strings_internal
base
bits
config
core_headers
endian
int128
memory
raw_logging_internal
throw_delegate
type_traits)
set(${_pkg}_strings_internal_DEPENDENCIES config core_headers endian raw_logging_internal type_traits)
set(${_pkg}_symbolize_DEPENDENCIES
debugging_internal
demangle_internal
base
config
core_headers
dynamic_annotations
malloc_internal
raw_logging_internal
strings)
set(${_pkg}_synchronization_DEPENDENCIES
graphcycles_internal
kernel_timeout_internal
atomic_hook
base
base_internal
config
core_headers
dynamic_annotations
malloc_internal
raw_logging_internal
stacktrace
symbolize
time)
set(${_pkg}_synchronization_EXTERNAL_DEPENDENCIES Threads::Threads)
set(${_pkg}_throw_delegate_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_time_DEPENDENCIES
base
civil_time
core_headers
int128
raw_logging_internal
strings
time_zone)
set(${_pkg}_type_traits_DEPENDENCIES config)
set(${_pkg}_utility_DEPENDENCIES base_internal config type_traits)
set(${_pkg}_variant_DEPENDENCIES bad_variant_access base_internal config core_headers type_traits utility)

+ 527
- 0
cmake/modules/absl/20210324.cmake View File

@@ -0,0 +1,527 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

# Set names of each component of abseil-cpp
foreach(
comp
algorithm
algorithm_container
any
atomic_hook
bad_any_cast
bad_any_cast_impl
bad_optional_access
bad_variant_access
base
base_internal
bind_front
bits
btree
city
civil_time
cleanup
cleanup_internal
compare
compressed_tuple
config
container_common
container_memory
cord
core_headers
counting_allocator
debugging
debugging_internal
demangle_internal
dynamic_annotations
endian
errno_saver
examine_stack
exponential_biased
failure_signal_handler
fast_type_id
fixed_array
flags
flags_commandlineflag
flags_commandlineflag_internal
flags_config
flags_internal
flags_marshalling
flags_parse
flags_path_util
flags_private_handle_accessor
flags_program_name
flags_reflection
flags_usage
flags_usage_internal
flat_hash_map
flat_hash_set
function_ref
graphcycles_internal
hash
hash_function_defaults
hash_policy_traits
hashtable_debug
hashtable_debug_hooks
hashtablez_sampler
have_sse
inlined_vector
inlined_vector_internal
int128
kernel_timeout_internal
layout
leak_check
leak_check_disable
log_severity
malloc_internal
memory
meta
node_hash_map
node_hash_policy
node_hash_set
numeric
numeric_representation
optional
periodic_sampler
pretty_function
random_bit_gen_ref
random_distributions
random_internal_distribution_caller
random_internal_distribution_test_util
random_internal_fast_uniform_bits
random_internal_fastmath
random_internal_generate_real
random_internal_iostream_state_saver
random_internal_mock_helpers
random_internal_nonsecure_base
random_internal_pcg_engine
random_internal_platform
random_internal_pool_urbg
random_internal_randen
random_internal_randen_engine
random_internal_randen_hwaes
random_internal_randen_hwaes_impl
random_internal_randen_slow
random_internal_salted_seed_seq
random_internal_seed_material
random_internal_traits
random_internal_uniform_helper
random_internal_wide_multiply
random_random
random_seed_gen_exception
random_seed_sequences
raw_hash_map
raw_hash_set
raw_logging_internal
scoped_set_env
span
spinlock_wait
stacktrace
status
statusor
str_format
str_format_internal
strerror
strings
strings_internal
symbolize
synchronization
throw_delegate
time
time_zone
type_traits
utility
variant
wyhash)
set(${_pkg}_${comp}_NAMES absl_${comp})
endforeach()

set(${_pkg}_algorithm_DEPENDENCIES config)
set(${_pkg}_algorithm_container_DEPENDENCIES algorithm core_headers meta)
set(${_pkg}_any_DEPENDENCIES bad_any_cast config core_headers fast_type_id type_traits utility)
set(${_pkg}_atomic_hook_DEPENDENCIES config core_headers)
set(${_pkg}_bad_any_cast_DEPENDENCIES bad_any_cast_impl config)
set(${_pkg}_bad_any_cast_impl_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_bad_optional_access_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_bad_variant_access_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_base_DEPENDENCIES
atomic_hook
base_internal
config
core_headers
dynamic_annotations
log_severity
raw_logging_internal
spinlock_wait
type_traits)
set(${_pkg}_base_EXTERNAL_DEPENDENCIES Threads::Threads)
set(${_pkg}_base_internal_DEPENDENCIES config type_traits)
set(${_pkg}_bind_front_DEPENDENCIES base_internal compressed_tuple)
set(${_pkg}_bits_DEPENDENCIES core_headers)
set(${_pkg}_btree_DEPENDENCIES
container_common
compare
compressed_tuple
container_memory
cord
core_headers
layout
memory
strings
throw_delegate
type_traits
utility)
set(${_pkg}_city_DEPENDENCIES config core_headers endian)
set(${_pkg}_cleanup_DEPENDENCIES cleanup_internal config core_headers)
set(${_pkg}_cleanup_internal_DEPENDENCIES base_internal core_headers utility)
set(${_pkg}_compare_DEPENDENCIES core_headers type_traits)
set(${_pkg}_compressed_tuple_DEPENDENCIES utility)
set(${_pkg}_container_common_DEPENDENCIES type_traits)
set(${_pkg}_container_memory_DEPENDENCIES config memory type_traits utility)
set(${_pkg}_cord_DEPENDENCIES
base
base_internal
compressed_tuple
config
core_headers
endian
fixed_array
function_ref
inlined_vector
optional
raw_logging_internal
strings
strings_internal
throw_delegate
type_traits)
set(${_pkg}_core_headers_DEPENDENCIES config)
set(${_pkg}_counting_allocator_DEPENDENCIES config)
set(${_pkg}_debugging_DEPENDENCIES stacktrace leak_check)
set(${_pkg}_debugging_internal_DEPENDENCIES core_headers config dynamic_annotations errno_saver raw_logging_internal)
set(${_pkg}_demangle_internal_DEPENDENCIES base core_headers)
set(${_pkg}_dynamic_annotations_DEPENDENCIES config)
set(${_pkg}_endian_DEPENDENCIES base config core_headers)
set(${_pkg}_errno_saver_DEPENDENCIES config)
set(${_pkg}_examine_stack_DEPENDENCIES stacktrace symbolize config core_headers raw_logging_internal)
set(${_pkg}_exponential_biased_DEPENDENCIES config core_headers)
set(${_pkg}_failure_signal_handler_DEPENDENCIES
examine_stack
stacktrace
base
config
core_headers
errno_saver
raw_logging_internal)
set(${_pkg}_fast_type_id_DEPENDENCIES config)
set(${_pkg}_fixed_array_DEPENDENCIES
compressed_tuple
algorithm
config
core_headers
dynamic_annotations
throw_delegate
memory)
set(${_pkg}_flags_DEPENDENCIES
config
flags_commandlineflag
flags_config
flags_internal
flags_reflection
base
core_headers
strings)
set(${_pkg}_flags_commandlineflag_DEPENDENCIES config fast_type_id flags_commandlineflag_internal optional strings)
set(${_pkg}_flags_commandlineflag_internal_DEPENDENCIES config fast_type_id)
set(${_pkg}_flags_config_DEPENDENCIES config flags_path_util flags_program_name core_headers strings synchronization)
set(${_pkg}_flags_internal_DEPENDENCIES
base
config
flags_commandlineflag
flags_commandlineflag_internal
flags_config
flags_marshalling
synchronization
meta
utility)
set(${_pkg}_flags_marshalling_DEPENDENCIES config core_headers log_severity strings str_format)
set(${_pkg}_flags_parse_DEPENDENCIES
config
core_headers
flags_config
flags
flags_commandlineflag
flags_commandlineflag_internal
flags_internal
flags_private_handle_accessor
flags_program_name
flags_reflection
flags_usage
strings
synchronization)
set(${_pkg}_flags_path_util_DEPENDENCIES config strings)
set(${_pkg}_flags_private_handle_accessor_DEPENDENCIES config flags_commandlineflag flags_commandlineflag_internal
strings)
set(${_pkg}_flags_program_name_DEPENDENCIES config core_headers flags_path_util strings synchronization)
set(${_pkg}_flags_reflection_DEPENDENCIES
config
flags_commandlineflag
flags_private_handle_accessor
flags_config
strings
synchronization
flat_hash_map)
set(${_pkg}_flags_usage_DEPENDENCIES config core_headers flags_usage_internal strings synchronization)
set(${_pkg}_flags_usage_internal_DEPENDENCIES
config
flags_config
flags
flags_commandlineflag
flags_internal
flags_path_util
flags_private_handle_accessor
flags_program_name
flags_reflection
strings
synchronization)
set(${_pkg}_flat_hash_map_DEPENDENCIES container_memory hash_function_defaults raw_hash_map algorithm_container memory)
set(${_pkg}_flat_hash_set_DEPENDENCIES container_memory hash_function_defaults raw_hash_set algorithm_container
core_headers memory)
set(${_pkg}_function_ref_DEPENDENCIES base_internal meta)
set(${_pkg}_graphcycles_internal_DEPENDENCIES base base_internal config core_headers malloc_internal
raw_logging_internal)
set(${_pkg}_hash_DEPENDENCIES
city
config
core_headers
endian
fixed_array
meta
int128
strings
optional
variant
utility
wyhash)
set(${_pkg}_hash_function_defaults_DEPENDENCIES config cord hash strings)
set(${_pkg}_hash_policy_traits_DEPENDENCIES meta)
set(${_pkg}_hashtable_debug_DEPENDENCIES hashtable_debug_hooks)
set(${_pkg}_hashtable_debug_hooks_DEPENDENCIES config)
set(${_pkg}_hashtablez_sampler_DEPENDENCIES base exponential_biased have_sse synchronization)
set(${_pkg}_inlined_vector_DEPENDENCIES algorithm core_headers inlined_vector_internal throw_delegate memory)
set(${_pkg}_inlined_vector_internal_DEPENDENCIES compressed_tuple core_headers memory span type_traits)
set(${_pkg}_int128_DEPENDENCIES config core_headers bits)
set(${_pkg}_kernel_timeout_internal_DEPENDENCIES core_headers raw_logging_internal time)
set(${_pkg}_layout_DEPENDENCIES config core_headers meta strings span utility)
set(${_pkg}_leak_check_DEPENDENCIES config core_headers)
set(${_pkg}_log_severity_DEPENDENCIES core_headers)
set(${_pkg}_malloc_internal_DEPENDENCIES base base_internal config core_headers dynamic_annotations
raw_logging_internal)
set(${_pkg}_malloc_internal_EXTERNAL_DEPENDENCIES Threads::Threads)
set(${_pkg}_memory_DEPENDENCIES core_headers meta)
set(${_pkg}_meta_DEPENDENCIES type_traits)
set(${_pkg}_node_hash_map_DEPENDENCIES container_memory hash_function_defaults node_hash_policy raw_hash_map
algorithm_container memory)
set(${_pkg}_node_hash_policy_DEPENDENCIES config)
set(${_pkg}_node_hash_set_DEPENDENCIES hash_function_defaults node_hash_policy raw_hash_set algorithm_container memory)
set(${_pkg}_numeric_DEPENDENCIES int128)
set(${_pkg}_numeric_representation_DEPENDENCIES config)
set(${_pkg}_optional_DEPENDENCIES
bad_optional_access
base_internal
config
core_headers
memory
type_traits
utility)
set(${_pkg}_periodic_sampler_DEPENDENCIES core_headers exponential_biased)
set(${_pkg}_random_bit_gen_ref_DEPENDENCIES core_headers random_internal_distribution_caller
random_internal_fast_uniform_bits type_traits)
set(${_pkg}_random_distributions_DEPENDENCIES
base_internal
config
core_headers
random_internal_generate_real
random_internal_distribution_caller
random_internal_fast_uniform_bits
random_internal_fastmath
random_internal_iostream_state_saver
random_internal_traits
random_internal_uniform_helper
random_internal_wide_multiply
strings
type_traits)
set(${_pkg}_random_internal_distribution_caller_DEPENDENCIES config utility fast_type_id)
set(${_pkg}_random_internal_distribution_test_util_DEPENDENCIES config core_headers raw_logging_internal strings
str_format span)
set(${_pkg}_random_internal_fast_uniform_bits_DEPENDENCIES config)
set(${_pkg}_random_internal_fastmath_DEPENDENCIES bits)
set(${_pkg}_random_internal_generate_real_DEPENDENCIES bits random_internal_fastmath random_internal_traits type_traits)
set(${_pkg}_random_internal_iostream_state_saver_DEPENDENCIES int128 type_traits)
set(${_pkg}_random_internal_mock_helpers_DEPENDENCIES fast_type_id optional)
set(${_pkg}_random_internal_nonsecure_base_DEPENDENCIES
core_headers
optional
random_internal_pool_urbg
random_internal_salted_seed_seq
random_internal_seed_material
span
type_traits)
set(${_pkg}_random_internal_pcg_engine_DEPENDENCIES config int128 random_internal_fastmath
random_internal_iostream_state_saver type_traits)
set(${_pkg}_random_internal_platform_DEPENDENCIES config)
set(${_pkg}_random_internal_pool_urbg_DEPENDENCIES
base
config
core_headers
endian
random_internal_randen
random_internal_seed_material
random_internal_traits
random_seed_gen_exception
raw_logging_internal
span)
set(${_pkg}_random_internal_randen_DEPENDENCIES random_internal_platform random_internal_randen_hwaes
random_internal_randen_slow)
set(${_pkg}_random_internal_randen_engine_DEPENDENCIES endian random_internal_iostream_state_saver
random_internal_randen raw_logging_internal type_traits)
set(${_pkg}_random_internal_randen_hwaes_DEPENDENCIES random_internal_platform random_internal_randen_hwaes_impl config)
set(${_pkg}_random_internal_randen_hwaes_impl_DEPENDENCIES random_internal_platform config)
set(${_pkg}_random_internal_randen_slow_DEPENDENCIES random_internal_platform config)
set(${_pkg}_random_internal_salted_seed_seq_DEPENDENCIES inlined_vector optional span random_internal_seed_material
type_traits)
set(${_pkg}_random_internal_seed_material_DEPENDENCIES core_headers optional random_internal_fast_uniform_bits
raw_logging_internal span strings)
set(${_pkg}_random_internal_traits_DEPENDENCIES config)
set(${_pkg}_random_internal_uniform_helper_DEPENDENCIES config random_internal_traits type_traits)
set(${_pkg}_random_internal_wide_multiply_DEPENDENCIES bits config int128)
set(${_pkg}_random_random_DEPENDENCIES random_distributions random_internal_nonsecure_base random_internal_pcg_engine
random_internal_pool_urbg random_internal_randen_engine random_seed_sequences)
set(${_pkg}_random_seed_gen_exception_DEPENDENCIES config)
set(${_pkg}_random_seed_sequences_DEPENDENCIES
inlined_vector
random_internal_nonsecure_base
random_internal_pool_urbg
random_internal_salted_seed_seq
random_internal_seed_material
random_seed_gen_exception
span)
set(${_pkg}_raw_hash_map_DEPENDENCIES container_memory raw_hash_set throw_delegate)
set(${_pkg}_raw_hash_set_DEPENDENCIES
bits
compressed_tuple
config
container_common
container_memory
core_headers
endian
hash_policy_traits
hashtable_debug_hooks
have_sse
layout
memory
meta
optional
utility
hashtablez_sampler)
set(${_pkg}_raw_logging_internal_DEPENDENCIES atomic_hook config core_headers log_severity)
set(${_pkg}_scoped_set_env_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_span_DEPENDENCIES algorithm core_headers throw_delegate type_traits)
set(${_pkg}_spinlock_wait_DEPENDENCIES base_internal core_headers errno_saver)
set(${_pkg}_stacktrace_DEPENDENCIES debugging_internal config core_headers)
set(${_pkg}_status_DEPENDENCIES
atomic_hook
config
core_headers
raw_logging_internal
inlined_vector
stacktrace
symbolize
strings
cord
str_format
optional)
set(${_pkg}_statusor_DEPENDENCIES
status
core_headers
raw_logging_internal
type_traits
strings
utility
variant)
set(${_pkg}_str_format_DEPENDENCIES str_format_internal)
set(${_pkg}_str_format_internal_DEPENDENCIES
bits
strings
config
core_headers
numeric_representation
type_traits
int128
span)
set(${_pkg}_strerror_DEPENDENCIES config core_headers errno_saver)
set(${_pkg}_strings_DEPENDENCIES
strings_internal
base
bits
config
core_headers
endian
int128
memory
raw_logging_internal
throw_delegate
type_traits)
set(${_pkg}_strings_internal_DEPENDENCIES config core_headers endian raw_logging_internal type_traits)
set(${_pkg}_symbolize_DEPENDENCIES
debugging_internal
demangle_internal
base
config
core_headers
dynamic_annotations
malloc_internal
raw_logging_internal
strings)
set(${_pkg}_synchronization_DEPENDENCIES
graphcycles_internal
kernel_timeout_internal
atomic_hook
base
base_internal
config
core_headers
dynamic_annotations
malloc_internal
raw_logging_internal
stacktrace
symbolize
time)
set(${_pkg}_synchronization_EXTERNAL_DEPENDENCIES Threads::Threads)
set(${_pkg}_throw_delegate_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_time_DEPENDENCIES
base
civil_time
core_headers
int128
raw_logging_internal
strings
time_zone)
set(${_pkg}_time_zone_DEPENDENCIES $<$<PLATFORM_ID:Darwin>:>)
set(${_pkg}_type_traits_DEPENDENCIES config)
set(${_pkg}_utility_DEPENDENCIES base_internal config type_traits)
set(${_pkg}_variant_DEPENDENCIES bad_variant_access base_internal config core_headers type_traits utility)
set(${_pkg}_wyhash_DEPENDENCIES config endian int128)

+ 571
- 0
cmake/modules/absl/20211102.cmake View File

@@ -0,0 +1,571 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

# Set names of each component of abseil-cpp
foreach(
comp
algorithm
algorithm_container
any
atomic_hook
bad_any_cast
bad_any_cast_impl
bad_optional_access
bad_variant_access
base
base_internal
bind_front
bits
btree
city
civil_time
cleanup
cleanup_internal
compare
compressed_tuple
config
container_common
container_memory
cord
cord_internal
cordz_functions
cordz_handle
cordz_info
cordz_sample_token
cordz_statistics
cordz_update_scope
cordz_update_tracker
core_headers
counting_allocator
debugging
debugging_internal
demangle_internal
dynamic_annotations
endian
errno_saver
examine_stack
exponential_biased
failure_signal_handler
fast_type_id
fixed_array
flags
flags_commandlineflag
flags_commandlineflag_internal
flags_config
flags_internal
flags_marshalling
flags_parse
flags_path_util
flags_private_handle_accessor
flags_program_name
flags_reflection
flags_usage
flags_usage_internal
flat_hash_map
flat_hash_set
function_ref
graphcycles_internal
hash
hash_function_defaults
hash_policy_traits
hashtable_debug
hashtable_debug_hooks
hashtablez_sampler
have_sse
inlined_vector
inlined_vector_internal
int128
kernel_timeout_internal
layout
leak_check
leak_check_disable
log_severity
low_level_hash
malloc_internal
memory
meta
node_hash_map
node_hash_policy
node_hash_set
numeric
numeric_representation
optional
periodic_sampler
pretty_function
random_bit_gen_ref
random_distributions
random_internal_distribution_caller
random_internal_distribution_test_util
random_internal_fast_uniform_bits
random_internal_fastmath
random_internal_generate_real
random_internal_iostream_state_saver
random_internal_mock_helpers
random_internal_nonsecure_base
random_internal_pcg_engine
random_internal_platform
random_internal_pool_urbg
random_internal_randen
random_internal_randen_engine
random_internal_randen_hwaes
random_internal_randen_hwaes_impl
random_internal_randen_slow
random_internal_salted_seed_seq
random_internal_seed_material
random_internal_traits
random_internal_uniform_helper
random_internal_wide_multiply
random_random
random_seed_gen_exception
random_seed_sequences
raw_hash_map
raw_hash_set
raw_logging_internal
sample_recorder
scoped_set_env
span
spinlock_wait
stacktrace
status
statusor
str_format
str_format_internal
strerror
strings
strings_internal
symbolize
synchronization
throw_delegate
time
time_zone
type_traits
utility
variant)
set(${_pkg}_${comp}_NAMES absl_${comp})
endforeach()

set(${_pkg}_algorithm_DEPENDENCIES config)
set(${_pkg}_algorithm_container_DEPENDENCIES algorithm core_headers meta)
set(${_pkg}_any_DEPENDENCIES bad_any_cast config core_headers fast_type_id type_traits utility)
set(${_pkg}_atomic_hook_DEPENDENCIES config core_headers)
set(${_pkg}_bad_any_cast_DEPENDENCIES bad_any_cast_impl config)
set(${_pkg}_bad_any_cast_impl_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_bad_optional_access_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_bad_variant_access_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_base_DEPENDENCIES
atomic_hook
base_internal
config
core_headers
dynamic_annotations
log_severity
raw_logging_internal
spinlock_wait
type_traits)
set(${_pkg}_base_EXTERNAL_DEPENDENCIES Threads::Threads)
set(${_pkg}_base_internal_DEPENDENCIES config type_traits)
set(${_pkg}_bind_front_DEPENDENCIES base_internal compressed_tuple)
set(${_pkg}_bits_DEPENDENCIES core_headers)
set(${_pkg}_btree_DEPENDENCIES
container_common
compare
compressed_tuple
container_memory
cord
core_headers
layout
memory
strings
throw_delegate
type_traits
utility)
set(${_pkg}_city_DEPENDENCIES config core_headers endian)
set(${_pkg}_cleanup_DEPENDENCIES cleanup_internal config core_headers)
set(${_pkg}_cleanup_internal_DEPENDENCIES base_internal core_headers utility)
set(${_pkg}_compare_DEPENDENCIES core_headers type_traits)
set(${_pkg}_compressed_tuple_DEPENDENCIES utility)
set(${_pkg}_container_common_DEPENDENCIES type_traits)
set(${_pkg}_container_memory_DEPENDENCIES config memory type_traits utility)
set(${_pkg}_cord_DEPENDENCIES
base
config
cord_internal
cordz_functions
cordz_info
cordz_update_scope
cordz_update_tracker
core_headers
endian
fixed_array
function_ref
inlined_vector
optional
raw_logging_internal
strings
type_traits)
set(${_pkg}_cord_internal_DEPENDENCIES
base_internal
compressed_tuple
config
core_headers
endian
inlined_vector
layout
raw_logging_internal
strings
throw_delegate
type_traits)
set(${_pkg}_cordz_functions_DEPENDENCIES config core_headers exponential_biased raw_logging_internal)
set(${_pkg}_cordz_handle_DEPENDENCIES base config raw_logging_internal synchronization)
set(${_pkg}_cordz_info_DEPENDENCIES
base
config
cord_internal
cordz_functions
cordz_handle
cordz_statistics
cordz_update_tracker
core_headers
inlined_vector
span
raw_logging_internal
stacktrace
synchronization)
set(${_pkg}_cordz_sample_token_DEPENDENCIES config cordz_handle cordz_info)
set(${_pkg}_cordz_statistics_DEPENDENCIES config core_headers cordz_update_tracker synchronization)
set(${_pkg}_cordz_update_scope_DEPENDENCIES config cord_internal cordz_info cordz_update_tracker core_headers)
set(${_pkg}_cordz_update_tracker_DEPENDENCIES config)
set(${_pkg}_core_headers_DEPENDENCIES config)
set(${_pkg}_counting_allocator_DEPENDENCIES config)
set(${_pkg}_debugging_DEPENDENCIES stacktrace leak_check)
set(${_pkg}_debugging_internal_DEPENDENCIES core_headers config dynamic_annotations errno_saver raw_logging_internal)
set(${_pkg}_demangle_internal_DEPENDENCIES base core_headers)
set(${_pkg}_dynamic_annotations_DEPENDENCIES config)
set(${_pkg}_endian_DEPENDENCIES base config core_headers)
set(${_pkg}_errno_saver_DEPENDENCIES config)
set(${_pkg}_examine_stack_DEPENDENCIES stacktrace symbolize config core_headers raw_logging_internal)
set(${_pkg}_exponential_biased_DEPENDENCIES config core_headers)
set(${_pkg}_failure_signal_handler_DEPENDENCIES
examine_stack
stacktrace
base
config
core_headers
errno_saver
raw_logging_internal)
set(${_pkg}_fast_type_id_DEPENDENCIES config)
set(${_pkg}_fixed_array_DEPENDENCIES
compressed_tuple
algorithm
config
core_headers
dynamic_annotations
throw_delegate
memory)
set(${_pkg}_flags_DEPENDENCIES
config
flags_commandlineflag
flags_config
flags_internal
flags_reflection
base
core_headers
strings)
set(${_pkg}_flags_commandlineflag_DEPENDENCIES config fast_type_id flags_commandlineflag_internal optional strings)
set(${_pkg}_flags_commandlineflag_internal_DEPENDENCIES config fast_type_id)
set(${_pkg}_flags_config_DEPENDENCIES config flags_path_util flags_program_name core_headers strings synchronization)
set(${_pkg}_flags_internal_DEPENDENCIES
base
config
flags_commandlineflag
flags_commandlineflag_internal
flags_config
flags_marshalling
synchronization
meta
utility)
set(${_pkg}_flags_marshalling_DEPENDENCIES config core_headers log_severity strings str_format)
set(${_pkg}_flags_parse_DEPENDENCIES
config
core_headers
flags_config
flags
flags_commandlineflag
flags_commandlineflag_internal
flags_internal
flags_private_handle_accessor
flags_program_name
flags_reflection
flags_usage
strings
synchronization)
set(${_pkg}_flags_path_util_DEPENDENCIES config strings)
set(${_pkg}_flags_private_handle_accessor_DEPENDENCIES config flags_commandlineflag flags_commandlineflag_internal
strings)
set(${_pkg}_flags_program_name_DEPENDENCIES config core_headers flags_path_util strings synchronization)
set(${_pkg}_flags_reflection_DEPENDENCIES
config
flags_commandlineflag
flags_private_handle_accessor
flags_config
strings
synchronization
flat_hash_map)
set(${_pkg}_flags_usage_DEPENDENCIES config core_headers flags_usage_internal strings synchronization)
set(${_pkg}_flags_usage_internal_DEPENDENCIES
config
flags_config
flags
flags_commandlineflag
flags_internal
flags_path_util
flags_private_handle_accessor
flags_program_name
flags_reflection
flat_hash_map
strings
synchronization)
set(${_pkg}_flat_hash_map_DEPENDENCIES container_memory hash_function_defaults raw_hash_map algorithm_container memory)
set(${_pkg}_flat_hash_set_DEPENDENCIES container_memory hash_function_defaults raw_hash_set algorithm_container
core_headers memory)
set(${_pkg}_function_ref_DEPENDENCIES base_internal core_headers meta)
set(${_pkg}_graphcycles_internal_DEPENDENCIES base base_internal config core_headers malloc_internal
raw_logging_internal)
set(${_pkg}_hash_DEPENDENCIES
city
config
core_headers
endian
fixed_array
meta
int128
strings
optional
variant
utility
low_level_hash)
set(${_pkg}_hash_function_defaults_DEPENDENCIES config cord hash strings)
set(${_pkg}_hash_policy_traits_DEPENDENCIES meta)
set(${_pkg}_hashtable_debug_DEPENDENCIES hashtable_debug_hooks)
set(${_pkg}_hashtable_debug_hooks_DEPENDENCIES config)
set(${_pkg}_hashtablez_sampler_DEPENDENCIES base exponential_biased have_sse sample_recorder synchronization)
set(${_pkg}_inlined_vector_DEPENDENCIES algorithm core_headers inlined_vector_internal throw_delegate memory)
set(${_pkg}_inlined_vector_internal_DEPENDENCIES compressed_tuple core_headers memory span type_traits)
set(${_pkg}_int128_DEPENDENCIES config core_headers bits)
set(${_pkg}_kernel_timeout_internal_DEPENDENCIES core_headers raw_logging_internal time)
set(${_pkg}_layout_DEPENDENCIES config core_headers meta strings span utility)
set(${_pkg}_leak_check_DEPENDENCIES config core_headers)
set(${_pkg}_log_severity_DEPENDENCIES core_headers)
set(${_pkg}_low_level_hash_DEPENDENCIES bits config endian int128)
set(${_pkg}_malloc_internal_DEPENDENCIES base base_internal config core_headers dynamic_annotations
raw_logging_internal)
set(${_pkg}_malloc_internal_EXTERNAL_DEPENDENCIES Threads::Threads)
set(${_pkg}_memory_DEPENDENCIES core_headers meta)
set(${_pkg}_meta_DEPENDENCIES type_traits)
set(${_pkg}_node_hash_map_DEPENDENCIES container_memory hash_function_defaults node_hash_policy raw_hash_map
algorithm_container memory)
set(${_pkg}_node_hash_policy_DEPENDENCIES config)
set(${_pkg}_node_hash_set_DEPENDENCIES hash_function_defaults node_hash_policy raw_hash_set algorithm_container memory)
set(${_pkg}_numeric_DEPENDENCIES int128)
set(${_pkg}_numeric_representation_DEPENDENCIES config)
set(${_pkg}_optional_DEPENDENCIES
bad_optional_access
base_internal
config
core_headers
memory
type_traits
utility)
set(${_pkg}_periodic_sampler_DEPENDENCIES core_headers exponential_biased)
set(${_pkg}_random_bit_gen_ref_DEPENDENCIES core_headers random_internal_distribution_caller
random_internal_fast_uniform_bits type_traits)
set(${_pkg}_random_distributions_DEPENDENCIES
base_internal
config
core_headers
random_internal_generate_real
random_internal_distribution_caller
random_internal_fast_uniform_bits
random_internal_fastmath
random_internal_iostream_state_saver
random_internal_traits
random_internal_uniform_helper
random_internal_wide_multiply
strings
type_traits)
set(${_pkg}_random_internal_distribution_caller_DEPENDENCIES config utility fast_type_id)
set(${_pkg}_random_internal_distribution_test_util_DEPENDENCIES config core_headers raw_logging_internal strings
str_format span)
set(${_pkg}_random_internal_fast_uniform_bits_DEPENDENCIES config)
set(${_pkg}_random_internal_fastmath_DEPENDENCIES bits)
set(${_pkg}_random_internal_generate_real_DEPENDENCIES bits random_internal_fastmath random_internal_traits type_traits)
set(${_pkg}_random_internal_iostream_state_saver_DEPENDENCIES int128 type_traits)
set(${_pkg}_random_internal_mock_helpers_DEPENDENCIES fast_type_id optional)
set(${_pkg}_random_internal_nonsecure_base_DEPENDENCIES
core_headers
optional
random_internal_pool_urbg
random_internal_salted_seed_seq
random_internal_seed_material
span
type_traits)
set(${_pkg}_random_internal_pcg_engine_DEPENDENCIES config int128 random_internal_fastmath
random_internal_iostream_state_saver type_traits)
set(${_pkg}_random_internal_platform_DEPENDENCIES config)
set(${_pkg}_random_internal_pool_urbg_DEPENDENCIES
base
config
core_headers
endian
random_internal_randen
random_internal_seed_material
random_internal_traits
random_seed_gen_exception
raw_logging_internal
span)
set(${_pkg}_random_internal_randen_DEPENDENCIES random_internal_platform random_internal_randen_hwaes
random_internal_randen_slow)
set(${_pkg}_random_internal_randen_engine_DEPENDENCIES endian random_internal_iostream_state_saver
random_internal_randen raw_logging_internal type_traits)
set(${_pkg}_random_internal_randen_hwaes_DEPENDENCIES random_internal_platform random_internal_randen_hwaes_impl config)
set(${_pkg}_random_internal_randen_hwaes_impl_DEPENDENCIES random_internal_platform config)
set(${_pkg}_random_internal_randen_slow_DEPENDENCIES random_internal_platform config)
set(${_pkg}_random_internal_salted_seed_seq_DEPENDENCIES inlined_vector optional span random_internal_seed_material
type_traits)
set(${_pkg}_random_internal_seed_material_DEPENDENCIES core_headers optional random_internal_fast_uniform_bits
raw_logging_internal span strings)
set(${_pkg}_random_internal_traits_DEPENDENCIES config)
set(${_pkg}_random_internal_uniform_helper_DEPENDENCIES config random_internal_traits type_traits)
set(${_pkg}_random_internal_wide_multiply_DEPENDENCIES bits config int128)
set(${_pkg}_random_random_DEPENDENCIES random_distributions random_internal_nonsecure_base random_internal_pcg_engine
random_internal_pool_urbg random_internal_randen_engine random_seed_sequences)
set(${_pkg}_random_seed_gen_exception_DEPENDENCIES config)
set(${_pkg}_random_seed_sequences_DEPENDENCIES
inlined_vector
random_internal_nonsecure_base
random_internal_pool_urbg
random_internal_salted_seed_seq
random_internal_seed_material
random_seed_gen_exception
span)
set(${_pkg}_raw_hash_map_DEPENDENCIES container_memory raw_hash_set throw_delegate)
set(${_pkg}_raw_hash_set_DEPENDENCIES
bits
compressed_tuple
config
container_common
container_memory
core_headers
endian
hash_policy_traits
hashtable_debug_hooks
have_sse
memory
meta
optional
utility
hashtablez_sampler)
set(${_pkg}_raw_logging_internal_DEPENDENCIES atomic_hook config core_headers log_severity)
set(${_pkg}_sample_recorder_DEPENDENCIES base synchronization)
set(${_pkg}_scoped_set_env_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_span_DEPENDENCIES algorithm core_headers throw_delegate type_traits)
set(${_pkg}_spinlock_wait_DEPENDENCIES base_internal core_headers errno_saver)
set(${_pkg}_stacktrace_DEPENDENCIES debugging_internal config core_headers)
set(${_pkg}_status_DEPENDENCIES
atomic_hook
config
core_headers
function_ref
raw_logging_internal
inlined_vector
stacktrace
symbolize
strings
cord
str_format
optional)
set(${_pkg}_statusor_DEPENDENCIES
base
status
core_headers
raw_logging_internal
type_traits
strings
utility
variant)
set(${_pkg}_str_format_DEPENDENCIES str_format_internal)
set(${_pkg}_str_format_internal_DEPENDENCIES
bits
strings
config
core_headers
numeric_representation
type_traits
int128
span)
set(${_pkg}_strerror_DEPENDENCIES config core_headers errno_saver)
set(${_pkg}_strings_DEPENDENCIES
strings_internal
base
bits
config
core_headers
endian
int128
memory
raw_logging_internal
throw_delegate
type_traits)
set(${_pkg}_strings_internal_DEPENDENCIES config core_headers endian raw_logging_internal type_traits)
set(${_pkg}_symbolize_DEPENDENCIES
debugging_internal
demangle_internal
base
config
core_headers
dynamic_annotations
malloc_internal
raw_logging_internal
strings)
set(${_pkg}_synchronization_DEPENDENCIES
graphcycles_internal
kernel_timeout_internal
atomic_hook
base
base_internal
config
core_headers
dynamic_annotations
malloc_internal
raw_logging_internal
stacktrace
symbolize
time)
set(${_pkg}_synchronization_EXTERNAL_DEPENDENCIES Threads::Threads)
set(${_pkg}_throw_delegate_DEPENDENCIES config raw_logging_internal)
set(${_pkg}_time_DEPENDENCIES
base
civil_time
core_headers
int128
raw_logging_internal
strings
time_zone)
set(${_pkg}_type_traits_DEPENDENCIES config)
set(${_pkg}_utility_DEPENDENCIES base_internal config type_traits)
set(${_pkg}_variant_DEPENDENCIES bad_variant_access base_internal config core_headers type_traits utility)

+ 599
- 0
cmake/modules/opencv/4.0.cmake View File

@@ -0,0 +1,599 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

if(NOT "${CMAKE_CUDA_COMPILER}" STREQUAL "")
set(_with_cuda TRUE)
else()
set(_with_cuda FALSE)
endif()

set(_comps
alphamat
aruco
barcode
bgsegm
bioinspired
calib3d
ccalib
core
correspondence
cudaarithm
cudabgsegm
cudacodec
cudafeatures2d
cudafilters
cudaimgproc
cudalegacy
cudaobjdetect
cudaoptflow
cudastereo
cudawarping
cudev
cvv
datasets
dnn
dnn_objdetect
dnn_superres
dpm
face
features2d
flann
freetype
fuzzy
gapi
hdf
hfs
highgui
img_hash
imgcodecs
imgproc
intensity_transform
line_descriptor
mcc
ml
multiview
numeric
objdetect
optflow
ovis
phase_unwrapping
photo
plot
quality
rapid
reg
rgbd
saliency
sfm
shape
simple_pipeline
stereo
stitching
structured_light
superres
surface_matching
text
tracking
video
videoio
videostab
viz
wechat_qrcode
xfeatures2d
ximgproc
xobjdetect
xphoto)

# Set names of each component of OpenCV 4.0
foreach(comp ${_comps})
set(${_pkg}_${comp}_NAMES opencv_${comp} opencv_${comp}401 opencv_${comp}400)
endforeach()

set(${_pkg}_alphamat_DEPENDENCIES core cudev imgproc)
set(${_pkg}_aruco_DEPENDENCIES
calib3d
core
cudev
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_barcode_DEPENDENCIES core cudev dnn imgproc)
set(${_pkg}_bgsegm_DEPENDENCIES
calib3d
core
cudev
features2d
flann
highgui
imgcodecs
imgproc
video
videoio)
set(${_pkg}_bioinspired_DEPENDENCIES core cudev highgui imgcodecs imgproc videoio)
set(${_pkg}_calib3d_DEPENDENCIES
core
cudev
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_ccalib_DEPENDENCIES
calib3d
core
cudev
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_core_DEPENDENCIES cudev)
set(${_pkg}_cudaarithm_DEPENDENCIES core cudev)
set(${_pkg}_cudabgsegm_DEPENDENCIES
calib3d
core
cudev
features2d
flann
highgui
imgcodecs
imgproc
video
videoio)
set(${_pkg}_cudacodec_DEPENDENCIES core cudev imgcodecs imgproc videoio)
set(${_pkg}_cudafeatures2d_DEPENDENCIES
core
cudaarithm
cudafilters
cudawarping
cudev
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_cudafilters_DEPENDENCIES core cudaarithm cudev imgproc)
set(${_pkg}_cudaimgproc_DEPENDENCIES core cudaarithm cudafilters cudev imgproc)
set(${_pkg}_cudalegacy_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
cudev
features2d
flann
highgui
imgcodecs
imgproc
objdetect
video
videoio)
set(${_pkg}_cudaobjdetect_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudawarping
cudev
features2d
flann
highgui
imgcodecs
imgproc
objdetect
video
videoio)
set(${_pkg}_cudaoptflow_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudawarping
cudev
features2d
flann
highgui
imgcodecs
imgproc
objdetect
optflow
video
videoio
ximgproc)
set(${_pkg}_cudastereo_DEPENDENCIES
calib3d
core
cudev
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_cudawarping_DEPENDENCIES core cudev imgproc)
set(${_pkg}_cvv_DEPENDENCIES
core
cudev
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_datasets_DEPENDENCIES
core
cudev
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
text
videoio)
set(${_pkg}_dnn_DEPENDENCIES core cudev imgproc)
set(${_pkg}_dnn_objdetect_DEPENDENCIES
core
cudev
dnn
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_dnn_superres_DEPENDENCIES core cudev dnn imgproc ml quality)
set(${_pkg}_dpm_DEPENDENCIES
calib3d
core
cudev
features2d
flann
highgui
imgcodecs
imgproc
objdetect
videoio)
set(${_pkg}_face_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
objdetect
photo
videoio)
if(_with_cuda)
list(APPEND ${_pkg}_face_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()
set(${_pkg}_features2d_DEPENDENCIES core flann highgui imgcodecs imgproc videoio)
set(${_pkg}_flann_DEPENDENCIES core)
set(${_pkg}_freetype_DEPENDENCIES core imgproc)
set(${_pkg}_fuzzy_DEPENDENCIES core imgproc)
set(${_pkg}_gapi_DEPENDENCIES core imgproc)
set(${_pkg}_hdf_DEPENDENCIES core)
set(${_pkg}_hfs_DEPENDENCIES core imgproc)
set(${_pkg}_highgui_DEPENDENCIES core imgcodecs imgproc videoio)
set(${_pkg}_img_hash_DEPENDENCIES core imgproc)
set(${_pkg}_imgcodecs_DEPENDENCIES core imgproc)
set(${_pkg}_imgproc_DEPENDENCIES core)
set(${_pkg}_intensity_transform_DEPENDENCIES core imgproc)
set(${_pkg}_line_descriptor_DEPENDENCIES
core
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_mcc_DEPENDENCIES
calib3d
core
dnn
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_ml_DEPENDENCIES core)
set(${_pkg}_objdetect_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_optflow_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
video
videoio
ximgproc)
set(${_pkg}_ovis_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_phase_unwrapping_DEPENDENCIES core imgproc)
set(${_pkg}_photo_DEPENDENCIES core imgproc)
if(_with_cuda)
list(APPEND ${_pkg}_photo_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()
set(${_pkg}_plot_DEPENDENCIES core imgproc)
set(${_pkg}_quality_DEPENDENCIES core imgproc ml)
set(${_pkg}_rapid_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_reg_DEPENDENCIES core imgproc)
set(${_pkg}_rgbd_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
videoio
viz)
set(${_pkg}_saliency_DEPENDENCIES
core
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_sfm_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
ml
shape
videoio
xfeatures2d)
if(_with_cuda)
list(APPEND ${_pkg}_sfm_DEPENDENCIES cudaarithm)
endif()
set(${_pkg}_shape_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_stereo_DEPENDENCIES
calib3d
core
datasets
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
plot
text
tracking
video
videoio)
set(${_pkg}_stitching_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
ml
objdetect
shape
video
videoio
xfeatures2d)
if(_with_cuda)
list(
APPEND
${_pkg}_stitching_DEPENDENCIES
cudaarithm
cudafeatures2d
cudafilters
cudaimgproc
cudalegacy
cudawarping)
endif()
set(${_pkg}_structured_light_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
phase_unwrapping
videoio
viz)
set(${_pkg}_superres_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
objdetect
optflow
video
videoio
ximgproc)
if(_with_cuda)
list(
APPEND
${_pkg}_superres_DEPENDENCIES
cudaarithm
cudacodec
cudafilters
cudaimgproc
cudalegacy
cudaoptflow
cudawarping)
endif()
set(${_pkg}_surface_matching_DEPENDENCIES core flann)
set(${_pkg}_text_DEPENDENCIES
core
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
videoio)
set(${_pkg}_tracking_DEPENDENCIES
calib3d
core
datasets
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
plot
text
video
videoio)
set(${_pkg}_video_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_videoio_DEPENDENCIES core imgcodecs imgproc)
set(${_pkg}_videostab_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
objdetect
optflow
photo
video
videoio
ximgproc)
if(_with_cuda)
list(
APPEND
${_pkg}_videostab_DEPENDENCIES
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudaoptflow
cudawarping)
endif()

set(${_pkg}_viz_DEPENDENCIES core)
set(${_pkg}_wechat_qrcode_DEPENDENCIES core dnn imgproc)
set(${_pkg}_xfeatures2d_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
ml
shape
videoio)
if(_with_cuda)
list(APPEND ${_pkg}_xfeatures2d_DEPENDENCIES cudaarithm)
endif()
set(${_pkg}_ximgproc_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
video
videoio)
set(${_pkg}_xobjdetect_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
objdetect
videoio)
set(${_pkg}_xphoto_DEPENDENCIES core imgproc photo)
if(_with_cuda)
list(APPEND ${_pkg}_xphoto_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()

if(_with_cuda)
foreach(comp ${_comps})
list(PREPEND ${_pkg}_${comp}_NAMES cudev)
endforeach()
endif()

+ 414
- 0
cmake/modules/opencv/4.1.cmake View File

@@ -0,0 +1,414 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

if(NOT "${CMAKE_CUDA_COMPILER}" STREQUAL "")
set(_with_cuda TRUE)
else()
set(_with_cuda FALSE)
endif()

set(_comps
alphamat
aruco
barcode
bgsegm
bioinspired
calib3d
ccalib
core
correspondence
cudaarithm
cudabgsegm
cudacodec
cudafeatures2d
cudafilters
cudaimgproc
cudalegacy
cudaobjdetect
cudaoptflow
cudastereo
cudawarping
cudev
cvv
datasets
dnn
dnn_objdetect
dnn_superres
dpm
face
features2d
flann
freetype
fuzzy
gapi
hdf
hfs
highgui
img_hash
imgcodecs
imgproc
intensity_transform
line_descriptor
mcc
ml
multiview
numeric
objdetect
optflow
ovis
phase_unwrapping
photo
plot
quality
rapid
reg
rgbd
saliency
sfm
shape
simple_pipeline
stereo
stitching
structured_light
superres
surface_matching
text
tracking
video
videoio
videostab
viz
wechat_qrcode
xfeatures2d
ximgproc
xobjdetect
xphoto)

# Set names of each component of OpenCV 4.1
foreach(comp ${_comps})
set(${_pkg}_${comp}_NAMES opencv_${comp} opencv_${comp}412 opencv_${comp}411 opencv_${comp}410)
endforeach()

set(${_pkg}_alphamat_DEPENDENCIES core imgproc)
set(${_pkg}_aruco_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_barcode_DEPENDENCIES core dnn imgproc)
set(${_pkg}_bgsegm_DEPENDENCIES calib3d core features2d flann imgproc video)
set(${_pkg}_bioinspired_DEPENDENCIES core highgui imgcodecs imgproc videoio)
set(${_pkg}_calib3d_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_ccalib_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_core_DEPENDENCIES)
set(${_pkg}_cudaarithm_DEPENDENCIES core)
set(${_pkg}_cudabgsegm_DEPENDENCIES calib3d core features2d flann imgproc video)
set(${_pkg}_cudacodec_DEPENDENCIES core imgcodecs imgproc videoio)
set(${_pkg}_cudafeatures2d_DEPENDENCIES
core
cudaarithm
cudafilters
cudawarping
features2d
flann
imgproc)
set(${_pkg}_cudafilters_DEPENDENCIES core cudaarithm imgproc)
set(${_pkg}_cudaimgproc_DEPENDENCIES core cudaarithm cudafilters imgproc)
set(${_pkg}_cudalegacy_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
features2d
flann
imgproc
objdetect
video)
set(${_pkg}_cudaobjdetect_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudawarping
features2d
flann
imgproc
objdetect
video)
set(${_pkg}_cudaoptflow_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudawarping
features2d
flann
imgcodecs
imgproc
objdetect
optflow
video
ximgproc)
set(${_pkg}_cudastereo_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_cudawarping_DEPENDENCIES core imgproc)
set(${_pkg}_cvv_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_datasets_DEPENDENCIES
core
dnn
features2d
flann
imgcodecs
imgproc
ml
text)
set(${_pkg}_dnn_DEPENDENCIES core imgproc)
set(${_pkg}_dnn_objdetect_DEPENDENCIES core dnn highgui imgcodecs imgproc videoio)
set(${_pkg}_dnn_superres_DEPENDENCIES core dnn imgproc ml quality)
set(${_pkg}_dpm_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
objdetect
videoio)
set(${_pkg}_face_DEPENDENCIES
core
flann
imgproc
features2d
photo
calib3d
objdetect)
if(_with_cuda)
list(APPEND ${_pkg}_face_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()
set(${_pkg}_features2d_DEPENDENCIES core flann imgproc)
set(${_pkg}_flann_DEPENDENCIES core)
set(${_pkg}_freetype_DEPENDENCIES core imgproc)
set(${_pkg}_fuzzy_DEPENDENCIES core imgproc)
set(${_pkg}_gapi_DEPENDENCIES core imgproc)
set(${_pkg}_hdf_DEPENDENCIES core)
set(${_pkg}_hfs_DEPENDENCIES core imgproc)
set(${_pkg}_highgui_DEPENDENCIES core imgcodecs imgproc videoio)
set(${_pkg}_img_hash_DEPENDENCIES core imgproc)
set(${_pkg}_imgcodecs_DEPENDENCIES core imgproc)
set(${_pkg}_imgproc_DEPENDENCIES core)
set(${_pkg}_intensity_transform_DEPENDENCIES core imgproc)
set(${_pkg}_line_descriptor_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_mcc_DEPENDENCIES calib3d core dnn features2d flann imgproc)
set(${_pkg}_ml_DEPENDENCIES core)
set(${_pkg}_objdetect_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_optflow_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
video
ximgproc)
set(${_pkg}_ovis_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_phase_unwrapping_DEPENDENCIES core imgproc)
set(${_pkg}_photo_DEPENDENCIES core imgproc)
if(_with_cuda)
list(APPEND ${_pkg}_photo_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()
set(${_pkg}_plot_DEPENDENCIES core imgproc)
set(${_pkg}_quality_DEPENDENCIES core imgproc ml)
set(${_pkg}_rapid_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_reg_DEPENDENCIES core imgproc)
set(${_pkg}_rgbd_DEPENDENCIES calib3d core features2d flann imgproc viz)
set(${_pkg}_saliency_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_sfm_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
ml
shape
xfeatures2d)
if(_with_cuda)
list(APPEND ${_pkg}_sfm_DEPENDENCIES cudaarithm)
endif()
set(${_pkg}_shape_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_stereo_DEPENDENCIES
calib3d
core
datasets
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
plot
text
tracking
video
videoio)
set(${_pkg}_stitching_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
ml
objdetect
shape
video
xfeatures2d)
if(_with_cuda)
list(
APPEND
${_pkg}_stitching_DEPENDENCIES
cudaarithm
cudafeatures2d
cudafilters
cudaimgproc
cudalegacy
cudawarping)
endif()
set(${_pkg}_structured_light_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
phase_unwrapping
viz)
set(${_pkg}_superres_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
objdetect
optflow
video
videoio
ximgproc)
if(_with_cuda)
list(
APPEND
${_pkg}_superres_DEPENDENCIES
cudaarithm
cudacodec
cudafilters
cudaimgproc
cudalegacy
cudaoptflow
cudawarping)
endif()
set(${_pkg}_surface_matching_DEPENDENCIES core flann)
set(${_pkg}_text_DEPENDENCIES core dnn features2d flann imgproc ml)
set(${_pkg}_tracking_DEPENDENCIES
calib3d
core
datasets
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
plot
text
video
videoio)
set(${_pkg}_video_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_videoio_DEPENDENCIES core imgcodecs imgproc)
set(${_pkg}_videostab_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
objdetect
optflow
photo
video
videoio
ximgproc)
if(_with_cuda)
list(
APPEND
${_pkg}_videostab_DEPENDENCIES
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudaoptflow
cudawarping)
endif()
set(${_pkg}_viz_DEPENDENCIES core)
set(${_pkg}_wechat_qrcode_DEPENDENCIES core dnn imgproc)
set(${_pkg}_xfeatures2d_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
ml
shape)
if(_with_cuda)
list(APPEND ${_pkg}_xfeatures2d_DEPENDENCIES cudaarithm)
endif()
set(${_pkg}_ximgproc_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
video)
set(${_pkg}_xobjdetect_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
objdetect)
set(${_pkg}_xphoto_DEPENDENCIES core imgproc photo)
if(_with_cuda)
list(APPEND ${_pkg}_xphoto_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()

if(_with_cuda)
foreach(comp ${_comps})
list(PREPEND ${_pkg}_${comp}_NAMES cudev)
endforeach()
endif()

+ 414
- 0
cmake/modules/opencv/4.2.cmake View File

@@ -0,0 +1,414 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

if(NOT "${CMAKE_CUDA_COMPILER}" STREQUAL "")
set(_with_cuda TRUE)
else()
set(_with_cuda FALSE)
endif()

set(_comps
alphamat
aruco
barcode
bgsegm
bioinspired
calib3d
ccalib
core
correspondence
cudaarithm
cudabgsegm
cudacodec
cudafeatures2d
cudafilters
cudaimgproc
cudalegacy
cudaobjdetect
cudaoptflow
cudastereo
cudawarping
cudev
cvv
datasets
dnn
dnn_objdetect
dnn_superres
dpm
face
features2d
flann
freetype
fuzzy
gapi
hdf
hfs
highgui
img_hash
imgcodecs
imgproc
intensity_transform
line_descriptor
mcc
ml
multiview
numeric
objdetect
optflow
ovis
phase_unwrapping
photo
plot
quality
rapid
reg
rgbd
saliency
sfm
shape
simple_pipeline
stereo
stitching
structured_light
superres
surface_matching
text
tracking
video
videoio
videostab
viz
wechat_qrcode
xfeatures2d
ximgproc
xobjdetect
xphoto)

# Set names of each component of OpenCV 4.2
foreach(comp ${_comps})
set(${_pkg}_${comp}_NAMES opencv_${comp} opencv_${comp}420)
endforeach()

set(${_pkg}_alphamat_DEPENDENCIES core imgproc)
set(${_pkg}_aruco_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_barcode_DEPENDENCIES core dnn imgproc)
set(${_pkg}_bgsegm_DEPENDENCIES calib3d core features2d flann imgproc video)
set(${_pkg}_bioinspired_DEPENDENCIES core highgui imgcodecs imgproc videoio)
set(${_pkg}_calib3d_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_ccalib_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_core_DEPENDENCIES)
set(${_pkg}_cudaarithm_DEPENDENCIES core)
set(${_pkg}_cudabgsegm_DEPENDENCIES calib3d core features2d flann imgproc video)
set(${_pkg}_cudacodec_DEPENDENCIES core imgcodecs imgproc videoio)
set(${_pkg}_cudafeatures2d_DEPENDENCIES
core
cudaarithm
cudafilters
cudawarping
features2d
flann
imgproc)
set(${_pkg}_cudafilters_DEPENDENCIES core cudaarithm imgproc)
set(${_pkg}_cudaimgproc_DEPENDENCIES core cudaarithm cudafilters imgproc)
set(${_pkg}_cudalegacy_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
features2d
flann
imgproc
objdetect
video)
set(${_pkg}_cudaobjdetect_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudawarping
features2d
flann
imgproc
objdetect
video)
set(${_pkg}_cudaoptflow_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudawarping
features2d
flann
imgcodecs
imgproc
objdetect
optflow
video
ximgproc)
set(${_pkg}_cudastereo_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_cudawarping_DEPENDENCIES core imgproc)
set(${_pkg}_cvv_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_datasets_DEPENDENCIES
core
dnn
features2d
flann
imgcodecs
imgproc
ml
text)
set(${_pkg}_dnn_DEPENDENCIES core imgproc)
set(${_pkg}_dnn_objdetect_DEPENDENCIES core dnn highgui imgcodecs imgproc videoio)
set(${_pkg}_dnn_superres_DEPENDENCIES core dnn imgproc ml quality)
set(${_pkg}_dpm_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
objdetect
videoio)
set(${_pkg}_face_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
objdetect
photo)
if(_with_cuda)
list(APPEND ${_pkg}_face_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()
set(${_pkg}_features2d_DEPENDENCIES core flann imgproc)
set(${_pkg}_flann_DEPENDENCIES core)
set(${_pkg}_freetype_DEPENDENCIES core imgproc)
set(${_pkg}_fuzzy_DEPENDENCIES core imgproc)
set(${_pkg}_gapi_DEPENDENCIES core imgproc)
set(${_pkg}_hdf_DEPENDENCIES core)
set(${_pkg}_hfs_DEPENDENCIES core imgproc)
set(${_pkg}_highgui_DEPENDENCIES core imgcodecs imgproc videoio)
set(${_pkg}_img_hash_DEPENDENCIES core imgproc)
set(${_pkg}_imgcodecs_DEPENDENCIES core imgproc)
set(${_pkg}_imgproc_DEPENDENCIES core)
set(${_pkg}_intensity_transform_DEPENDENCIES core imgproc)
set(${_pkg}_line_descriptor_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_mcc_DEPENDENCIES calib3d core dnn features2d flann imgproc)
set(${_pkg}_ml_DEPENDENCIES core)
set(${_pkg}_objdetect_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_optflow_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
video
ximgproc)
set(${_pkg}_ovis_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_phase_unwrapping_DEPENDENCIES core imgproc)
set(${_pkg}_photo_DEPENDENCIES core imgproc)
if(_with_cuda)
list(APPEND ${_pkg}_photo_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()
set(${_pkg}_plot_DEPENDENCIES core imgproc)
set(${_pkg}_quality_DEPENDENCIES core imgproc ml)
set(${_pkg}_rapid_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_reg_DEPENDENCIES core imgproc)
set(${_pkg}_rgbd_DEPENDENCIES calib3d core features2d flann imgproc viz)
set(${_pkg}_saliency_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_sfm_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
ml
shape
xfeatures2d)
if(_with_cuda)
list(APPEND ${_pkg}_sfm_DEPENDENCIES cudaarithm)
endif()
set(${_pkg}_shape_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_stereo_DEPENDENCIES
calib3d
core
datasets
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
plot
text
tracking
video
videoio)
set(${_pkg}_stitching_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
ml
objdetect
shape
video
xfeatures2d)
if(_with_cuda)
list(
APPEND
${_pkg}_stitching_DEPENDENCIES
cudaarithm
cudafeatures2d
cudafilters
cudaimgproc
cudalegacy
cudawarping)
endif()
set(${_pkg}_structured_light_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
phase_unwrapping
viz)
set(${_pkg}_superres_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
objdetect
optflow
video
videoio
ximgproc)
if(_with_cuda)
list(
APPEND
${_pkg}_superres_DEPENDENCIES
cudaarithm
cudacodec
cudafilters
cudaimgproc
cudalegacy
cudaoptflow
cudawarping)
endif()
set(${_pkg}_surface_matching_DEPENDENCIES core flann)
set(${_pkg}_text_DEPENDENCIES core dnn features2d flann imgproc ml)
set(${_pkg}_tracking_DEPENDENCIES
calib3d
core
datasets
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
plot
text
video
videoio)
set(${_pkg}_video_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_videoio_DEPENDENCIES core imgcodecs imgproc)
set(${_pkg}_videostab_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
objdetect
optflow
photo
video
videoio
ximgproc)
if(_with_cuda)
list(
APPEND
${_pkg}_videostab_DEPENDENCIES
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudaoptflow
cudawarping)
endif()
set(${_pkg}_viz_DEPENDENCIES core)
set(${_pkg}_wechat_qrcode_DEPENDENCIES core dnn imgproc)
set(${_pkg}_xfeatures2d_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
ml
shape)
if(_with_cuda)
list(APPEND ${_pkg}_xfeatures2d_DEPENDENCIES cudaarithm)
endif()
set(${_pkg}_ximgproc_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
video)
set(${_pkg}_xobjdetect_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
objdetect)
set(${_pkg}_xphoto_DEPENDENCIES core imgproc photo)
if(_with_cuda)
list(APPEND ${_pkg}_xphoto_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()

if(_with_cuda)
foreach(comp ${_comps})
list(PREPEND ${_pkg}_${comp}_NAMES cudev)
endforeach()
endif()

+ 414
- 0
cmake/modules/opencv/4.3.cmake View File

@@ -0,0 +1,414 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

if(NOT "${CMAKE_CUDA_COMPILER}" STREQUAL "")
set(_with_cuda TRUE)
else()
set(_with_cuda FALSE)
endif()

set(_comps
alphamat
aruco
barcode
bgsegm
bioinspired
calib3d
ccalib
core
correspondence
cudaarithm
cudabgsegm
cudacodec
cudafeatures2d
cudafilters
cudaimgproc
cudalegacy
cudaobjdetect
cudaoptflow
cudastereo
cudawarping
cudev
cvv
datasets
dnn
dnn_objdetect
dnn_superres
dpm
face
features2d
flann
freetype
fuzzy
gapi
hdf
hfs
highgui
img_hash
imgcodecs
imgproc
intensity_transform
line_descriptor
mcc
ml
multiview
numeric
objdetect
optflow
ovis
phase_unwrapping
photo
plot
quality
rapid
reg
rgbd
saliency
sfm
shape
simple_pipeline
stereo
stitching
structured_light
superres
surface_matching
text
tracking
video
videoio
videostab
viz
wechat_qrcode
xfeatures2d
ximgproc
xobjdetect
xphoto)

# Set names of each component of OpenCV 4.3
foreach(comp ${_comps})
set(${_pkg}_${comp}_NAMES opencv_${comp} opencv_${comp}430)
endforeach()

set(${_pkg}_alphamat_DEPENDENCIES core imgproc)
set(${_pkg}_aruco_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_barcode_DEPENDENCIES core dnn imgproc)
set(${_pkg}_bgsegm_DEPENDENCIES calib3d core features2d flann imgproc video)
set(${_pkg}_bioinspired_DEPENDENCIES core highgui imgcodecs imgproc videoio)
set(${_pkg}_calib3d_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_ccalib_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_core_DEPENDENCIES)
set(${_pkg}_cudaarithm_DEPENDENCIES core)
set(${_pkg}_cudabgsegm_DEPENDENCIES calib3d core features2d flann imgproc video)
set(${_pkg}_cudacodec_DEPENDENCIES core imgcodecs imgproc videoio)
set(${_pkg}_cudafeatures2d_DEPENDENCIES
core
cudaarithm
cudafilters
cudawarping
features2d
flann
imgproc)
set(${_pkg}_cudafilters_DEPENDENCIES core cudaarithm imgproc)
set(${_pkg}_cudaimgproc_DEPENDENCIES core cudaarithm cudafilters imgproc)
set(${_pkg}_cudalegacy_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
features2d
flann
imgproc
objdetect
video)
set(${_pkg}_cudaobjdetect_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudawarping
features2d
flann
imgproc
objdetect
video)
set(${_pkg}_cudaoptflow_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudawarping
features2d
flann
imgcodecs
imgproc
objdetect
optflow
video
ximgproc)
set(${_pkg}_cudastereo_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_cudawarping_DEPENDENCIES core imgproc)
set(${_pkg}_cvv_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_datasets_DEPENDENCIES
core
dnn
features2d
flann
imgcodecs
imgproc
ml
text)
set(${_pkg}_dnn_DEPENDENCIES core imgproc)
set(${_pkg}_dnn_objdetect_DEPENDENCIES core dnn highgui imgcodecs imgproc videoio)
set(${_pkg}_dnn_superres_DEPENDENCIES core dnn imgproc ml quality)
set(${_pkg}_dpm_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
objdetect
videoio)
set(${_pkg}_face_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
objdetect
photo)
if(_with_cuda)
list(APPEND ${_pkg}_face_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()
set(${_pkg}_features2d_DEPENDENCIES core flann imgproc)
set(${_pkg}_flann_DEPENDENCIES core)
set(${_pkg}_freetype_DEPENDENCIES core imgproc)
set(${_pkg}_fuzzy_DEPENDENCIES core imgproc)
set(${_pkg}_gapi_DEPENDENCIES core imgproc)
set(${_pkg}_hdf_DEPENDENCIES core)
set(${_pkg}_hfs_DEPENDENCIES core imgproc)
set(${_pkg}_highgui_DEPENDENCIES core imgcodecs imgproc videoio)
set(${_pkg}_img_hash_DEPENDENCIES core imgproc)
set(${_pkg}_imgcodecs_DEPENDENCIES core imgproc)
set(${_pkg}_imgproc_DEPENDENCIES core)
set(${_pkg}_intensity_transform_DEPENDENCIES core imgproc)
set(${_pkg}_line_descriptor_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_mcc_DEPENDENCIES calib3d core dnn features2d flann imgproc)
set(${_pkg}_ml_DEPENDENCIES core)
set(${_pkg}_objdetect_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_optflow_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
video
ximgproc)
set(${_pkg}_ovis_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_phase_unwrapping_DEPENDENCIES core imgproc)
set(${_pkg}_photo_DEPENDENCIES core imgproc)
if(_with_cuda)
list(APPEND ${_pkg}_photo_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()
set(${_pkg}_plot_DEPENDENCIES core imgproc)
set(${_pkg}_quality_DEPENDENCIES core imgproc ml)
set(${_pkg}_rapid_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_reg_DEPENDENCIES core imgproc)
set(${_pkg}_rgbd_DEPENDENCIES calib3d core features2d flann imgproc viz)
set(${_pkg}_saliency_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_sfm_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
ml
shape
xfeatures2d)
if(_with_cuda)
list(APPEND ${_pkg}_sfm_DEPENDENCIES cudaarithm)
endif()
set(${_pkg}_shape_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_stereo_DEPENDENCIES
calib3d
core
datasets
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
plot
text
tracking
video
videoio)
set(${_pkg}_stitching_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
ml
objdetect
shape
video
xfeatures2d)
if(_with_cuda)
list(
APPEND
${_pkg}_stitching_DEPENDENCIES
cudaarithm
cudafeatures2d
cudafilters
cudaimgproc
cudalegacy
cudawarping)
endif()
set(${_pkg}_structured_light_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
phase_unwrapping
viz)
set(${_pkg}_superres_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
objdetect
optflow
video
videoio
ximgproc)
if(_with_cuda)
list(
APPEND
${_pkg}_superres_DEPENDENCIES
cudaarithm
cudacodec
cudafilters
cudaimgproc
cudalegacy
cudaoptflow
cudawarping)
endif()
set(${_pkg}_surface_matching_DEPENDENCIES core flann)
set(${_pkg}_text_DEPENDENCIES core dnn features2d flann imgproc ml)
set(${_pkg}_tracking_DEPENDENCIES
calib3d
core
datasets
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
plot
text
video
videoio)
set(${_pkg}_video_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_videoio_DEPENDENCIES core imgcodecs imgproc)
set(${_pkg}_videostab_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
objdetect
optflow
photo
video
videoio
ximgproc)
if(_with_cuda)
list(
APPEND
${_pkg}_videostab_DEPENDENCIES
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudaoptflow
cudawarping)
endif()
set(${_pkg}_viz_DEPENDENCIES core)
set(${_pkg}_wechat_qrcode_DEPENDENCIES core dnn imgproc)
set(${_pkg}_xfeatures2d_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
ml
shape)
if(_with_cuda)
list(APPEND ${_pkg}_xfeatures2d_DEPENDENCIES cudaarithm)
endif()
set(${_pkg}_ximgproc_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
video)
set(${_pkg}_xobjdetect_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
objdetect)
set(${_pkg}_xphoto_DEPENDENCIES core imgproc photo)
if(_with_cuda)
list(APPEND ${_pkg}_xphoto_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()

if(_with_cuda)
foreach(comp ${_comps})
list(PREPEND ${_pkg}_${comp}_NAMES cudev)
endforeach()
endif()

+ 414
- 0
cmake/modules/opencv/4.4.cmake View File

@@ -0,0 +1,414 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

if(NOT "${CMAKE_CUDA_COMPILER}" STREQUAL "")
set(_with_cuda TRUE)
else()
set(_with_cuda FALSE)
endif()

set(_comps
alphamat
aruco
barcode
bgsegm
bioinspired
calib3d
ccalib
core
correspondence
cudaarithm
cudabgsegm
cudacodec
cudafeatures2d
cudafilters
cudaimgproc
cudalegacy
cudaobjdetect
cudaoptflow
cudastereo
cudawarping
cudev
cvv
datasets
dnn
dnn_objdetect
dnn_superres
dpm
face
features2d
flann
freetype
fuzzy
gapi
hdf
hfs
highgui
img_hash
imgcodecs
imgproc
intensity_transform
line_descriptor
mcc
ml
multiview
numeric
objdetect
optflow
ovis
phase_unwrapping
photo
plot
quality
rapid
reg
rgbd
saliency
sfm
shape
simple_pipeline
stereo
stitching
structured_light
superres
surface_matching
text
tracking
video
videoio
videostab
viz
wechat_qrcode
xfeatures2d
ximgproc
xobjdetect
xphoto)

# Set names of each component of OpenCV 4.4
foreach(comp ${_comps})
set(${_pkg}_${comp}_NAMES opencv_${comp} opencv_${comp}440)
endforeach()

set(${_pkg}_alphamat_DEPENDENCIES core imgproc)
set(${_pkg}_aruco_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_barcode_DEPENDENCIES core dnn imgproc)
set(${_pkg}_bgsegm_DEPENDENCIES calib3d core features2d flann imgproc video)
set(${_pkg}_bioinspired_DEPENDENCIES core highgui imgcodecs imgproc videoio)
set(${_pkg}_calib3d_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_ccalib_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_core_DEPENDENCIES)
set(${_pkg}_cudaarithm_DEPENDENCIES core)
set(${_pkg}_cudabgsegm_DEPENDENCIES calib3d core features2d flann imgproc video)
set(${_pkg}_cudacodec_DEPENDENCIES core imgcodecs imgproc videoio)
set(${_pkg}_cudafeatures2d_DEPENDENCIES
core
cudaarithm
cudafilters
cudawarping
features2d
flann
imgproc)
set(${_pkg}_cudafilters_DEPENDENCIES core cudaarithm imgproc)
set(${_pkg}_cudaimgproc_DEPENDENCIES core cudaarithm cudafilters imgproc)
set(${_pkg}_cudalegacy_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
features2d
flann
imgproc
objdetect
video)
set(${_pkg}_cudaobjdetect_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudawarping
features2d
flann
imgproc
objdetect
video)
set(${_pkg}_cudaoptflow_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudawarping
features2d
flann
imgcodecs
imgproc
objdetect
optflow
video
ximgproc)
set(${_pkg}_cudastereo_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_cudawarping_DEPENDENCIES core imgproc)
set(${_pkg}_cvv_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_datasets_DEPENDENCIES
core
dnn
features2d
flann
imgcodecs
imgproc
ml
text)
set(${_pkg}_dnn_DEPENDENCIES core imgproc)
set(${_pkg}_dnn_objdetect_DEPENDENCIES core dnn highgui imgcodecs imgproc videoio)
set(${_pkg}_dnn_superres_DEPENDENCIES core dnn imgproc ml quality)
set(${_pkg}_dpm_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
objdetect
videoio)
set(${_pkg}_face_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
objdetect
photo)
if(_with_cuda)
list(APPEND ${_pkg}_face_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()
set(${_pkg}_features2d_DEPENDENCIES core flann imgproc)
set(${_pkg}_flann_DEPENDENCIES core)
set(${_pkg}_freetype_DEPENDENCIES core imgproc)
set(${_pkg}_fuzzy_DEPENDENCIES core imgproc)
set(${_pkg}_gapi_DEPENDENCIES calib3d core features2d flann imgproc video)
set(${_pkg}_hdf_DEPENDENCIES core)
set(${_pkg}_hfs_DEPENDENCIES core imgproc)
set(${_pkg}_highgui_DEPENDENCIES core imgcodecs imgproc videoio)
set(${_pkg}_img_hash_DEPENDENCIES core imgproc)
set(${_pkg}_imgcodecs_DEPENDENCIES core imgproc)
set(${_pkg}_imgproc_DEPENDENCIES core)
set(${_pkg}_intensity_transform_DEPENDENCIES core imgproc)
set(${_pkg}_line_descriptor_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_mcc_DEPENDENCIES calib3d core dnn features2d flann imgproc)
set(${_pkg}_ml_DEPENDENCIES core)
set(${_pkg}_objdetect_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_optflow_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
video
ximgproc)
set(${_pkg}_ovis_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_phase_unwrapping_DEPENDENCIES core imgproc)
set(${_pkg}_photo_DEPENDENCIES core imgproc)
if(_with_cuda)
list(APPEND ${_pkg}_photo_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()
set(${_pkg}_plot_DEPENDENCIES core imgproc)
set(${_pkg}_quality_DEPENDENCIES core imgproc ml)
set(${_pkg}_rapid_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_reg_DEPENDENCIES core imgproc)
set(${_pkg}_rgbd_DEPENDENCIES calib3d core features2d flann imgproc viz)
set(${_pkg}_saliency_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_sfm_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
ml
shape
xfeatures2d)
if(_with_cuda)
list(APPEND ${_pkg}_sfm_DEPENDENCIES cudaarithm)
endif()
set(${_pkg}_shape_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_stereo_DEPENDENCIES
calib3d
core
datasets
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
plot
text
tracking
video
videoio)
set(${_pkg}_stitching_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
ml
objdetect
shape
video
xfeatures2d)
if(_with_cuda)
list(
APPEND
${_pkg}_stitching_DEPENDENCIES
cudaarithm
cudafeatures2d
cudafilters
cudaimgproc
cudalegacy
cudawarping)
endif()
set(${_pkg}_structured_light_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
phase_unwrapping
viz)
set(${_pkg}_superres_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
objdetect
optflow
video
videoio
ximgproc)
if(_with_cuda)
list(
APPEND
${_pkg}_superres_DEPENDENCIES
cudaarithm
cudacodec
cudafilters
cudaimgproc
cudalegacy
cudaoptflow
cudawarping)
endif()
set(${_pkg}_surface_matching_DEPENDENCIES core flann)
set(${_pkg}_text_DEPENDENCIES core dnn features2d flann imgproc ml)
set(${_pkg}_tracking_DEPENDENCIES
calib3d
core
datasets
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
plot
text
video
videoio)
set(${_pkg}_video_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_videoio_DEPENDENCIES core imgcodecs imgproc)
set(${_pkg}_videostab_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
objdetect
optflow
photo
video
videoio
ximgproc)
if(_with_cuda)
list(
APPEND
${_pkg}_videostab_DEPENDENCIES
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudaoptflow
cudawarping)
endif()
set(${_pkg}_viz_DEPENDENCIES core)
set(${_pkg}_wechat_qrcode_DEPENDENCIES core dnn imgproc)
set(${_pkg}_xfeatures2d_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
ml
shape)
if(_with_cuda)
list(APPEND ${_pkg}_xfeatures2d_DEPENDENCIES cudaarithm)
endif()
set(${_pkg}_ximgproc_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
video)
set(${_pkg}_xobjdetect_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
objdetect)
set(${_pkg}_xphoto_DEPENDENCIES core imgproc photo)
if(_with_cuda)
list(APPEND ${_pkg}_xphoto_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()

if(_with_cuda)
foreach(comp ${_comps})
list(PREPEND ${_pkg}_${comp}_NAMES cudev)
endforeach()
endif()

+ 457
- 0
cmake/modules/opencv/4.5.cmake View File

@@ -0,0 +1,457 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

if(NOT "${CMAKE_CUDA_COMPILER}" STREQUAL "")
set(_with_cuda TRUE)
else()
set(_with_cuda FALSE)
endif()

set(_comps
alphamat
aruco
barcode
bgsegm
bioinspired
calib3d
ccalib
core
correspondence
cudaarithm
cudabgsegm
cudacodec
cudafeatures2d
cudafilters
cudaimgproc
cudalegacy
cudaobjdetect
cudaoptflow
cudastereo
cudawarping
cudev
cvv
datasets
dnn
dnn_objdetect
dnn_superres
dpm
face
features2d
flann
freetype
fuzzy
gapi
hdf
hfs
highgui
img_hash
imgcodecs
imgproc
intensity_transform
line_descriptor
mcc
ml
multiview
numeric
objdetect
optflow
ovis
phase_unwrapping
photo
plot
quality
rapid
reg
rgbd
saliency
sfm
shape
simple_pipeline
stereo
stitching
structured_light
superres
surface_matching
text
tracking
video
videoio
videostab
viz
wechat_qrcode
xfeatures2d
ximgproc
xobjdetect
xphoto)

# Set names of each component of OpenCV 4.5
foreach(comp ${_comps})
set(${_pkg}_${comp}_NAMES
opencv_${comp}
opencv_${comp}459
opencv_${comp}458
opencv_${comp}457
opencv_${comp}456
opencv_${comp}455
opencv_${comp}454
opencv_${comp}453
opencv_${comp}452
opencv_${comp}451
opencv_${comp}450)
endforeach()

set(${_pkg}_alphamat_DEPENDENCIES core imgproc)
set(${_pkg}_aruco_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_barcode_DEPENDENCIES core dnn imgproc)
set(${_pkg}_bgsegm_DEPENDENCIES
calib3d
core
dnn
features2d
flann
imgproc
video)
set(${_pkg}_bioinspired_DEPENDENCIES core highgui imgcodecs imgproc videoio)
set(${_pkg}_calib3d_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_ccalib_DEPENDENCIES
calib3d
core
features2d
flann
highgui
imgcodecs
imgproc
videoio)
set(${_pkg}_core_DEPENDENCIES)
set(${_pkg}_cudaarithm_DEPENDENCIES core)
set(${_pkg}_cudabgsegm_DEPENDENCIES
calib3d
core
dnn
features2d
flann
imgproc
video)
set(${_pkg}_cudacodec_DEPENDENCIES core imgcodecs imgproc videoio)
set(${_pkg}_cudafeatures2d_DEPENDENCIES
core
cudaarithm
cudafilters
cudawarping
features2d
flann
imgproc)
set(${_pkg}_cudafilters_DEPENDENCIES core cudaarithm imgproc)
set(${_pkg}_cudaimgproc_DEPENDENCIES core cudaarithm cudafilters imgproc)
set(${_pkg}_cudalegacy_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
dnn
features2d
flann
imgproc
objdetect
video)
set(${_pkg}_cudaobjdetect_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudawarping
dnn
features2d
flann
imgproc
objdetect
video)
set(${_pkg}_cudaoptflow_DEPENDENCIES
calib3d
core
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudawarping
dnn
features2d
flann
imgcodecs
imgproc
objdetect
optflow
video
ximgproc)
set(${_pkg}_cudastereo_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_cudawarping_DEPENDENCIES core imgproc)
set(${_pkg}_cvv_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_datasets_DEPENDENCIES
core
dnn
features2d
flann
imgcodecs
imgproc
ml
text)
set(${_pkg}_dnn_DEPENDENCIES core imgproc)
set(${_pkg}_dnn_objdetect_DEPENDENCIES core dnn highgui imgcodecs imgproc videoio)
set(${_pkg}_dnn_superres_DEPENDENCIES core dnn imgproc ml quality)
set(${_pkg}_dpm_DEPENDENCIES
calib3d
core
dnn
features2d
flann
highgui
imgcodecs
imgproc
objdetect
videoio)
set(${_pkg}_face_DEPENDENCIES
calib3d
core
dnn
features2d
flann
imgproc
objdetect
photo)
if(_with_cuda)
list(APPEND ${_pkg}_face_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()
set(${_pkg}_features2d_DEPENDENCIES core flann imgproc)
set(${_pkg}_flann_DEPENDENCIES core)
set(${_pkg}_freetype_DEPENDENCIES core imgproc)
set(${_pkg}_fuzzy_DEPENDENCIES core imgproc)
set(${_pkg}_gapi_DEPENDENCIES
calib3d
core
dnn
features2d
flann
imgproc
video)
set(${_pkg}_hdf_DEPENDENCIES core)
set(${_pkg}_hfs_DEPENDENCIES core imgproc)
set(${_pkg}_highgui_DEPENDENCIES core imgcodecs imgproc videoio)
set(${_pkg}_img_hash_DEPENDENCIES core imgproc)
set(${_pkg}_imgcodecs_DEPENDENCIES core imgproc)
set(${_pkg}_imgproc_DEPENDENCIES core)
set(${_pkg}_intensity_transform_DEPENDENCIES core imgproc)
set(${_pkg}_line_descriptor_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_mcc_DEPENDENCIES calib3d core dnn features2d flann imgproc)
set(${_pkg}_ml_DEPENDENCIES core)
set(${_pkg}_objdetect_DEPENDENCIES calib3d core dnn features2d flann imgproc)
set(${_pkg}_optflow_DEPENDENCIES
calib3d
core
dnn
features2d
flann
imgcodecs
imgproc
video
ximgproc)
set(${_pkg}_ovis_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_phase_unwrapping_DEPENDENCIES core imgproc)
set(${_pkg}_photo_DEPENDENCIES core imgproc)
if(_with_cuda)
list(APPEND ${_pkg}_photo_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()
set(${_pkg}_plot_DEPENDENCIES core imgproc)
set(${_pkg}_quality_DEPENDENCIES core imgproc ml)
set(${_pkg}_rapid_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_reg_DEPENDENCIES core imgproc)
set(${_pkg}_rgbd_DEPENDENCIES calib3d core features2d flann imgproc viz)
set(${_pkg}_saliency_DEPENDENCIES core features2d flann imgproc)
set(${_pkg}_sfm_DEPENDENCIES
calib3d
core
features2d
flann
imgcodecs
imgproc
ml
shape
xfeatures2d)
if(_with_cuda)
list(APPEND ${_pkg}_sfm_DEPENDENCIES cudaarithm)
endif()
set(${_pkg}_shape_DEPENDENCIES calib3d core features2d flann imgproc)
set(${_pkg}_stereo_DEPENDENCIES
calib3d
core
datasets
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
plot
text
tracking
video
videoio)
set(${_pkg}_stitching_DEPENDENCIES
calib3d
core
dnn
features2d
flann
imgproc
ml
objdetect
shape
video
xfeatures2d)
if(_with_cuda)
list(
APPEND
${_pkg}_stitching_DEPENDENCIES
cudaarithm
cudafeatures2d
cudafilters
cudaimgproc
cudalegacy
cudawarping)
endif()
set(${_pkg}_structured_light_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
phase_unwrapping
viz)
set(${_pkg}_superres_DEPENDENCIES
calib3d
core
dnn
features2d
flann
imgcodecs
imgproc
objdetect
optflow
video
videoio
ximgproc)
if(_with_cuda)
list(
APPEND
${_pkg}_superres_DEPENDENCIES
cudaarithm
cudacodec
cudafilters
cudaimgproc
cudalegacy
cudaoptflow
cudawarping)
endif()
set(${_pkg}_surface_matching_DEPENDENCIES core flann)
set(${_pkg}_text_DEPENDENCIES core dnn features2d flann imgproc ml)
set(${_pkg}_tracking_DEPENDENCIES
calib3d
core
datasets
dnn
features2d
flann
highgui
imgcodecs
imgproc
ml
plot
text
video
videoio)
set(${_pkg}_video_DEPENDENCIES calib3d core dnn features2d flann imgproc)
set(${_pkg}_videoio_DEPENDENCIES core imgcodecs imgproc)
set(${_pkg}_videostab_DEPENDENCIES
calib3d
core
dnn
features2d
flann
imgcodecs
imgproc
objdetect
optflow
photo
video
videoio
ximgproc)
if(_with_cuda)
list(
APPEND
${_pkg}_videostab_DEPENDENCIES
cudaarithm
cudafilters
cudaimgproc
cudalegacy
cudaoptflow
cudawarping)
endif()
set(${_pkg}_viz_DEPENDENCIES core)
set(${_pkg}_wechat_qrcode_DEPENDENCIES core dnn imgproc)
set(${_pkg}_xfeatures2d_DEPENDENCIES
calib3d
core
features2d
flann
imgproc
ml
shape)
if(_with_cuda)
list(APPEND ${_pkg}_xfeatures2d_DEPENDENCIES cudaarithm)
endif()
set(${_pkg}_ximgproc_DEPENDENCIES
calib3d
core
dnn
features2d
flann
imgcodecs
imgproc
video)
set(${_pkg}_xobjdetect_DEPENDENCIES
calib3d
core
dnn
features2d
flann
imgcodecs
imgproc
objdetect)
set(${_pkg}_xphoto_DEPENDENCIES core imgproc photo)
if(_with_cuda)
list(APPEND ${_pkg}_xphoto_DEPENDENCIES cudaarithm cudafilters cudaimgproc)
endif()

if(_with_cuda)
foreach(comp ${_comps})
list(PREPEND ${_pkg}_${comp}_NAMES cudev)
endforeach()
endif()

+ 108
- 0
cmake/modules/opencv/5.0.cmake View File

@@ -0,0 +1,108 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

# Set names of each component of OpenCV 5.0-pre
foreach(
comp
3d
alphamat
aruco
barcode
bgsegm
bioinspired
calib
ccalib
core
cudaarithm
cudabgsegm
cudacodec
cudafeatures2d
cudafilters
cudaimgproc
cudalegacy
cudaobjdetect
cudaoptflow
cudastereo
cudawarping
cudev
cvv
datasets
dnn
dnn_objdetect
dnn_superres
dpm
face
features2d
flann
freetype
fuzzy
gapi
hdf
hfs
highgui
img_hash
imgcodecs
imgproc
intensity_transform
julia
line_descriptor
mcc
ml
objdetect
optflow
ovis
phase_unwrapping
photo
plot
quality
rapid
reg
rgbd
saliency
sfm
shape
stereo
stitching
structured_light
superres
surface_matching
text
tracking
video
videoio
videostab
viz
wechat_qrcode
xfeatures2d
ximgproc
xobjdetect
xphoto
xstereo)
set(${_pkg}_${comp}_NAMES
opencv_${comp}
opencv_${comp}509
opencv_${comp}508
opencv_${comp}507
opencv_${comp}506
opencv_${comp}505
opencv_${comp}504
opencv_${comp}503
opencv_${comp}502
opencv_${comp}501
opencv_${comp}500)
endforeach()

+ 5
- 0
cmake/options.cmake View File

@@ -21,6 +21,7 @@ option(ENABLE_IBVERBS "enable IBVERBS for parameter server" OFF)
option(ENABLE_PYTHON "Enable python" ON) option(ENABLE_PYTHON "Enable python" ON)
option(ENABLE_ACL "enable acl" OFF) option(ENABLE_ACL "enable acl" OFF)
option(ENABLE_GLIBCXX "enable_glibcxx" OFF) option(ENABLE_GLIBCXX "enable_glibcxx" OFF)
option(ENABLE_WERROR "Enable -Werror while compiling" ON)
option(MODE_ASCEND_ALL "supports all ascend platform" OFF) option(MODE_ASCEND_ALL "supports all ascend platform" OFF)
option(MODE_ASCEND_ACL "supports ascend acl mode only" OFF) option(MODE_ASCEND_ACL "supports ascend acl mode only" OFF)
option(ENABLE_SYM_FILE "enable sym file" OFF) option(ENABLE_SYM_FILE "enable sym file" OFF)
@@ -61,6 +62,10 @@ if(ENABLE_ASAN)
endif() endif()
endif() endif()


if(ENABLE_WERROR)
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -Werror")
endif()

if(DEBUG_MODE) if(DEBUG_MODE)
set(CMAKE_BUILD_TYPE "Debug") set(CMAKE_BUILD_TYPE "Debug")
add_compile_definitions(MEM_REUSE_DEBUG) add_compile_definitions(MEM_REUSE_DEBUG)


+ 993
- 330
cmake/utils.cmake
File diff suppressed because it is too large
View File


+ 1
- 1
docs/api/api_python/mindspore.ops.rst View File

@@ -348,7 +348,7 @@ functional算子是经过初始化后的Primitive,可以直接作为函数使
mindspore.ops.jvp mindspore.ops.jvp
mindspore.ops.laplace mindspore.ops.laplace
mindspore.ops.Map mindspore.ops.Map
mindspore.ops.matmul
mindspore.ops.matmul_
mindspore.ops.multinomial mindspore.ops.multinomial
mindspore.ops.MultitypeFuncGraph mindspore.ops.MultitypeFuncGraph
mindspore.ops.narrow mindspore.ops.narrow


docs/api/api_python/ops/mindspore.ops.matmul.rst → docs/api/api_python/ops/mindspore.ops.matmul_.rst View File


+ 51
- 40
mindspore/ccsrc/CMakeLists.txt View File

@@ -11,7 +11,7 @@ set(FBS_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../schema/cipher.fbs ${CMAKE_CURRENT_SOURCE_DIR}/../schema/cipher.fbs
${CMAKE_CURRENT_SOURCE_DIR}/../schema/fl_job.fbs ${CMAKE_CURRENT_SOURCE_DIR}/../schema/fl_job.fbs
) )
ms_build_flatbuffers(FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}../../schema generated_fbs_files ${SERVER_FLATBUFFER_OUTPUT})
ms_build_flatbuffers(FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../schema generated_fbs_files ${SERVER_FLATBUFFER_OUTPUT})


if(ENABLE_D) if(ENABLE_D)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/plugin/device/ascend/kernel/aicpu/aicpu_ops) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/plugin/device/ascend/kernel/aicpu/aicpu_ops)
@@ -34,7 +34,9 @@ endif()
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
link_directories(${CMAKE_SOURCE_DIR}/build/mindspore/graphengine) link_directories(${CMAKE_SOURCE_DIR}/build/mindspore/graphengine)
else() else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 \
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wno-delete-non-abstract-non-virtual-dtor -Wno-unused-private-field -Wno-overloaded-virtual \ -Wno-delete-non-abstract-non-virtual-dtor -Wno-unused-private-field -Wno-overloaded-virtual \
-Wno-unused-const-variable -Wno-pessimizing-move -Wno-range-loop-analysis -Wno-mismatched-tags \ -Wno-unused-const-variable -Wno-pessimizing-move -Wno-range-loop-analysis -Wno-mismatched-tags \
-Wno-c++11-narrowing") -Wno-c++11-narrowing")
@@ -49,14 +51,7 @@ if(ENABLE_MPI)
endif() endif()


if(ENABLE_GPU) if(ENABLE_GPU)
find_package(CUDA REQUIRED)
find_package(Threads)
if(${CUDA_VERSION} VERSION_LESS ${MS_REQUIRE_CUDA_VERSION})
message(FATAL_ERROR "The minimum CUDA version ${MS_REQUIRE_CUDA_VERSION} is required, \
but only CUDA ${CUDA_VERSION} found.")
endif()
enable_language(CUDA)
if(NOT CUDA_PATH OR CUDA_PATH STREQUAL "")
if(NOT CUDA_PATH OR "${CUDA_PATH}" STREQUAL "")
if(DEFINED ENV{CUDA_HOME} AND NOT $ENV{CUDA_HOME} STREQUAL "") if(DEFINED ENV{CUDA_HOME} AND NOT $ENV{CUDA_HOME} STREQUAL "")
set(CUDA_PATH $ENV{CUDA_HOME}) set(CUDA_PATH $ENV{CUDA_HOME})
else() else()
@@ -64,16 +59,24 @@ if(ENABLE_GPU)
endif() endif()
endif() endif()


if(DEFINED ENV{CUDNN_HOME} AND NOT $ENV{CUDNN_HOME} STREQUAL "")
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
find_package(Threads)
if(CUDAToolkit_VERSION VERSION_LESS ${MS_REQUIRE_CUDA_VERSION})
message(FATAL_ERROR "The minimum CUDA version ${MS_REQUIRE_CUDA_VERSION} is required, \
but only CUDA ${CUDAToolkit_VERSION} found.")
endif()

if(DEFINED ENV{CUDNN_HOME} AND NOT "$ENV{CUDNN_HOME}" STREQUAL "")
set(CUDNN_INCLUDE_DIR $ENV{CUDNN_HOME}/include) set(CUDNN_INCLUDE_DIR $ENV{CUDNN_HOME}/include)
set(CUDNN_LIBRARY_DIR $ENV{CUDNN_HOME}/lib64) set(CUDNN_LIBRARY_DIR $ENV{CUDNN_HOME}/lib64)
find_path(CUDNN_INCLUDE_PATH cudnn.h HINTS ${CUDNN_INCLUDE_DIR} NO_DEFAULT_PATH) find_path(CUDNN_INCLUDE_PATH cudnn.h HINTS ${CUDNN_INCLUDE_DIR} NO_DEFAULT_PATH)
find_library(CUDNN_LIBRARY_PATH "cudnn" HINTS ${CUDNN_LIBRARY_DIR} NO_DEFAULT_PATH) find_library(CUDNN_LIBRARY_PATH "cudnn" HINTS ${CUDNN_LIBRARY_DIR} NO_DEFAULT_PATH)
if(CUDNN_INCLUDE_PATH STREQUAL CUDNN_INCLUDE_PATH-NOTFOUND)
if(NOT CUDNN_INCLUDE_PATH)
message(FATAL_ERROR "Failed to find cudnn header file, please set environment variable CUDNN_HOME to \ message(FATAL_ERROR "Failed to find cudnn header file, please set environment variable CUDNN_HOME to \
cudnn installation position.") cudnn installation position.")
endif() endif()
if(CUDNN_LIBRARY_PATH STREQUAL CUDNN_LIBRARY_PATH-NOTFOUND)
if(NOT CUDNN_LIBRARY_PATH)
message(FATAL_ERROR "Failed to find cudnn library file, please set environment variable CUDNN_HOME to \ message(FATAL_ERROR "Failed to find cudnn library file, please set environment variable CUDNN_HOME to \
cudnn installation position.") cudnn installation position.")
endif() endif()
@@ -81,14 +84,14 @@ if(ENABLE_GPU)
list(APPEND CMAKE_PREFIX_PATH ${CUDA_TOOLKIT_ROOT_DIR}) list(APPEND CMAKE_PREFIX_PATH ${CUDA_TOOLKIT_ROOT_DIR})
find_path(CUDNN_INCLUDE_PATH cudnn.h PATH_SUFFIXES cuda/inclulde include cuda) find_path(CUDNN_INCLUDE_PATH cudnn.h PATH_SUFFIXES cuda/inclulde include cuda)
find_library(CUDNN_LIBRARY_PATH "cudnn" PATH_SUFFIXES cuda/lib64 lib64 lib cuda/lib lib/x86_64-linux-gnu) find_library(CUDNN_LIBRARY_PATH "cudnn" PATH_SUFFIXES cuda/lib64 lib64 lib cuda/lib lib/x86_64-linux-gnu)
if(CUDNN_INCLUDE_PATH STREQUAL CUDNN_INCLUDE_PATH-NOTFOUND)
if(NOT CUDNN_INCLUDE_PATH)
message(FATAL_ERROR "Failed to find cudnn header file, if cudnn library is not installed, please put \ message(FATAL_ERROR "Failed to find cudnn header file, if cudnn library is not installed, please put \
cudnn header file in cuda include path or user include path(eg. /usr/local/cuda/include; \ cudnn header file in cuda include path or user include path(eg. /usr/local/cuda/include; \
/usr/local/include; /usr/include), if cudnn library is installed in other position, please \ /usr/local/include; /usr/include), if cudnn library is installed in other position, please \
set environment variable CUDNN_HOME to cudnn installation position, there should be cudnn.h \ set environment variable CUDNN_HOME to cudnn installation position, there should be cudnn.h \
in {CUDNN_HOME}/include.") in {CUDNN_HOME}/include.")
endif() endif()
if(CUDNN_LIBRARY_PATH STREQUAL CUDNN_LIBRARY_PATH-NOTFOUND)
if(NOT CUDNN_LIBRARY_PATH)
message(FATAL_ERROR "Failed to find cudnn library file, if cudnn library is not installed, please put \ message(FATAL_ERROR "Failed to find cudnn library file, if cudnn library is not installed, please put \
cudnn library file in cuda library path or user library path(eg. /usr/local/cuda/lib64; \ cudnn library file in cuda library path or user library path(eg. /usr/local/cuda/lib64; \
/usr/local/lib64; /usr/lib64; /usr/local/lib; /usr/lib), if cudnn library is installed in other \ /usr/local/lib64; /usr/lib64; /usr/local/lib; /usr/lib), if cudnn library is installed in other \
@@ -97,15 +100,21 @@ if(ENABLE_GPU)
endif() endif()
endif() endif()


if(NOT CUPTI_INCLUDE_DIRS OR CUPTI_INCLUDE_DIRS STREQUAL "")
set(CUPTI_INCLUDE_DIRS ${CUDA_PATH}/extras/CUPTI/include)
message("CUDAToolkit_LIBRARY_DIR: ${CUDAToolkit_LIBRARY_DIR}")
message("CUDAToolkit_INCLUDE_DIRS: ${CUDAToolkit_INCLUDE_DIRS}")
message("CUDNN_INCLUDE_PATH: ${CUDNN_INCLUDE_PATH}")
message("CUDNN_LIBRARY_PATH: ${CUDNN_LIBRARY_PATH}")
include_directories(${CUDNN_INCLUDE_PATH})

set(_cuda_root)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
set(_cuda_root "${CUDAToolkit_LIBRARY_ROOT}")
else()
set(_cuda_root "${CUDAToolkit_INCLUDE_DIRS}/..")
endif()
if(EXISTS "${_cuda_root}/extras/CUPTI/include")
target_include_directories(CUDA::cupti INTERFACE "${_cuda_root}/extras/CUPTI/include")
endif() endif()
message("CUDA_PATH: ${CUDA_PATH}")
message("CUDA_INCLUDE_DIRS: ${CUDA_INCLUDE_DIRS}")
message("CUDNN_INCLUDE_PATH: ${CUDNN_INCLUDE_PATH}")
message("CUDNN_LIBRARY_PATH: ${CUDNN_LIBRARY_PATH}")
message("CUPTI_INCLUDE_DIRS: ${CUPTI_INCLUDE_DIRS}")
include_directories(${CUDNN_INCLUDE_PATH} ${CUDA_PATH} ${CUDA_INCLUDE_DIRS} ${CUPTI_INCLUDE_DIRS})


file(GLOB_RECURSE GPU_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} file(GLOB_RECURSE GPU_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"plugin/device/gpu/hal/device/*.cc" "plugin/device/gpu/hal/device/*.cc"
@@ -126,9 +135,10 @@ if(ENABLE_GPU)


if(NOT ${TENSORRT_HOME} STREQUAL "") if(NOT ${TENSORRT_HOME} STREQUAL "")
find_path(TENSORRT_HOME_INCLUDE NvInfer.h HINTS ${TENSORRT_HOME}/include) find_path(TENSORRT_HOME_INCLUDE NvInfer.h HINTS ${TENSORRT_HOME}/include)
if(TENSORRT_HOME_INCLUDE STREQUAL TENSORRT_HOME_INCLUDE-NOTFOUND)
if(NOT TENSORRT_HOME_INCLUDE)
message(FATAL_ERROR "Tensor-RT dir not exist ${TENSORRT_HOME}") message(FATAL_ERROR "Tensor-RT dir not exist ${TENSORRT_HOME}")
endif() endif()
set(TENSORRT_HOME_INCLUDE "${TENSORRT_HOME_INCLUDE}" CACHE INTERNAL "")
message("Enable GPU inference. Tensor-RT include dir: ${TENSORRT_HOME_INCLUDE}") message("Enable GPU inference. Tensor-RT include dir: ${TENSORRT_HOME_INCLUDE}")
set(ENABLE_GPU_INFER TRUE) set(ENABLE_GPU_INFER TRUE)
add_compile_definitions(ENABLE_GPU_INFER) add_compile_definitions(ENABLE_GPU_INFER)
@@ -136,15 +146,15 @@ if(ENABLE_GPU)
list(APPEND GPU_SRC_LIST ${CMAKE_CURRENT_SOURCE_DIR}/plugin/device/gpu/hal/device/trt_loader.cc) list(APPEND GPU_SRC_LIST ${CMAKE_CURRENT_SOURCE_DIR}/plugin/device/gpu/hal/device/trt_loader.cc)
endif() endif()


set(NVCC_TMP_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
if(${CUDA_VERSION} VERSION_LESS 11.0)
string(REPLACE "-std=c++17" "-std=c++11" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
string(REPLACE "-std=c++17" "-std=c++14" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
set_property(SOURCE ${GPU_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE)
cuda_add_library(gpu_cuda_lib STATIC ${GPU_SRC_LIST})
set(CMAKE_CXX_FLAGS ${NVCC_TMP_CMAKE_CXX_FLAGS})
set_source_files_properties(${GPU_SRC_LIST} PROPERTIES COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE
LANGUAGE CUDA)
add_library(gpu_cuda_lib STATIC ${GPU_SRC_LIST})
target_compile_features(gpu_cuda_lib PUBLIC cuda_std_17)
target_link_libraries(gpu_cuda_lib PUBLIC CUDA::cudart CUDA::cuda_driver CUDA::cupti
mindspore::json mindspore::pybind11_module mindspore::nccl
mindspore::protobuf mindspore::grpc++
$<$<BOOL:${USE_GLOG}>:mindspore::glog>)
add_dependencies(gpu_cuda_lib proto_input)
add_compile_definitions(ENABLE_GPU) add_compile_definitions(ENABLE_GPU)


add_subdirectory(plugin/device/gpu/kernel/cuda_impl/cuda_ops) add_subdirectory(plugin/device/gpu/kernel/cuda_impl/cuda_ops)
@@ -225,6 +235,7 @@ list(APPEND MINDSPORE_PROTO_LIST ${CORE_PROTO_SRC})


if(MINDSPORE_PROTO_LIST) if(MINDSPORE_PROTO_LIST)
add_library(proto_input STATIC ${MINDSPORE_PROTO_LIST}) add_library(proto_input STATIC ${MINDSPORE_PROTO_LIST})
target_link_libraries(proto_input PUBLIC mindspore::protobuf mindspore::grpc++)
set_target_properties(proto_input PROPERTIES COMPILE_FLAGS "-Wno-unused-variable") set_target_properties(proto_input PROPERTIES COMPILE_FLAGS "-Wno-unused-variable")
endif() endif()


@@ -431,7 +442,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows")
mindspore_common) mindspore_common)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
target_link_libraries(mindspore PUBLIC proto_input mindspore::protobuf target_link_libraries(mindspore PUBLIC proto_input mindspore::protobuf
mindspore::event mindspore::event_pthreads mindspore::event_openssl mindspore::eigen mindspore::json)
mindspore::event_core mindspore::event_extra mindspore::event_pthreads mindspore::event_openssl mindspore::eigen mindspore::json)
target_link_libraries(mindspore PUBLIC mindspore::event_core ps_cache) target_link_libraries(mindspore PUBLIC mindspore::event_core ps_cache)
target_link_libraries(_c_expression PRIVATE -Wl,-all_load mindspore proto_input -Wl,-noall_load mindspore_core target_link_libraries(_c_expression PRIVATE -Wl,-all_load mindspore proto_input -Wl,-noall_load mindspore_core
mindspore_common) mindspore_common)
@@ -439,7 +450,7 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
else() else()
if(ENABLE_CPU AND NOT WIN32) if(ENABLE_CPU AND NOT WIN32)
target_link_libraries(mindspore PUBLIC proto_input mindspore::protobuf target_link_libraries(mindspore PUBLIC proto_input mindspore::protobuf
mindspore::event mindspore::event_pthreads mindspore::event_openssl mindspore::eigen mindspore::json)
mindspore::event_core mindspore::event_extra mindspore::event_pthreads mindspore::event_openssl mindspore::eigen mindspore::json)
target_link_libraries(mindspore PUBLIC -Wl,--no-as-needed mindspore::event_core ps_cache) target_link_libraries(mindspore PUBLIC -Wl,--no-as-needed mindspore::event_core ps_cache)
if(${ENABLE_IBVERBS} STREQUAL "ON") if(${ENABLE_IBVERBS} STREQUAL "ON")
target_link_libraries(mindspore PUBLIC ibverbs rdmacm) target_link_libraries(mindspore PUBLIC ibverbs rdmacm)
@@ -461,12 +472,12 @@ endif()
if(ENABLE_GPU) if(ENABLE_GPU)
message("add gpu lib to c_expression") message("add gpu lib to c_expression")
target_link_libraries(_c_expression PRIVATE gpu_cuda_lib gpu_queue cublas cuda_ops target_link_libraries(_c_expression PRIVATE gpu_cuda_lib gpu_queue cublas cuda_ops
${CUDA_PATH}/lib64/libcurand.so
CUDA::curand
${CUDNN_LIBRARY_PATH} ${CUDNN_LIBRARY_PATH}
${CUDA_PATH}/lib64/libcudart.so
${CUDA_PATH}/lib64/stubs/libcuda.so
${CUDA_PATH}/lib64/libcusolver.so
${CUDA_PATH}/lib64/libcufft.so)
CUDA::cudart
CUDA::cusolver
CUDA::cuda_driver
CUDA::cufft)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(_c_expression PRIVATE mindspore::crypto mindspore::ssl) target_link_libraries(_c_expression PRIVATE mindspore::crypto mindspore::ssl)
endif() endif()


+ 2
- 0
mindspore/ccsrc/backend/common/optimizer/CMakeLists.txt View File

@@ -13,3 +13,5 @@ endif()
set_property(SOURCE ${_PREACTIVATE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS set_property(SOURCE ${_PREACTIVATE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS
SUBMODULE_ID=mindspore::SubModuleId::SM_PRE_ACT) SUBMODULE_ID=mindspore::SubModuleId::SM_PRE_ACT)
add_library(_mindspore_backend_common_optimizer_obj OBJECT ${_PREACTIVATE_SRC_LIST}) add_library(_mindspore_backend_common_optimizer_obj OBJECT ${_PREACTIVATE_SRC_LIST})
target_link_libraries(_mindspore_backend_common_optimizer_obj PUBLIC mindspore::json
$<$<BOOL:${USE_GLOG}>:mindspore::glog>)

+ 1
- 0
mindspore/ccsrc/backend/common/pass/CMakeLists.txt View File

@@ -13,3 +13,4 @@ endif()
set_property(SOURCE ${_PREACTIVATE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS set_property(SOURCE ${_PREACTIVATE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS
SUBMODULE_ID=mindspore::SubModuleId::SM_PRE_ACT) SUBMODULE_ID=mindspore::SubModuleId::SM_PRE_ACT)
add_library(_mindspore_backend_common_pass_obj OBJECT ${_PREACTIVATE_SRC_LIST}) add_library(_mindspore_backend_common_pass_obj OBJECT ${_PREACTIVATE_SRC_LIST})
target_link_libraries(_mindspore_backend_common_pass_obj PUBLIC mindspore::json $<$<BOOL:${USE_GLOG}>:mindspore::glog>)

+ 47
- 42
mindspore/ccsrc/backend/common/session/CMakeLists.txt View File

@@ -1,42 +1,47 @@
file(GLOB_RECURSE _SESSION_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"kernel_build_client.cc"
"kernel_graph.cc"
"session_basic.cc"
"session_factory.cc"
"executor.cc"
"executor_manager.cc"
"anf_runtime_algorithm.cc"
"single_kernel_graph.cc"
)
if("${ENABLE_HIDDEN}" STREQUAL "OFF")
string(REPLACE " -Werror " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE " -fvisibility=hidden" " -fvisibility=default" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual -Wno-delete-abstract-non-virtual-dtor")
endif()
if(ENABLE_GPU)
file(GLOB_RECURSE _GPU_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "gpu_session.cc" "gpu_inference_session.cc")
list(APPEND _SESSION_SRC_LIST ${_GPU_SRC_LIST})
endif()
if(ENABLE_CPU)
file(GLOB_RECURSE _CPU_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "cpu_session.cc")
list(APPEND _SESSION_SRC_LIST ${_CPU_SRC_LIST})
endif()
if(ENABLE_D)
file(GLOB_RECURSE _D_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"ascend_session.cc"
"ascend_control_parser.cc"
"ascend_auto_monad.cc"
"ascend_inference_session.cc"
)
list(APPEND _SESSION_SRC_LIST ${_D_SRC_LIST})
endif()
set_property(SOURCE ${_SESSION_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_SESSION)
add_library(_mindspore_backend_common_session_obj OBJECT ${_SESSION_SRC_LIST})
file(GLOB_RECURSE _SESSION_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"kernel_build_client.cc"
"kernel_graph.cc"
"session_basic.cc"
"session_factory.cc"
"executor.cc"
"executor_manager.cc"
"anf_runtime_algorithm.cc"
"single_kernel_graph.cc"
)

if("${ENABLE_HIDDEN}" STREQUAL "OFF")
string(REPLACE " -Werror " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE " -fvisibility=hidden" " -fvisibility=default" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual -Wno-delete-abstract-non-virtual-dtor")
endif()

if(ENABLE_GPU)
file(GLOB_RECURSE _GPU_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "gpu_session.cc" "gpu_inference_session.cc")
list(APPEND _SESSION_SRC_LIST ${_GPU_SRC_LIST})
endif()

if(ENABLE_CPU)
file(GLOB_RECURSE _CPU_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "cpu_session.cc")
list(APPEND _SESSION_SRC_LIST ${_CPU_SRC_LIST})
endif()

if(ENABLE_D)
file(GLOB_RECURSE _D_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"ascend_session.cc"
"ascend_control_parser.cc"
"ascend_auto_monad.cc"
"ascend_inference_session.cc"
)
list(APPEND _SESSION_SRC_LIST ${_D_SRC_LIST})
endif()

set_property(SOURCE ${_SESSION_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_SESSION)
add_library(_mindspore_backend_common_session_obj OBJECT ${_SESSION_SRC_LIST})
target_link_libraries(_mindspore_backend_common_session_obj PUBLIC mindspore::protobuf mindspore::grpc++
mindspore::json mindspore::pybind11_module
$<$<BOOL:${USE_GLOG}>:mindspore::glog>
$<$<BOOL:${ENABLE_GPU}>:CUDA::cudart>
$<$<BOOL:${ENABLE_GPU}>:CUDA::cupti>)

+ 1
- 1
mindspore/ccsrc/backend/common/session/ascend_auto_monad.cc View File

@@ -70,7 +70,7 @@ void DumpAllGraphs(NotNull<KernelGraphPtr> kg, std::set<KernelGraphPtr> *memo) {
if (memo->find(kg) != memo->end()) { if (memo->find(kg) != memo->end()) {
return; return;
} }
memo->insert(kg);
memo->insert(kg.get());
std::string file_name = "ascend_auto_monad_" + std::to_string(kg->graph_id()) + ".ir"; std::string file_name = "ascend_auto_monad_" + std::to_string(kg->graph_id()) + ".ir";
DumpIR(file_name, kg.get()); DumpIR(file_name, kg.get());
for (auto &child : kg->child_graph_order()) { for (auto &child : kg->child_graph_order()) {


+ 2
- 2
mindspore/ccsrc/backend/common/session/ascend_session.cc View File

@@ -248,7 +248,7 @@ bool TensorNeedSync(const std::shared_ptr<KernelGraph> &kernel_graph, const AnfN
} }
MS_EXCEPTION_IF_NULL(memcpy_nums); MS_EXCEPTION_IF_NULL(memcpy_nums);
(*memcpy_nums)++; (*memcpy_nums)++;
#if ((defined ENABLE_CPU) && (!defined _WIN32))
#if ((defined ENABLE_CPU) && (defined ENABLE_D) && (!defined _WIN32))
const std::string &param_name = parameter->fullname_with_scope(); const std::string &param_name = parameter->fullname_with_scope();
if (ps::ps_cache_instance.IsHashTable(param_name)) { if (ps::ps_cache_instance.IsHashTable(param_name)) {
return false; return false;
@@ -347,7 +347,7 @@ void AscendSession::LoadInputData(const std::shared_ptr<KernelGraph> &kernel_gra
} }
if (AnfAlgo::OutputAddrExist(input_node, 0) && if (AnfAlgo::OutputAddrExist(input_node, 0) &&
TensorNeedSync(kernel_graph, input_node, tensor, &device_memcpy_nums)) { TensorNeedSync(kernel_graph, input_node, tensor, &device_memcpy_nums)) {
#if ((defined ENABLE_CPU) && (!defined _WIN32))
#if ((defined ENABLE_CPU) && (defined ENABLE_D) && (!defined _WIN32))
const std::string &param_name = input_node->fullname_with_scope(); const std::string &param_name = input_node->fullname_with_scope();
if (ps::ps_cache_instance.IsHashTable(param_name)) { if (ps::ps_cache_instance.IsHashTable(param_name)) {
continue; continue;


+ 2
- 0
mindspore/ccsrc/backend/common/somas/CMakeLists.txt View File

@@ -13,3 +13,5 @@ endif()
set_property(SOURCE ${_PREACTIVATE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS set_property(SOURCE ${_PREACTIVATE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS
SUBMODULE_ID=mindspore::SubModuleId::SM_PRE_ACT) SUBMODULE_ID=mindspore::SubModuleId::SM_PRE_ACT)
add_library(_mindspore_backend_common_somas_obj OBJECT ${_PREACTIVATE_SRC_LIST}) add_library(_mindspore_backend_common_somas_obj OBJECT ${_PREACTIVATE_SRC_LIST})
target_link_libraries(_mindspore_backend_common_somas_obj PRIVATE mindspore::protobuf mindspore::json
$<$<BOOL:${USE_GLOG}>:mindspore::glog>)

+ 4
- 3
mindspore/ccsrc/backend/common/somas/somas_solver_core.cc View File

@@ -307,9 +307,10 @@ size_t SomasSolverCore::Search(const std::shared_ptr<FootPrint> &pFootprint) {
if (all_ || is_multi_thread_valid_) { if (all_ || is_multi_thread_valid_) {
const double giga = 1073741824.; const double giga = 1073741824.;
MS_LOG(INFO) << timing_ << " ms\t" << sol_count_ + 1 << "/" MS_LOG(INFO) << timing_ << " ms\t" << sol_count_ + 1 << "/"
<< kNumFittingTypes * kNumAlgorithmTypes * kNumSortingTypes << "\t" << result << " Bytes ("
<< result / giga << " GB)\t" << algorithmTypeNames[algorithm_] << "\t"
<< sortingNames[sort_strategy_] << "\t" << branchingNames[branching_strategy_];
<< static_cast<int>(kNumFittingTypes) * static_cast<int>(kNumAlgorithmTypes) *
static_cast<int>(kNumSortingTypes)
<< "\t" << result << " Bytes (" << result / giga << " GB)\t" << algorithmTypeNames[algorithm_]
<< "\t" << sortingNames[sort_strategy_] << "\t" << branchingNames[branching_strategy_];
} }
} else { } else {
MS_LOG(INFO) << "FastSolver could not find solution"; MS_LOG(INFO) << "FastSolver could not find solution";


+ 6
- 1
mindspore/ccsrc/backend/graph_compiler/CMakeLists.txt View File

@@ -4,8 +4,13 @@ include_directories(${CMAKE_SOURCE_DIR}/mindspore/core/mindrt/src)
file(GLOB_RECURSE _GRAPH_COMPILER_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc") file(GLOB_RECURSE _GRAPH_COMPILER_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")
set_property(SOURCE ${_GRAPH_COMPILER_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_VM) set_property(SOURCE ${_GRAPH_COMPILER_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_VM)
add_library(_mindspore_backend_graph_compiler_obj OBJECT ${_GRAPH_COMPILER_SRC_LIST}) add_library(_mindspore_backend_graph_compiler_obj OBJECT ${_GRAPH_COMPILER_SRC_LIST})
target_link_libraries(_mindspore_backend_graph_compiler_obj PRIVATE mindspore::protobuf
mindspore::grpc++
mindspore::pybind11_module
mindspore::json
$<$<BOOL:${USE_GLOG}>:mindspore::glog>)


if("${ENABLE_HIDDEN}" STREQUAL "OFF") if("${ENABLE_HIDDEN}" STREQUAL "OFF")
string(REPLACE " -Werror " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE " -Werror " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE " -fvisibility=hidden" " -fvisibility=default" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE " -fvisibility=hidden" " -fvisibility=default" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
endif()

+ 3
- 0
mindspore/ccsrc/common/CMakeLists.txt View File

@@ -13,3 +13,6 @@ endif()
set_property(SOURCE ${_COMMON_ALL_SRC_FILES} PROPERTY COMPILE_DEFINITIONS set_property(SOURCE ${_COMMON_ALL_SRC_FILES} PROPERTY COMPILE_DEFINITIONS
SUBMODULE_ID=mindspore::SubModuleId::SM_COMMON) SUBMODULE_ID=mindspore::SubModuleId::SM_COMMON)
add_library(_mindspore_common_obj OBJECT ${_COMMON_ALL_SRC_FILES}) add_library(_mindspore_common_obj OBJECT ${_COMMON_ALL_SRC_FILES})
if(USE_GLOG)
target_link_libraries(_mindspore_common_obj PUBLIC mindspore::glog)
endif()

+ 3
- 3
mindspore/ccsrc/common/graph_kernel/add_atomic_clean.cc View File

@@ -540,11 +540,11 @@ std::vector<std::tuple<AnfNodePtr, int, AnfNodePtr>> AtomicCleanInsertter::FindO
} }
} }
} }
for (auto &[getitem_node, broadcast_to_node] : getitem_user_nodes) {
for (const auto& user_node: getitem_user_nodes) {
// Directory to find real user. // Directory to find real user.
auto real_users = mng->node_users()[getitem_node];
auto real_users = mng->node_users()[std::get<0>(user_node)];
(void)std::transform(real_users.cbegin(), real_users.cend(), std::back_inserter(reduce_user_nodes), (void)std::transform(real_users.cbegin(), real_users.cend(), std::back_inserter(reduce_user_nodes),
[&broadcast_to_node](const std::pair<AnfNodePtr, int> &pair) {
[&broadcast_to_node = std::get<1>(user_node)](const std::pair<AnfNodePtr, int> &pair) {
return std::make_tuple(pair.first, pair.second, broadcast_to_node); return std::make_tuple(pair.first, pair.second, broadcast_to_node);
}); });
} }


+ 3
- 3
mindspore/ccsrc/common/graph_kernel/parallel_fusion.cc View File

@@ -394,12 +394,12 @@ void DumpParallelGroups(const std::vector<std::vector<AnfNodePtrList>> &groups,
MS_LOG(INFO) << "[" << title << "]" MS_LOG(INFO) << "[" << title << "]"
<< "There are " << groups.size() << " parallel groups, their detail is: "; << "There are " << groups.size() << " parallel groups, their detail is: ";
int i = 0; int i = 0;
for (const auto group : groups) {
for (const auto& group : groups) {
std::stringstream buf; std::stringstream buf;
buf << "[" << i << " group] " << group.size() << ":\n"; buf << "[" << i << " group] " << group.size() << ":\n";
for (const auto nodes : group) {
for (const auto& nodes : group) {
buf << " " << nodes.size() << ": [<"; buf << " " << nodes.size() << ": [<";
for (const auto node : nodes) {
for (const auto& node : nodes) {
buf << "(" << DumpNode(node) << ") -> "; buf << "(" << DumpNode(node) << ") -> ";
} }
buf << ">]\n"; buf << ">]\n";


+ 2
- 0
mindspore/ccsrc/common/mem_reuse/CMakeLists.txt View File

@@ -13,3 +13,5 @@ endif()
set_property(SOURCE ${_PREACTIVATE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS set_property(SOURCE ${_PREACTIVATE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS
SUBMODULE_ID=mindspore::SubModuleId::SM_PRE_ACT) SUBMODULE_ID=mindspore::SubModuleId::SM_PRE_ACT)
add_library(_mindspore_common_mem_reuse_obj OBJECT ${_PREACTIVATE_SRC_LIST}) add_library(_mindspore_common_mem_reuse_obj OBJECT ${_PREACTIVATE_SRC_LIST})
target_link_libraries(_mindspore_common_mem_reuse_obj PRIVATE mindspore::protobuf mindspore::grpc++ mindspore::json
$<$<BOOL:${USE_GLOG}>:mindspore::glog>)

+ 11
- 6
mindspore/ccsrc/cxx_api/CMakeLists.txt View File

@@ -77,7 +77,11 @@ if(BUILD_LITE)
endif() endif()


add_library(mindspore_shared_lib_obj OBJECT ${MSLIB_SRC}) add_library(mindspore_shared_lib_obj OBJECT ${MSLIB_SRC})
target_link_libraries(mindspore_shared_lib_obj PRIVATE mindspore::protobuf mindspore::grpc++ mindspore::json
mindspore::pybind11_module)

add_library(mindspore_shared_lib SHARED $<TARGET_OBJECTS:mindspore_shared_lib_obj>) add_library(mindspore_shared_lib SHARED $<TARGET_OBJECTS:mindspore_shared_lib_obj>)
target_link_libraries(mindspore_shared_lib_obj PUBLIC mindspore::opencv_core $<$<BOOL:${ENABLE_GPU}>:CUDA::cuda_driver>)
if(BUILD_LITE) if(BUILD_LITE)
target_link_libraries(mindspore_shared_lib PRIVATE $<TARGET_OBJECTS:_mindspore_transform_graph_ir_obj>) target_link_libraries(mindspore_shared_lib PRIVATE $<TARGET_OBJECTS:_mindspore_transform_graph_ir_obj>)
add_dependencies(mindspore_shared_lib _mindspore_transform_graph_ir_obj) add_dependencies(mindspore_shared_lib _mindspore_transform_graph_ir_obj)
@@ -106,6 +110,7 @@ if(ENABLE_CPU)
endif() endif()


if(USE_GLOG) if(USE_GLOG)
target_link_libraries(mindspore_shared_lib_obj PRIVATE mindspore::glog)
target_link_libraries(mindspore_shared_lib PRIVATE mindspore::glog) target_link_libraries(mindspore_shared_lib PRIVATE mindspore::glog)
endif() endif()


@@ -142,13 +147,13 @@ if(ENABLE_D)
endif() endif()


if(ENABLE_GPU) if(ENABLE_GPU)
target_link_libraries(mindspore_shared_lib PRIVATE gpu_cuda_lib gpu_queue cublas cuda_ops
${CUDA_PATH}/lib64/libcurand.so
target_link_libraries(mindspore_shared_lib PRIVATE gpu_cuda_lib gpu_queue CUDA::cublas cuda_ops
CUDA::curand
${CUDNN_LIBRARY_PATH} ${CUDNN_LIBRARY_PATH}
${CUDA_PATH}/lib64/libcudart.so
${CUDA_PATH}/lib64/stubs/libcuda.so
${CUDA_PATH}/lib64/libcusolver.so
${CUDA_PATH}/lib64/libcufft.so)
CUDA::cudart
CUDA::cuda_driver
CUDA::cusolver
CUDA::cufft)
endif() endif()


if(CMAKE_SYSTEM_NAME MATCHES "Linux") if(CMAKE_SYSTEM_NAME MATCHES "Linux")


+ 6
- 1
mindspore/ccsrc/debug/CMakeLists.txt View File

@@ -66,15 +66,20 @@ endif()
set_property(SOURCE ${_DEBUG_SRC_LIST} ${_RDR_SRC_LIST} PROPERTY COMPILE_DEFINITIONS set_property(SOURCE ${_DEBUG_SRC_LIST} ${_RDR_SRC_LIST} PROPERTY COMPILE_DEFINITIONS
SUBMODULE_ID=mindspore::SubModuleId::SM_DEBUG) SUBMODULE_ID=mindspore::SubModuleId::SM_DEBUG)
add_library(_mindspore_debug_obj OBJECT ${_DEBUG_SRC_LIST} ${_RDR_SRC_LIST}) add_library(_mindspore_debug_obj OBJECT ${_DEBUG_SRC_LIST} ${_RDR_SRC_LIST})
target_link_libraries(_mindspore_debug_obj PRIVATE mindspore::protobuf mindspore::grpc++ mindspore::json
mindspore::pybind11_module $<$<BOOL:${USE_GLOG}>:mindspore::glog>)

if(ENABLE_DEBUGGER) if(ENABLE_DEBUGGER)
if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows") if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
add_compile_options(-Wall -DOFFLINE_DBG_MODE -fPIC -O2)
add_compile_options(-Wall -DOFFLINE_DBG_MODE -O2)
set_property(SOURCE ${_OFFLINE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS set_property(SOURCE ${_OFFLINE_SRC_LIST} PROPERTY COMPILE_DEFINITIONS
SUBMODULE_ID=mindspore::SubModuleId::SM_OFFLINE_DEBUG) SUBMODULE_ID=mindspore::SubModuleId::SM_OFFLINE_DEBUG)
add_library(_mindspore_offline_debug SHARED ${_OFFLINE_SRC_LIST}) add_library(_mindspore_offline_debug SHARED ${_OFFLINE_SRC_LIST})
target_link_libraries(_mindspore_offline_debug PRIVATE target_link_libraries(_mindspore_offline_debug PRIVATE
mindspore::pybind11_module mindspore::pybind11_module
mindspore_core mindspore_core
mindspore::json
$<$<BOOL:${USE_GLOG}>:mindspore::glog>
) )
set_target_properties(_mindspore_offline_debug PROPERTIES set_target_properties(_mindspore_offline_debug PROPERTIES
PREFIX "${PYTHON_MODULE_PREFIX}" PREFIX "${PYTHON_MODULE_PREFIX}"


+ 1
- 0
mindspore/ccsrc/debug/env_config_parser.h View File

@@ -20,6 +20,7 @@
#include <map> #include <map>
#include <set> #include <set>
#include <mutex> #include <mutex>
#include <optional>
#include "nlohmann/json.hpp" #include "nlohmann/json.hpp"
#include "utils/ms_utils.h" #include "utils/ms_utils.h"
namespace mindspore { namespace mindspore {


+ 2
- 0
mindspore/ccsrc/distributed/CMakeLists.txt View File

@@ -20,3 +20,5 @@ endif()
set_property(SOURCE ${_DISTRIBUTED_SRC_FILES} PROPERTY COMPILE_DEFINITIONS set_property(SOURCE ${_DISTRIBUTED_SRC_FILES} PROPERTY COMPILE_DEFINITIONS
SUBMODULE_ID=mindspore::SubModuleId::SM_DISTRIBUTED) SUBMODULE_ID=mindspore::SubModuleId::SM_DISTRIBUTED)
add_library(_mindspore_distributed_obj OBJECT ${_DISTRIBUTED_SRC_FILES}) add_library(_mindspore_distributed_obj OBJECT ${_DISTRIBUTED_SRC_FILES})
target_link_libraries(_mindspore_distributed_obj PRIVATE mindspore::protobuf mindspore::json mindspore::pybind11_module
$<$<BOOL:${USE_GLOG}>:mindspore::glog>)

+ 2
- 1
mindspore/ccsrc/fl/CMakeLists.txt View File

@@ -61,5 +61,6 @@ list(LENGTH _FL_SRC_FILES fl_file_num)
if(NOT fl_file_num EQUAL 0) if(NOT fl_file_num EQUAL 0)
set_property(SOURCE ${_FL_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_FL) set_property(SOURCE ${_FL_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_FL)
add_library(_mindspore_fl_obj OBJECT ${_FL_SRC_FILES}) add_library(_mindspore_fl_obj OBJECT ${_FL_SRC_FILES})
target_link_libraries(_mindspore_fl_obj mindspore::flatbuffers)
target_link_libraries(_mindspore_fl_obj PUBLIC mindspore::flatbuffers mindspore::protobuf mindspore::json
$<$<BOOL:${USE_GLOG}>:mindspore::glog>)
endif() endif()

+ 7
- 4
mindspore/ccsrc/frontend/operator/CMakeLists.txt View File

@@ -1,4 +1,7 @@
file(GLOB_RECURSE _OPERATOR_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")
set_property(SOURCE ${_OPERATOR_SRC_FILES} PROPERTY COMPILE_DEFINITIONS
SUBMODULE_ID=mindspore::SubModuleId::SM_ANALYZER)
add_library(_mindspore_frontend_operator_obj OBJECT ${_OPERATOR_SRC_FILES})
file(GLOB_RECURSE _OPERATOR_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")
set_property(SOURCE ${_OPERATOR_SRC_FILES} PROPERTY COMPILE_DEFINITIONS
SUBMODULE_ID=mindspore::SubModuleId::SM_ANALYZER)
add_library(_mindspore_frontend_operator_obj OBJECT ${_OPERATOR_SRC_FILES})

target_link_libraries(_mindspore_frontend_operator_obj PUBLIC mindspore::pybind11_module
$<$<BOOL:${USE_GLOG}>:mindspore::glog>)

+ 12
- 9
mindspore/ccsrc/frontend/optimizer/CMakeLists.txt View File

@@ -1,9 +1,12 @@
file(GLOB_RECURSE _OPTIMIZER_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-abstract-non-virtual-dtor")
endif()
set_property(SOURCE ${_OPTIMIZER_SRC_FILES} PROPERTY COMPILE_DEFINITIONS
SUBMODULE_ID=mindspore::SubModuleId::SM_OPTIMIZER)
add_library(_mindspore_frontend_optimizer_obj OBJECT ${_OPTIMIZER_SRC_FILES})
file(GLOB_RECURSE _OPTIMIZER_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")

if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-abstract-non-virtual-dtor")
endif()

set_property(SOURCE ${_OPTIMIZER_SRC_FILES} PROPERTY COMPILE_DEFINITIONS
SUBMODULE_ID=mindspore::SubModuleId::SM_OPTIMIZER)
add_library(_mindspore_frontend_optimizer_obj OBJECT ${_OPTIMIZER_SRC_FILES})
target_link_libraries(_mindspore_frontend_optimizer_obj PRIVATE mindspore::protobuf mindspore::grpc++
mindspore::pybind11_module mindspore::json
$<$<BOOL:${USE_GLOG}>:mindspore::glog>)

+ 3
- 0
mindspore/ccsrc/frontend/parallel/CMakeLists.txt View File

@@ -16,3 +16,6 @@ endif()
set_property(SOURCE ${_PARALLEL_SRC_FILES} PROPERTY COMPILE_DEFINITIONS set_property(SOURCE ${_PARALLEL_SRC_FILES} PROPERTY COMPILE_DEFINITIONS
SUBMODULE_ID=mindspore::SubModuleId::SM_PARALLEL) SUBMODULE_ID=mindspore::SubModuleId::SM_PARALLEL)
add_library(_mindspore_frontend_parallel_obj OBJECT ${_PARALLEL_SRC_FILES}) add_library(_mindspore_frontend_parallel_obj OBJECT ${_PARALLEL_SRC_FILES})
target_link_libraries(_mindspore_frontend_parallel_obj PRIVATE mindspore::protobuf mindspore::grpc++
mindspore::pybind11_module mindspore::json
$<$<BOOL:${USE_GLOG}>:mindspore::glog>)

+ 1
- 0
mindspore/ccsrc/frontend/parallel/auto_parallel/rec_core/rec_cost.h View File

@@ -18,6 +18,7 @@
#define PARALLEL_AUTO_PARALLEL_REC_COST_H_ #define PARALLEL_AUTO_PARALLEL_REC_COST_H_


#include <iostream> #include <iostream>
#include <limits>
#include <memory> #include <memory>
#include <string> #include <string>
#include <utility> #include <utility>


+ 2
- 0
mindspore/ccsrc/kernel/CMakeLists.txt View File

@@ -22,3 +22,5 @@ endif()


set_property(SOURCE ${KERNEL_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_KERNEL) set_property(SOURCE ${KERNEL_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_KERNEL)
add_library(_mindspore_kernel_obj OBJECT ${KERNEL_SRC_LIST}) add_library(_mindspore_kernel_obj OBJECT ${KERNEL_SRC_LIST})
target_link_libraries(_mindspore_kernel_obj PUBLIC mindspore::json mindspore::pybind11_module
$<$<BOOL:${USE_GLOG}>:mindspore::glog>)

+ 3
- 2
mindspore/ccsrc/kernel/akg/akg_kernel_json_generator.cc View File

@@ -907,8 +907,9 @@ void AkgKernelJsonGenerator::GenParallelJson(const std::vector<AnfNodePtr> &anf_
auto output_index = GetOutputIndex(anf_nodes, input_list, output_list); auto output_index = GetOutputIndex(anf_nodes, input_list, output_list);
for (size_t i = 0; i < output_index.size(); ++i) { for (size_t i = 0; i < output_index.size(); ++i) {
auto [tmp_output, tmp_output_index] = output_index[i]; auto [tmp_output, tmp_output_index] = output_index[i];
bool found = std::any_of(input_list.cbegin(), input_list.cend(),
[&tmp_output](const AnfNodePtr &in) { return tmp_output == in; });
bool found =
std::any_of(input_list.cbegin(), input_list.cend(),
[&tmp_output = std::get<0>(output_index[i])](const AnfNodePtr &in) { return tmp_output == in; });
if (!found) { if (!found) {
auto tcnode = tmp_output->cast<CNodePtr>(); auto tcnode = tmp_output->cast<CNodePtr>();
if (tcnode == nullptr) { if (tcnode == nullptr) {


+ 3
- 3
mindspore/ccsrc/minddata/dataset/CMakeLists.txt View File

@@ -225,7 +225,7 @@ else()
else() else()
target_link_libraries(_c_dataengine PRIVATE -ldl ${SECUREC_LIBRARY}) target_link_libraries(_c_dataengine PRIVATE -ldl ${SECUREC_LIBRARY})
endif() endif()
target_link_libraries(_c_dataengine PUBLIC mindspore::sentencepiece)
target_link_libraries(_c_dataengine PUBLIC $<$<BOOL:${ENABLE_MINDDATA}>:mindspore::sentencepiece>)
endif() endif()


target_link_libraries(_c_dataengine PUBLIC mindspore::jpeg_turbo mindspore::turbojpeg mindspore::opencv_core target_link_libraries(_c_dataengine PUBLIC mindspore::jpeg_turbo mindspore::turbojpeg mindspore::opencv_core
@@ -234,8 +234,8 @@ target_link_libraries(_c_dataengine PUBLIC mindspore::jpeg_turbo mindspore::turb
if(ENABLE_GPUQUE) if(ENABLE_GPUQUE)
target_link_libraries(_c_dataengine PRIVATE gpu_queue target_link_libraries(_c_dataengine PRIVATE gpu_queue
${CUDNN_LIBRARY_PATH} ${CUDNN_LIBRARY_PATH}
${CUDA_PATH}/lib64/libcudart.so
${CUDA_PATH}/lib64/stubs/libcuda.so)
CUDA::cudart
CUDA::cuda_driver)
endif() endif()


if(ENABLE_TDTQUE) if(ENABLE_TDTQUE)


+ 14
- 1
mindspore/ccsrc/minddata/dataset/api/CMakeLists.txt View File

@@ -25,7 +25,13 @@ if(ENABLE_PYTHON)
python/pybind_conversion.cc python/pybind_conversion.cc
python/pybind_register.cc python/pybind_register.cc
) )
target_include_directories(APItoPython PRIVATE ${pybind11_INCLUDE_DIRS})
target_link_libraries(APItoPython PUBLIC core_headers $<$<BOOL:${ENABLE_GPU}>:CUDA::cudart>
pybind11::headers mindspore::eigen mindspore::protobuf mindspore::grpc++
mindspore::flatbuffers mindspore::absl_strings mindspore::json
mindspore::pybind11_module mindspore::jpeg_turbo
$<$<BOOL:${USE_GLOG}>:mindspore::glog>
$<$<BOOL:${ENABLE_MINDDATA}>:mindspore::sentencepiece>)
target_compile_definitions(APItoPython PRIVATE _USE_TF_STRING_VIEW)
endif() endif()


add_library(cpp-API OBJECT add_library(cpp-API OBJECT
@@ -40,3 +46,10 @@ add_library(cpp-API OBJECT
text.cc text.cc
vision.cc vision.cc
) )
target_link_libraries(cpp-API PUBLIC core_headers $<$<BOOL:${ENABLE_GPU}>:CUDA::cudart>
mindspore::eigen mindspore::protobuf mindspore::json mindspore::grpc++
mindspore::flatbuffers mindspore::absl_strings mindspore::json
mindspore::pybind11_module mindspore::jpeg_turbo
$<$<BOOL:${USE_GLOG}>:mindspore::glog>
$<$<BOOL:${ENABLE_MINDDATA}>:mindspore::sentencepiece>)
target_compile_definitions(cpp-API PRIVATE _USE_TF_STRING_VIEW)

+ 2
- 0
mindspore/ccsrc/minddata/dataset/audio/ir/CMakeLists.txt View File

@@ -4,3 +4,5 @@ file(GLOB_RECURSE _CURRENT_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc"
set_property(SOURCE ${_CURRENT_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_MD) set_property(SOURCE ${_CURRENT_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_MD)


add_library(audio-ir OBJECT validators.cc) add_library(audio-ir OBJECT validators.cc)
target_link_libraries(audio-ir PUBLIC core_headers mindspore::protobuf mindspore::pybind11_module
mindspore::json $<$<BOOL:${USE_GLOG}>:mindspore::glog>)

+ 49
- 45
mindspore/ccsrc/minddata/dataset/audio/ir/kernels/CMakeLists.txt View File

@@ -1,47 +1,51 @@
file(GLOB_RECURSE _CURRENT_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")
file(
GLOB_RECURSE _CURRENT_SRC_FILES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"*.cc")
set_property(SOURCE ${_CURRENT_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_MD) set_property(SOURCE ${_CURRENT_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_MD)


add_library(audio-ir-kernels OBJECT
allpass_biquad_ir.cc
amplitude_to_db_ir.cc
angle_ir.cc
band_biquad_ir.cc
bandpass_biquad_ir.cc
bandreject_biquad_ir.cc
bass_biquad_ir.cc
biquad_ir.cc
complex_norm_ir.cc
compute_deltas_ir.cc
contrast_ir.cc
db_to_amplitude_ir.cc
dc_shift_ir.cc
deemph_biquad_ir.cc
detect_pitch_frequency_ir.cc
dither_ir.cc
equalizer_biquad_ir.cc
fade_ir.cc
flanger_ir.cc
frequency_masking_ir.cc
gain_ir.cc
highpass_biquad_ir.cc
lfilter_ir.cc
lowpass_biquad_ir.cc
magphase_ir.cc
mask_along_axis_iid_ir.cc
mask_along_axis_ir.cc
mel_scale_ir.cc
mu_law_decoding_ir.cc
mu_law_encoding_ir.cc
overdrive_ir.cc
phase_vocoder_ir.cc
phaser_ir.cc
riaa_biquad_ir.cc
sliding_window_cmn_ir.cc
spectral_centroid_ir.cc
spectrogram_ir.cc
time_masking_ir.cc
time_stretch_ir.cc
treble_biquad_ir.cc
vol_ir.cc
)

add_library(
audio-ir-kernels OBJECT
allpass_biquad_ir.cc
amplitude_to_db_ir.cc
angle_ir.cc
band_biquad_ir.cc
bandpass_biquad_ir.cc
bandreject_biquad_ir.cc
bass_biquad_ir.cc
biquad_ir.cc
complex_norm_ir.cc
compute_deltas_ir.cc
contrast_ir.cc
db_to_amplitude_ir.cc
dc_shift_ir.cc
deemph_biquad_ir.cc
detect_pitch_frequency_ir.cc
dither_ir.cc
equalizer_biquad_ir.cc
fade_ir.cc
flanger_ir.cc
frequency_masking_ir.cc
gain_ir.cc
highpass_biquad_ir.cc
lfilter_ir.cc
lowpass_biquad_ir.cc
magphase_ir.cc
mask_along_axis_iid_ir.cc
mask_along_axis_ir.cc
mel_scale_ir.cc
mu_law_decoding_ir.cc
mu_law_encoding_ir.cc
overdrive_ir.cc
phase_vocoder_ir.cc
phaser_ir.cc
riaa_biquad_ir.cc
sliding_window_cmn_ir.cc
spectral_centroid_ir.cc
spectrogram_ir.cc
time_masking_ir.cc
time_stretch_ir.cc
treble_biquad_ir.cc
vol_ir.cc)
target_link_libraries(audio-ir-kernels PUBLIC core_headers mindspore::eigen mindspore::protobuf mindspore::json
mindspore::pybind11_module $<$<BOOL:${USE_GLOG}>:mindspore::glog>)

+ 2
- 1
mindspore/ccsrc/minddata/dataset/audio/kernels/CMakeLists.txt View File

@@ -45,4 +45,5 @@ add_library(audio-kernels OBJECT
treble_biquad_op.cc treble_biquad_op.cc
vol_op.cc vol_op.cc
) )

target_link_libraries(audio-kernels PUBLIC core_headers mindspore::eigen mindspore::protobuf mindspore::pybind11_module
mindspore::json $<$<BOOL:${USE_GLOG}>:mindspore::glog>)

+ 3
- 1
mindspore/ccsrc/minddata/dataset/callback/CMakeLists.txt View File

@@ -11,4 +11,6 @@ else()
add_library(callback OBJECT add_library(callback OBJECT
callback_manager.cc callback_manager.cc
) )
endif()
endif()
target_link_libraries(callback PUBLIC core_headers mindspore::protobuf mindspore::json
mindspore::pybind11_module $<$<BOOL:${USE_GLOG}>:mindspore::glog>)

+ 9
- 2
mindspore/ccsrc/minddata/dataset/core/CMakeLists.txt View File

@@ -24,10 +24,17 @@ endif()
ms_protobuf_generate(EXAMPLE_SRCS EXAMPLE_HDRS example.proto) ms_protobuf_generate(EXAMPLE_SRCS EXAMPLE_HDRS example.proto)
ms_protobuf_generate(FEATURE_SRCS FEATURE_HDRS feature.proto) ms_protobuf_generate(FEATURE_SRCS FEATURE_HDRS feature.proto)
add_library(core OBJECT ${DATASET_CORE_SRC_FILES} ${EXAMPLE_SRCS} ${FEATURE_SRCS}) add_library(core OBJECT ${DATASET_CORE_SRC_FILES} ${EXAMPLE_SRCS} ${FEATURE_SRCS})
add_dependencies(core mindspore::protobuf)
target_link_libraries(core PUBLIC mindspore::json mindspore::pybind11_module mindspore::protobuf mindspore::jpeg_turbo
$<$<BOOL:${ENABLE_MINDDATA}>:mindspore::sentencepiece>
$<$<BOOL:${ENABLE_GPU}>:CUDA::cuda_driver>)

add_library(core_headers INTERFACE)
target_link_libraries(core_headers INTERFACE $<TARGET_NAME_IF_EXISTS:mindspore::opencv_core>)

target_link_libraries(core PUBLIC core_headers)


if(ENABLE_PYTHON) if(ENABLE_PYTHON)
target_include_directories(core PRIVATE ${pybind11_INCLUDE_DIRS})
target_include_directories(core PRIVATE pybind11::headers)
endif() endif()


if(MSLITE_ENABLE_CLOUD_MIND_DATA) if(MSLITE_ENABLE_CLOUD_MIND_DATA)


+ 1
- 1
mindspore/ccsrc/minddata/dataset/core/pybind_support.h View File

@@ -70,7 +70,7 @@ struct npy_format_descriptor<float16> {
handle ptr = npy_api::get().PyArray_DescrFromType_(kNpyFloat16); handle ptr = npy_api::get().PyArray_DescrFromType_(kNpyFloat16);
return reinterpret_borrow<pybind11::dtype>(ptr); return reinterpret_borrow<pybind11::dtype>(ptr);
} }
virtual ~npy_format_descriptor<float16>() {}
virtual ~npy_format_descriptor() {}


static std::string format() { static std::string format() {
// following: https://docs.python.org/3/library/struct.html#format-characters // following: https://docs.python.org/3/library/struct.html#format-characters


+ 8
- 1
mindspore/ccsrc/minddata/dataset/engine/CMakeLists.txt View File

@@ -38,9 +38,16 @@ if(ENABLE_PYTHON)
endif() endif()


add_library(engine OBJECT ${SRC_FILES_LIST}) add_library(engine OBJECT ${SRC_FILES_LIST})
target_link_libraries(engine PUBLIC core_headers
mindspore::protobuf
mindspore::json
mindspore::jpeg_turbo
$<$<BOOL:${USE_GLOG}>:mindspore::glog>
$<$<BOOL:${ENABLE_MINDDATA}>:mindspore::sentencepiece>
$<$<BOOL:${ENABLE_GPU}>:CUDA::cudart>)


if(ENABLE_PYTHON) if(ENABLE_PYTHON)
target_include_directories(engine PRIVATE ${pybind11_INCLUDE_DIRS})
target_link_libraries(engine PRIVATE pybind11::headers)
endif() endif()


add_dependencies(engine add_dependencies(engine


+ 29
- 15
mindspore/ccsrc/minddata/dataset/engine/cache/CMakeLists.txt View File

@@ -36,6 +36,9 @@ add_library(engine-cache-client OBJECT
cache_client.cc cache_client.cc
cache_fbb.cc cache_fbb.cc
cache_request.cc) cache_request.cc)
target_link_libraries(engine-cache-client PUBLIC core_headers mindspore::protobuf mindspore::flatbuffers
mindspore::grpc++ mindspore::json mindspore::pybind11_module
mindspore::jpeg_turbo $<$<BOOL:${USE_GLOG}>:mindspore::glog>)


if(CMAKE_SYSTEM_NAME MATCHES "Darwin") if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-abstract-non-virtual-dtor") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-abstract-non-virtual-dtor")
@@ -61,6 +64,10 @@ if(ENABLE_CACHE)
cache_server.cc cache_server.cc
storage_manager.cc storage_manager.cc
storage_container.cc) storage_container.cc)
target_link_libraries(engine-cache-server PUBLIC core_headers mindspore::protobuf mindspore::flatbuffers
mindspore::grpc++ mindspore::pybind11_module mindspore::json
$<$<BOOL:${USE_GLOG}>:mindspore::glog>
$<$<BOOL:${ENABLE_GPU}>:CUDA::cudart>)


if(ENABLE_ASAN) if(ENABLE_ASAN)
target_compile_options(engine-cache-server PRIVATE -fsanitize=address) target_compile_options(engine-cache-server PRIVATE -fsanitize=address)
@@ -71,7 +78,7 @@ if(ENABLE_CACHE)


add_executable(cache_server cache_main.cc) add_executable(cache_server cache_main.cc)
if(ENABLE_GPU) if(ENABLE_GPU)
target_link_libraries(cache_server
target_link_libraries(cache_server PUBLIC
engine-cache-server engine-cache-server
_c_dataengine _c_dataengine
_c_mindrecord _c_mindrecord
@@ -85,9 +92,10 @@ if(ENABLE_CACHE)
pthread pthread
-ldl -ldl
-Wl,--no-as-needed -Wl,--no-as-needed
mindspore::grpc++)
mindspore::grpc++
-Wl,--as-needed)
else() else()
target_link_libraries(cache_server
target_link_libraries(cache_server PUBLIC
mindspore mindspore
engine-cache-server engine-cache-server
_c_dataengine _c_dataengine
@@ -99,41 +107,47 @@ if(ENABLE_CACHE)
pthread pthread
-ldl) -ldl)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin") if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
target_link_libraries(cache_server mindspore::grpc++)
target_link_libraries(cache_server PUBLIC mindspore::grpc++)
else() else()
target_link_libraries(cache_server
target_link_libraries(cache_server PUBLIC
-Wl,--no-as-needed -Wl,--no-as-needed
mindspore::grpc++ mindspore::grpc++
-Wl,--as-needed) -Wl,--as-needed)
endif() endif()
endif() endif()
target_link_libraries(cache_server PUBLIC core_headers $<$<BOOL:${ENABLE_GPU}>:CUDA::cudart>)


if(USE_GLOG) if(USE_GLOG)
target_link_libraries(cache_server mindspore::glog)
target_link_libraries(cache_server PUBLIC mindspore::glog)
endif() endif()


if(NUMA_FOUND) if(NUMA_FOUND)
target_link_libraries(cache_server numa)
target_link_libraries(cache_server PUBLIC numa)
endif() endif()


add_executable(cache_admin cache_admin.cc cache_admin_arg.cc) add_executable(cache_admin cache_admin.cc cache_admin_arg.cc)
target_link_libraries(cache_admin _c_dataengine _c_mindrecord ${PYTHON_LIBRARIES} pthread -ldl)
target_link_libraries(cache_admin PUBLIC _c_dataengine
_c_mindrecord
core_headers
mindspore::flatbuffers
mindspore::grpc++
mindspore::json
mindspore::pybind11_module
$<$<BOOL:${USE_GLOG}>:mindspore::glog>
$<$<BOOL:${ENABLE_GPU}>:CUDA::cudart>
${PYTHON_LIBRARIES} pthread -ldl)
if(ENABLE_TDTQUE) if(ENABLE_TDTQUE)
target_link_libraries(cache_admin
target_link_libraries(cache_admin PUBLIC
-Wl,--start-group mindspore::protobuf mindspore_core mindspore_shared_lib ${ACL_TDT_CHANNEL} -Wl,--end-group) -Wl,--start-group mindspore::protobuf mindspore_core mindspore_shared_lib ${ACL_TDT_CHANNEL} -Wl,--end-group)
else() else()
if(CMAKE_SYSTEM_NAME MATCHES "Darwin") if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
target_link_libraries(cache_admin mindspore::protobuf mindspore_core mindspore_shared_lib)
target_link_libraries(cache_admin PUBLIC mindspore::protobuf mindspore_core mindspore_shared_lib)
else() else()
target_link_libraries(cache_admin
target_link_libraries(cache_admin PUBLIC
-Wl,--start-group mindspore::protobuf mindspore_core mindspore_shared_lib -Wl,--end-group) -Wl,--start-group mindspore::protobuf mindspore_core mindspore_shared_lib -Wl,--end-group)
endif() endif()
endif() endif()


if(USE_GLOG)
target_link_libraries(cache_admin mindspore::glog)
endif()

add_dependencies(engine-cache-server generated_engine_files) add_dependencies(engine-cache-server generated_engine_files)


set_target_properties(cache_admin PROPERTIES INSTALL_RPATH ${MINDSPORE_RPATH}) set_target_properties(cache_admin PROPERTIES INSTALL_RPATH ${MINDSPORE_RPATH})


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save