mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 02:48:45 +08:00
1a1ba0434b
Former-commit-id: d2df17911de6634f70dfa812211d0a6f52aadb18
60 lines
2.2 KiB
CMake
60 lines
2.2 KiB
CMake
set(GTEST_ROOT "${CMAKE_BINARY_DIR}/googletest")
|
|
|
|
set(GTEST_CMAKE_ARGS "")
|
|
# " -Dgtest_build_samples=ON"
|
|
# " -DCMAKE_VERBOSE_MAKEFILE=ON")
|
|
|
|
if(NOT CMAKE_CXX11_ABI)
|
|
message(STATUS "GTEST: Disabling the GLIBCXX11 ABI")
|
|
list(APPEND GTEST_CMAKE_ARGS " -DCMAKE_C_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0")
|
|
list(APPEND GTEST_CMAKE_ARGS " -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0")
|
|
elseif(CMAKE_CXX11_ABI)
|
|
message(STATUS "GTEST: Enabling the GLIBCXX11 ABI")
|
|
list(APPEND GTEST_CMAKE_ARGS " -DCMAKE_C_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=1")
|
|
list(APPEND GTEST_CMAKE_ARGS " -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=1")
|
|
endif(NOT CMAKE_CXX11_ABI)
|
|
|
|
configure_file("${CMAKE_SOURCE_DIR}/cmake/Templates/GoogleTest.CMakeLists.txt.cmake"
|
|
"${GTEST_ROOT}/CMakeLists.txt")
|
|
|
|
file(MAKE_DIRECTORY "${GTEST_ROOT}/build")
|
|
file(MAKE_DIRECTORY "${GTEST_ROOT}/install")
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} .
|
|
RESULT_VARIABLE GTEST_CONFIG
|
|
WORKING_DIRECTORY ${GTEST_ROOT})
|
|
|
|
if(GTEST_CONFIG)
|
|
message(FATAL_ERROR "Configuring GoogleTest failed: " ${GTEST_CONFIG})
|
|
endif(GTEST_CONFIG)
|
|
|
|
set(PARALLEL_BUILD -j)
|
|
if($ENV{PARALLEL_LEVEL})
|
|
set(NUM_JOBS $ENV{PARALLEL_LEVEL})
|
|
set(PARALLEL_BUILD "${PARALLEL_BUILD}${NUM_JOBS}")
|
|
endif($ENV{PARALLEL_LEVEL})
|
|
|
|
if(${NUM_JOBS})
|
|
if(${NUM_JOBS} EQUAL 1)
|
|
message(STATUS "GTEST BUILD: Enabling Sequential CMake build")
|
|
elseif(${NUM_JOBS} GREATER 1)
|
|
message(STATUS "GTEST BUILD: Enabling Parallel CMake build with ${NUM_JOBS} jobs")
|
|
endif(${NUM_JOBS} EQUAL 1)
|
|
else()
|
|
message(STATUS "GTEST BUILD: Enabling Parallel CMake build with all threads")
|
|
endif(${NUM_JOBS})
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} --build .. -- ${PARALLEL_BUILD}
|
|
RESULT_VARIABLE GTEST_BUILD
|
|
WORKING_DIRECTORY ${GTEST_ROOT}/build)
|
|
|
|
if(GTEST_BUILD)
|
|
message(FATAL_ERROR "Building GoogleTest failed: " ${GTEST_BUILD})
|
|
endif(GTEST_BUILD)
|
|
|
|
message(STATUS "GoogleTest installed here: " ${GTEST_ROOT}/install)
|
|
set(GTEST_INCLUDE_DIR "${GTEST_ROOT}/install/include")
|
|
set(GTEST_LIBRARY_DIR "${GTEST_ROOT}/install/lib")
|
|
set(GTEST_FOUND TRUE)
|
|
|