Skip to content

Commit

Permalink
Merge pull request #304 from holmes1412/cmake-3.26
Browse files Browse the repository at this point in the history
cmake : Add checking Gtest_VERSION for cmake 3.26.0; Use static link for macOS;
  • Loading branch information
Barenboim authored Apr 19, 2023
2 parents e683755 + 2cb9c18 commit dbeb9ab
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 48 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,34 @@ jobs:

- name: make install
run: sudo make install
test:
name: fedora
runs-on: ubuntu-latest

steps:
- name: Setup Podman
run: |
sudo apt update
sudo apt-get -y install podman
podman pull fedora:rawhide
- name: Get source
uses: actions/checkout@v3
with:
path: 'workflow'
- name: Create container and run tests
run: |
{
echo 'FROM fedora:rawhide'
echo 'RUN dnf -y update'
echo 'RUN dnf -y install cmake gcc-c++ gtest-devel make'
echo 'RUN dnf -y install openssl-devel protobuf-devel'
echo 'RUN dnf -y install lz4-devel snappy-devel workflow-devel'
echo 'RUN dnf clean all'
echo 'COPY workflow workflow'
echo 'WORKDIR /workflow'
echo "RUN cmake"
echo "RUN make"
echo "RUN make check"
echo "RUN make tutorial"
} > podmanfile
podman build --tag fedorarawhide -f ./podmanfile
1 change: 1 addition & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 6 additions & 13 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions benchmark/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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;)

Expand All @@ -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
41 changes: 26 additions & 15 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down
22 changes: 6 additions & 16 deletions tutorial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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)
Expand All @@ -97,7 +84,6 @@ add_custom_target(
COMMENT "srpc generator..."
)


if (WIN32)
if (SRPC_TUTORIAL_BUILD_STATIC_RUNTIME)
set(CompilerFlags
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dbeb9ab

Please sign in to comment.