mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-02-02 01:06:41 +08:00
Fix compile option of thirdparty libs (#3246)
* fix some bugs Signed-off-by: yangxuan <xuan.yang@zilliz.com> * rm not using -f Signed-off-by: yangxuan <xuan.yang@zilliz.com> Co-authored-by: yangxuan <xuan.yang@zilliz.com>
This commit is contained in:
parent
6f6a1bfd82
commit
3913cc0fc4
@ -63,7 +63,6 @@ using_ccache_if_defined( MILVUS_USE_CCACHE )
|
||||
include( ExternalProject )
|
||||
include( ThirdPartyPackages )
|
||||
|
||||
add_subdirectory( thirdparty )
|
||||
|
||||
|
||||
# **************************** Compiler arguments ****************************
|
||||
@ -109,6 +108,7 @@ append_flags( CMAKE_CXX_FLAGS
|
||||
|
||||
# **************************** Source files ****************************
|
||||
|
||||
add_subdirectory( thirdparty )
|
||||
add_subdirectory( src )
|
||||
|
||||
# Unittest lib
|
||||
|
||||
@ -20,7 +20,7 @@ WITH_PROMETHEUS="ON"
|
||||
FIU_ENABLE="OFF"
|
||||
CUDA_ARCH="DEFAULT"
|
||||
|
||||
while getopts "p:d:t:f:s:ulrcghzmei" arg; do
|
||||
while getopts "p:d:t:s:ulrcghzmei" arg; do
|
||||
case $arg in
|
||||
p)
|
||||
INSTALL_PREFIX=$OPTARG
|
||||
@ -40,7 +40,6 @@ while getopts "p:d:t:f:s:ulrcghzmei" arg; do
|
||||
;;
|
||||
r)
|
||||
if [[ -d ${BUILD_OUTPUT_DIR} ]]; then
|
||||
rm ./${BUILD_OUTPUT_DIR} -r
|
||||
MAKE_CLEAN="ON"
|
||||
fi
|
||||
;;
|
||||
@ -102,6 +101,13 @@ cd ${BUILD_OUTPUT_DIR}
|
||||
# force update the variables each time
|
||||
make rebuild_cache >/dev/null 2>&1
|
||||
|
||||
|
||||
if [[ ${MAKE_CLEAN} == "ON" ]]; then
|
||||
echo "Runing make clean in ${BUILD_OUTPUT_DIR} ..."
|
||||
make clean
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CMAKE_CMD="cmake \
|
||||
-DBUILD_UNIT_TEST=${BUILD_UNITTEST} \
|
||||
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}
|
||||
@ -119,9 +125,6 @@ CMAKE_CMD="cmake \
|
||||
echo ${CMAKE_CMD}
|
||||
${CMAKE_CMD}
|
||||
|
||||
if [[ ${MAKE_CLEAN} == "ON" ]]; then
|
||||
make clean
|
||||
fi
|
||||
|
||||
if [[ ${RUN_CPPLINT} == "ON" ]]; then
|
||||
# cpplint check
|
||||
|
||||
54
core/thirdparty/CMakeLists.txt
vendored
54
core/thirdparty/CMakeLists.txt
vendored
@ -10,52 +10,9 @@
|
||||
# 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.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_BUILD_TYPE)
|
||||
set(EP_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}}")
|
||||
set(EP_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${UPPERCASE_BUILD_TYPE}}")
|
||||
|
||||
if (NOT MSVC)
|
||||
# Set -fPIC on all external projects
|
||||
set(EP_CXX_FLAGS "${EP_CXX_FLAGS} -fPIC")
|
||||
set(EP_C_FLAGS "${EP_C_FLAGS} -fPIC")
|
||||
endif ()
|
||||
|
||||
# CC/CXX environment variables are captured on the first invocation of the
|
||||
# builder (e.g make or ninja) instead of when CMake is invoked into to build
|
||||
# directory. This leads to issues if the variables are exported in a subshell
|
||||
# and the invocation of make/ninja is in distinct subshell without the same # environment (CC/CXX).
|
||||
if ( CCACHE_FOUND )
|
||||
set( EP_C_COMPILER "${CCACHE_FOUND} ${CMAKE_C_COMPILER}" )
|
||||
set( EP_CXX_COMPILER "${CCACHE_FOUND} ${CMAKE_CXX_COMPILER}" )
|
||||
else()
|
||||
set( EP_C_COMPILER ${CMAKE_C_COMPILER} )
|
||||
set( EP_CXX_COMPILER ${CMAKE_CXX_COMPILER} )
|
||||
endif()
|
||||
|
||||
set(EP_COMMON_TOOLCHAIN
|
||||
-DCMAKE_C_COMPILER=${EP_C_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER=${EP_CXX_COMPILER})
|
||||
|
||||
if (CMAKE_AR)
|
||||
set(EP_COMMON_TOOLCHAIN ${EP_COMMON_TOOLCHAIN} -DCMAKE_AR=${CMAKE_AR})
|
||||
endif ()
|
||||
|
||||
if (CMAKE_RANLIB)
|
||||
set(EP_COMMON_TOOLCHAIN ${EP_COMMON_TOOLCHAIN} -DCMAKE_RANLIB=${CMAKE_RANLIB})
|
||||
endif ()
|
||||
|
||||
# External projects are still able to override the following declarations.
|
||||
# cmake command line will favor the last defined variable when a duplicate is
|
||||
# encountered. This requires that `EP_COMMON_CMAKE_ARGS` is always the first
|
||||
# argument.
|
||||
set(EP_COMMON_CMAKE_ARGS
|
||||
${EP_COMMON_TOOLCHAIN}
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_C_FLAGS=${EP_C_FLAGS}
|
||||
-DCMAKE_C_FLAGS_${UPPERCASE_BUILD_TYPE}=${EP_C_FLAGS}
|
||||
-DCMAKE_CXX_FLAGS=${EP_CXX_FLAGS}
|
||||
-DCMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}=${EP_CXX_FLAGS})
|
||||
# Using default c and cxx compiler in our build tree
|
||||
# Thirdpart cxx and c flags
|
||||
add_compile_options( -O3 -fPIC -Wno-error -fopenmp )
|
||||
|
||||
if (NOT KNOWHERE_VERBOSE_THIRDPARTY_BUILD)
|
||||
set(EP_LOG_OPTIONS LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_DOWNLOAD 1)
|
||||
@ -65,7 +22,10 @@ endif ()
|
||||
|
||||
set( MAKE_BUILD_ARGS "-j6" )
|
||||
|
||||
set( FETCHCONTENT_BASE_DIR ${MILVUS_BINARY_DIR}/3rdparty_download )
|
||||
include( FetchContent )
|
||||
set( FETCHCONTENT_BASE_DIR ${MILVUS_BINARY_DIR}/3rdparty_download )
|
||||
set( FETCHCONTENT_QUIET OFF )
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Find pthreads
|
||||
|
||||
|
||||
23
core/thirdparty/grpc/CMakeLists.txt
vendored
23
core/thirdparty/grpc/CMakeLists.txt
vendored
@ -1,10 +1,9 @@
|
||||
# Another way is to use CMake's FetchContent module to clone gRPC at
|
||||
# configure time. This makes gRPC's source code available to your project,
|
||||
# Another way is to use CMake's FetchContent module to clone gRPC at
|
||||
# configure time. This makes gRPC's source code available to project,
|
||||
message(STATUS "Building GRPC-${GRPC_VERSION} from source")
|
||||
# ******************************************************************
|
||||
# FetchContent
|
||||
# ******************************************************************
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
grpc
|
||||
URL ${GRPC_SOURCE_URL}
|
||||
@ -14,24 +13,12 @@ FetchContent_Declare(
|
||||
)
|
||||
set(FETCHCONTENT_QUIET OFF)
|
||||
|
||||
# Compile options for grpc only
|
||||
add_compile_options( ${EP_COMMON_TOOLCHAIN}
|
||||
"-D CMAKE_BUILD_TYPE=Release"
|
||||
"-D CMAKE_C_FLAGS=${EP_C_FLAGS}"
|
||||
"-D CMAKE_C_FLAGS_${UPPERCASE_BUILD_TYPE}=${EP_C_FLAGS}"
|
||||
"-D CMAKE_CXX_FLAGS=${EP_CXX_FLAGS}"
|
||||
"-D CMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}=${EP_CXX_FLAGS}"
|
||||
)
|
||||
|
||||
# using openSSL rather than boringssl
|
||||
set(gRPC_SSL_PROVIDER "package" CACHE STRING "OPENSSL" FORCE)
|
||||
# zlib build by grpc
|
||||
set( gRPC_ZLIB_PROVIDER "module" )
|
||||
FetchContent_GetProperties( grpc )
|
||||
if ( NOT grpc_POPULATED )
|
||||
|
||||
FetchContent_Populate( grpc
|
||||
)
|
||||
FetchContent_Populate( grpc )
|
||||
|
||||
# Adding the following targets:
|
||||
# libprotobuf
|
||||
@ -46,7 +33,7 @@ endif()
|
||||
|
||||
# get grpc COMPILE_OPTIONS )
|
||||
get_property(var DIRECTORY "${grpc_SOURCE_DIR}" PROPERTY COMPILE_OPTIONS )
|
||||
message(STATUS "grpc compile options: ${var}")
|
||||
message(STATUS "grpc src compile options: ${var}")
|
||||
|
||||
|
||||
# **************************************************************************
|
||||
@ -99,5 +86,3 @@ add_custom_command(
|
||||
# Include generated *.pb.h files
|
||||
include_directories("${MILVUS_SOURCE_DIR}/gen-milvus-test")
|
||||
include_directories("${MILVUS_SOURCE_DIR}/gen-status-test")
|
||||
|
||||
|
||||
|
||||
69
core/thirdparty/gtest/CMakeLists.txt
vendored
69
core/thirdparty/gtest/CMakeLists.txt
vendored
@ -12,26 +12,29 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# *********************************** FetchContent ***********************************
|
||||
# Cons: force install at INSTALL_DIRS, EXCLUDE_FROM_ALL can aviod install
|
||||
# Pros: Simple, done at configure time, can be used immediately
|
||||
# ************************************************************************************
|
||||
# include( FetchContent )
|
||||
# set( CMAKE_POLICY_DEFAULT_CMP0022 NEW ) # for googletest only
|
||||
#
|
||||
# FetchContent_Declare(
|
||||
# googletest
|
||||
# URL "https://github.com/google/googletest/archive/release-${GTEST_VERSION}.tar.gz"
|
||||
# "https://gitee.com/quicksilver/googletest/repository/archive/release-${GTEST_VERSION}.zip"
|
||||
# URL_MD5 2e6fbeb6a91310a16efe181886c59596
|
||||
# )
|
||||
#
|
||||
# if ( NOT googletest_POPULATED )
|
||||
# FetchContent_Populate( googletest )
|
||||
#
|
||||
# add_subdirectory( ${googletest_SOURCE_DIR}
|
||||
# ${googletest_BINARY_DIR}
|
||||
# )
|
||||
# endif()
|
||||
message( STATUS "Building gtest-${GTEST_VERSION} from source" )
|
||||
include( FetchContent )
|
||||
set( CMAKE_POLICY_DEFAULT_CMP0022 NEW ) # for googletest only
|
||||
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL ${GTEST_SOURCE_URL}
|
||||
URL_MD5 "f9137c5bc18b7d74027936f0f1bfa5c8"
|
||||
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
||||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
||||
|
||||
)
|
||||
|
||||
if ( NOT googletest_POPULATED )
|
||||
FetchContent_Populate( googletest )
|
||||
|
||||
add_subdirectory( ${googletest_SOURCE_DIR}
|
||||
${googletest_BINARY_DIR}
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
endif()
|
||||
|
||||
# ****************************************************************
|
||||
# Create ALIAS Target
|
||||
@ -52,35 +55,5 @@
|
||||
# endif()
|
||||
|
||||
|
||||
message( STATUS "Building gtest-${GTEST_VERSION} from source" )
|
||||
set( GTEST_CMAKE_CXX_FLAGS ${EP_CXX_FLAGS} )
|
||||
set( gtest_DOWNLOAD_DIR ${MILVUS_BINARY_DIR}/3rdparty_download/googletest_download )
|
||||
|
||||
# Download and unpack googletest at configure time
|
||||
configure_file( CMakeLists.txt.in ${gtest_DOWNLOAD_DIR}/CMakeLists.txt )
|
||||
|
||||
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
|
||||
WORKING_DIRECTORY ${gtest_DOWNLOAD_DIR}
|
||||
)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
|
||||
WORKING_DIRECTORY ${gtest_DOWNLOAD_DIR}
|
||||
)
|
||||
|
||||
add_compile_options( ${EP_COMMON_TOOLCHAIN}
|
||||
"-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
|
||||
"-D CMAKE_C_FLAGS=${EP_C_FLAGS}"
|
||||
"-D CMAKE_C_FLAGS_${UPPERCASE_BUILD_TYPE}=${EP_C_FLAGS}"
|
||||
"-D CMAKE_CXX_FLAGS=${EP_CXX_FLAGS}"
|
||||
"-D CMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}=${EP_CXX_FLAGS}"
|
||||
)
|
||||
# Add googletest directly to our build. This adds the following targets:
|
||||
# gtest, gtest_main, gmock and gmock_main
|
||||
add_subdirectory("${CMAKE_CURRENT_BINARY_DIR}/googletest-src"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/googletest-build"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
||||
# get_property(var DIRECTORY PROPERTY COMPILE_OPTIONS )
|
||||
get_property(var DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/googletest-src" PROPERTY COMPILE_OPTIONS )
|
||||
message(STATUS "gtest compile options: ${var}")
|
||||
|
||||
32
core/thirdparty/gtest/CMakeLists.txt.in
vendored
32
core/thirdparty/gtest/CMakeLists.txt.in
vendored
@ -1,32 +0,0 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# ****************************************************************
|
||||
# googletest download and extract template
|
||||
# ****************************************************************
|
||||
cmake_minimum_required( VERSION 3.14 )
|
||||
project( googletest-download NONE )
|
||||
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add( googletest_ep
|
||||
URL ${GTEST_SOURCE_URL}
|
||||
URL_MD5 "f9137c5bc18b7d74027936f0f1bfa5c8"
|
||||
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
||||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user