mirror of
https://gitee.com/sogou/srpc.git
synced 2024-12-21 16:14:54 +08:00
cmake : Add checking Gtest_VERSION for cmake 3.26.0; Use static link for macOS;
This commit is contained in:
parent
e6837552da
commit
cdf31c1455
@ -50,6 +50,7 @@ ifeq ("$(WORKFLOW)","Found")
|
||||
endif
|
||||
-make -C test clean
|
||||
-make -C tutorial clean
|
||||
-make -C benchmark clean
|
||||
rm -rf $(DEFAULT_BUILD_DIR)
|
||||
rm -rf _include
|
||||
rm -rf _lib
|
||||
|
@ -41,17 +41,6 @@ if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/workflow/workflow-config.cmake.in")
|
||||
find_package(Workflow REQUIRED CONFIG HINTS ../workflow)
|
||||
endif ()
|
||||
|
||||
#if (APPLE)
|
||||
# if (WORKFLOW_INCLUDE_DIR)
|
||||
# set (WORKFLOW_INCLUDE_DIR ${Workflow_DIR}/_include)
|
||||
# set (WORKFLOW_LIB_DIR ${Workflow_DIR}/_lib)
|
||||
# else ()
|
||||
# find_package(Workflow REQUIRED)
|
||||
# endif ()
|
||||
#else ()
|
||||
# find_package(Workflow REQUIRED)
|
||||
#endif()
|
||||
|
||||
find_package(srpc REQUIRED CONFIG HINTS ..)
|
||||
include_directories(
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
@ -88,9 +77,13 @@ else ()
|
||||
endif ()
|
||||
|
||||
if (APPLE)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
find_library(Workflow_LIB workflow HINTS ../workflow/_lib)
|
||||
find_library(Srpc_LIB srpc HINTS ../_lib)
|
||||
|
||||
set(SRPC_LIB
|
||||
srpc
|
||||
workflow
|
||||
${Srpc_LIB}
|
||||
${Workflow_LIB}
|
||||
pthread
|
||||
OpenSSL::SSL
|
||||
OpenSSL::Crypto
|
||||
|
@ -2,7 +2,7 @@ ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
ALL_TARGETS := all clean
|
||||
MAKE_FILE := Makefile
|
||||
|
||||
DEFAULT_BUILD_DIR := build
|
||||
DEFAULT_BUILD_DIR := build.cmake
|
||||
BUILD_DIR := $(shell if [ -f $(MAKE_FILE) ]; then echo "."; else echo $(DEFAULT_BUILD_DIR); fi)
|
||||
CMAKE3 := $(shell if which cmake3>/dev/null ; then echo cmake3; else echo cmake; fi;)
|
||||
|
||||
@ -22,9 +22,9 @@ endif
|
||||
clean:
|
||||
ifeq ($(MAKE_FILE), $(wildcard $(MAKE_FILE)))
|
||||
-make -f Makefile clean
|
||||
else ifeq (build, $(wildcard build))
|
||||
-make -C build clean
|
||||
else ifeq ($(DEFAULT_BUILD_DIR), $(wildcard $(DEFAULT_BUILD_DIR)))
|
||||
-make -C $(DEFAULT_BUILD_DIR) clean
|
||||
endif
|
||||
rm -rf build
|
||||
rm -rf $(DEFAULT_BUILD_DIR)
|
||||
|
||||
#g++ -o thrift_server thrift_server.cc gen-cpp/*.cpp -O2 -g -lthrift -lthriftnb -levent -lpthread -std=c++11
|
||||
|
@ -38,17 +38,6 @@ if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/workflow/workflow-config.cmake.in")
|
||||
find_package(Workflow REQUIRED CONFIG HINTS ../workflow)
|
||||
endif ()
|
||||
|
||||
#if (APPLE)
|
||||
# if (WORKFLOW_INCLUDE_DIR)
|
||||
# set (WORKFLOW_INCLUDE_DIR ${Workflow_DIR}/_include)
|
||||
# set (WORKFLOW_LIB_DIR ${Workflow_DIR}/_lib)
|
||||
# else ()
|
||||
# find_package(Workflow REQUIRED)
|
||||
# endif ()
|
||||
#else ()
|
||||
# find_package(Workflow REQUIRED)
|
||||
#endif()
|
||||
|
||||
include_directories(
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
@ -72,18 +61,36 @@ set(memcheck_command ${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OP
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
|
||||
|
||||
enable_testing()
|
||||
|
||||
if (WIN32)
|
||||
find_package(GTest CONFIG REQUIRED)
|
||||
else ()
|
||||
find_package(GTest REQUIRED)
|
||||
endif ()
|
||||
|
||||
set(CXX_STD "c++11")
|
||||
if (GTest_VERSION VERSION_GREATER_EQUAL "1.13.0")
|
||||
set(CXX_STD "c++14")
|
||||
else ()
|
||||
get_filename_component(GTEST_PATH ${GTEST_LIBRARY} DIRECTORY ABSOLUTE)
|
||||
execute_process(COMMAND grep Version "${GTEST_PATH}/pkgconfig/gtest.pc"
|
||||
RESULT_VARIABLE GTEST_VERSION_RESULT
|
||||
OUTPUT_VARIABLE GTEST_VERSION_OUTPUT)
|
||||
if (${GTEST_VERSION_RESULT} EQUAL "0")
|
||||
string(REPLACE " " ";" GTEST_VERSION_STR ${GTEST_VERSION_OUTPUT})
|
||||
list(GET GTEST_VERSION_STR 1 GTEST_VERSION)
|
||||
if (${GTEST_VERSION} VERSION_GREATER_EQUAL "1.13.0")
|
||||
set(CXX_STD "c++14")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (WIN32)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP /wd4200")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /wd4200 /Zc:__cplusplus /std:c++14")
|
||||
else ()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC -pipe -std=gnu90")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -pipe -std=c++11 -fno-exceptions")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -pipe -std=${CXX_STD} -fno-exceptions")
|
||||
endif ()
|
||||
|
||||
set(TEST_LIST
|
||||
@ -102,9 +109,13 @@ add_custom_target(
|
||||
set(GTEST_LIB GTest::GTest GTest::Main)
|
||||
|
||||
if (APPLE)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
find_library(Workflow_LIB workflow HINTS ../workflow/_lib)
|
||||
find_library(Srpc_LIB srpc HINTS ../_lib)
|
||||
|
||||
set(SRPC_LIB
|
||||
srpc
|
||||
workflow
|
||||
${Srpc_LIB}
|
||||
${Workflow_LIB}
|
||||
pthread
|
||||
OpenSSL::SSL
|
||||
OpenSSL::Crypto
|
||||
@ -157,7 +168,7 @@ endforeach()
|
||||
|
||||
if (WIN32)
|
||||
set(memcheck nothing)
|
||||
else ()
|
||||
elseif (NOT ${CMAKE_MEMORYCHECK_COMMAND} STREQUAL "CMAKE_MEMORYCHECK_COMMAND-NOTFOUND")
|
||||
foreach(src ${TEST_LIST})
|
||||
add_test(${src}-memory-check ${memcheck_command} ./${src})
|
||||
endforeach()
|
||||
|
@ -56,17 +56,6 @@ endif ()
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
#if (APPLE)
|
||||
# if (WORKFLOW_INCLUDE_DIR)
|
||||
# set (WORKFLOW_INCLUDE_DIR ${Workflow_DIR}/_include)
|
||||
# set (WORKFLOW_LIB_DIR ${Workflow_DIR}/_lib)
|
||||
# else ()
|
||||
# find_package(Workflow REQUIRED)
|
||||
# endif ()
|
||||
#else ()
|
||||
# find_package(Workflow REQUIRED)
|
||||
#endif()
|
||||
|
||||
include_directories(
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
@ -75,8 +64,6 @@ include_directories(
|
||||
${SRPC_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
|
||||
|
||||
if (WIN32)
|
||||
link_directories(${SRPC_LIB_DIR} ${WORKFLOW_LIB_DIR} ${Protobuf_LIB_DIR})
|
||||
set(SRPC_GEN_PROGRAM ${SRPC_BIN_DIR}/Debug/srpc_generator.exe)
|
||||
@ -97,7 +84,6 @@ add_custom_target(
|
||||
COMMENT "srpc generator..."
|
||||
)
|
||||
|
||||
|
||||
if (WIN32)
|
||||
if (SRPC_TUTORIAL_BUILD_STATIC_RUNTIME)
|
||||
set(CompilerFlags
|
||||
@ -136,9 +122,13 @@ set(TUTORIAL_PB_LIST
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
find_library(Workflow_LIB workflow HINTS ../workflow/_lib)
|
||||
find_library(Srpc_LIB srpc HINTS ../_lib)
|
||||
|
||||
set(SRPC_LIB
|
||||
srpc
|
||||
workflow
|
||||
${Srpc_LIB}
|
||||
${Workflow_LIB}
|
||||
pthread
|
||||
OpenSSL::SSL
|
||||
OpenSSL::Crypto
|
||||
|
Loading…
Reference in New Issue
Block a user