Skip to content

Commit ffa93cf

Browse files
authored
ci: cmake refine, prepare for conan/vcpkg (#231)
Signed-off-by: Ji Bin <[email protected]>
1 parent b8cae85 commit ffa93cf

15 files changed

+208
-697
lines changed

.github/workflows/main.yaml

-30
Original file line numberDiff line numberDiff line change
@@ -76,40 +76,13 @@ jobs:
7676
- name: Prepare
7777
run: |
7878
sh scripts/install_deps.sh
79-
- name: Build
80-
run: |
81-
make
8279
- name: Lint
8380
if: ${{ matrix.os.distro == 'Ubuntu' }}
8481
run: |
8582
make lint
8683
- name: Uint Testing
8784
run: |
8885
make test
89-
- name: Build Packages
90-
if: ${{ false }}
91-
run: |
92-
make package
93-
- name: Build with examples apk
94-
# disabled currently
95-
if: ${{ false && matrix.os.distro == 'Ubuntu' }}
96-
run: |
97-
set -e
98-
dpkg -i cmake_build/src/Pack/libmilvus*amd64.deb
99-
mkdir -p cmake_build_example
100-
cd cmake_build_example
101-
cmake ../examples
102-
make -j
103-
- name: Build with examples rpm
104-
# disabled currently
105-
if: ${{ false && (matrix.os.distro == 'CentOS' || matrix.os.distro == 'Fedora') }}
106-
run: |
107-
set -e
108-
yum install -y cmake_build/src/Pack/libmilvus{-devel,}-2*.rpm
109-
mkdir -p cmake_build_example
110-
cd cmake_build_example
111-
cmake ../examples
112-
make -j
11386
st-ubuntu:
11487
name: Test all with coverage
11588
runs-on: ubuntu-${{ matrix.ubuntu }}
@@ -176,9 +149,6 @@ jobs:
176149
- name: Prepare
177150
run: |
178151
sh scripts/install_deps.sh
179-
- name: Build
180-
run: |
181-
make
182152
- name: Uint Testing
183153
run: |
184154
make test

CMakeLists.txt

+36-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# limitations under the License.
1616

1717
cmake_minimum_required(VERSION 3.12)
18-
project(milvus_sdk LANGUAGES CXX C)
18+
project(milvus_sdk LANGUAGES CXX)
1919

2020
set(CMAKE_VERBOSE_MAKEFILE OFF)
2121
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -27,26 +27,52 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
2727
cmake_policy(SET CMP0135 NEW)
2828
endif()
2929

30+
# enable ccache if possible
3031
find_program(CCACHE_FOUND ccache)
3132
if(CCACHE_FOUND)
3233
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
3334
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
3435
endif(CCACHE_FOUND)
3536

3637
include(FindPython)
37-
include(DefineOptions)
38-
include(BuildUtils)
3938
include(FindClangTools)
40-
include(ThirdPartyPackages)
4139
include(GoogleTest)
4240
include(CTest)
4341

42+
include(DefineOptions)
43+
include(ThirdPartyPackages)
44+
include(MilvusProtoGen)
45+
46+
# options
47+
48+
set_option_category("Build")
49+
50+
define_option(BUILD_TEST "Build with testing" OFF)
51+
define_option(BUILD_COVERAGE "Build with coverage" OFF)
52+
define_option(BUILD_SHARED "Build with shared" ON)
53+
define_option(BUILD_STATIC "Build with static" OFF)
54+
define_option_string(MILVUS_SDK_VERSION
55+
"Version for sdk"
56+
"2.0.0")
57+
define_option_string(MILVUS_SDK_RELEASE
58+
"Release number for sdk"
59+
"1")
60+
61+
set_option_category("Thirdparty")
62+
# use thirdparty from:
63+
# auto: Find -> Fetch_Content_Then_Find
64+
# package: Find
65+
# module: Fetch_Content_Then_Find
66+
define_option_string(MILVUS_WITH_GRPC "Using gRPC from" "module" "package" "module")
67+
define_option_string(MILVUS_WITH_ZLIB "Using Zlib from" "module" "package" "module")
68+
define_option_string(MILVUS_WITH_NLOHMANN_JSON "nlohmann json from" "module" "package" "module")
69+
define_option_string(MILVUS_WITH_GTEST "Using GTest from" "module" "package" "module")
70+
71+
4472
set(CMAKE_CXX_STANDARD 11)
4573
set(CMAKE_CXX_STANDARD_REQUIRED on)
4674
set(BUILD_SCRIPTS_DIR ${PROJECT_SOURCE_DIR}/scripts)
4775

48-
49-
unset(CMAKE_EXPORT_COMPILE_COMMANDS CACHE)
5076
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
5177

5278
if (BUILD_TEST)
@@ -62,6 +88,7 @@ endif ()
6288
add_subdirectory(src)
6389
add_subdirectory(examples)
6490

91+
6592
# lint verbose options
6693
if (NOT MILVUS_VERBOSE_LINT)
6794
set(MILVUS_LINT_QUIET "--quiet")
@@ -155,3 +182,6 @@ if (${CLANG_TIDY_FOUND})
155182
${CMAKE_CURRENT_SOURCE_DIR}
156183
${MILVUS_LINT_QUIET})
157184
endif ()
185+
186+
# output config summary
187+
config_summary()

Makefile

-4
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ coverage: test st
4545
@echo "Run code coverage ..."
4646
@(env bash $(PWD)/scripts/coverage.sh)
4747

48-
package:
49-
@echo "Building Milvus SDK package ..."
50-
@(env bash $(PWD)/scripts/build.sh -p)
51-
5248
documentation:
5349
@echo "Generating Milvus SDK documentation ..."
5450
rm -rf ./doc/html ./doc/latex

cmake/BuildUtils.cmake

-220
This file was deleted.

cmake/CPM.cmake

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
set(CPM_DOWNLOAD_VERSION 0.38.1)
2+
3+
if(CPM_SOURCE_CACHE)
4+
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
5+
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
6+
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
7+
else()
8+
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
9+
endif()
10+
11+
# Expand relative path. This is important if the provided path contains a tilde (~)
12+
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
13+
14+
function(download_cpm)
15+
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
16+
file(DOWNLOAD
17+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
18+
${CPM_DOWNLOAD_LOCATION}
19+
)
20+
endfunction()
21+
22+
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
23+
download_cpm()
24+
else()
25+
# resume download if it previously failed
26+
file(READ ${CPM_DOWNLOAD_LOCATION} check)
27+
if("${check}" STREQUAL "")
28+
download_cpm()
29+
endif()
30+
unset(check)
31+
endif()
32+
33+
include(${CPM_DOWNLOAD_LOCATION})

0 commit comments

Comments
 (0)