-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from jackyding2679/v5.5.0
v5.5.0
- Loading branch information
Showing
758 changed files
with
141,271 additions
and
5,562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,71 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
CMAKE_policy(SET CMP0015 NEW) | ||
|
||
project(cos-cpp-sdk) | ||
#SET(BOOST_HEADER_DIR "/root/boost_1_68_0/") | ||
#SET(CMAKE_CXX_STANDARD 11) cmake 3.x才支持 | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
SET(CMAKE_VERBOSE_MAKEFILE ON) | ||
# find_package自动查找,或者通过SET(OPENSSL_VERSION 1.0.0)人工设置 | ||
find_package(OpenSSL REQUIRED) | ||
#SET(OPENSSL_VERSION 1.0.1e) | ||
message(${OPENSSL_VERSION}) | ||
|
||
# 单元测试与覆盖率统计 | ||
OPTION (ENABLE_UNITTEST "Unittest" OFF) | ||
|
||
# coverage option | ||
IF(ENABLE_UNITTEST) | ||
find_package(GTest REQUIRED) | ||
if (NOT GTest_FOUND) | ||
message(FATAL_ERROR "GTest Not Found!") | ||
endif (NOT GTest_FOUND) | ||
MESSAGE(STATUS ENABLE_UNITTEST=${ENABLE_UNITTEST}) | ||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") | ||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage") | ||
ENDIF() | ||
|
||
add_definitions(-D__COS_DEBUG__) | ||
|
||
# include directories | ||
INCLUDE_DIRECTORIES(./include) | ||
INCLUDE_DIRECTORIES(/usr/local/ssl/include) | ||
# include_directories(${BOOST_HEADER_DIR}) | ||
|
||
# lib directories | ||
link_directories(/usr/local/lib) | ||
link_directories(./lib) | ||
|
||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) | ||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) | ||
|
||
IF(ENABLE_UNITTEST) | ||
FILE(COPY unittest/testdata/config.json DESTINATION ${EXECUTABLE_OUTPUT_PATH}/) | ||
FILE(COPY unittest/testdata/config_bucket_test.json DESTINATION ${EXECUTABLE_OUTPUT_PATH}/) | ||
FILE(COPY unittest/testdata/sevenyou.txt DESTINATION ${EXECUTABLE_OUTPUT_PATH}/) | ||
FILE(COPY unittest/merge_xml_results.py DESTINATION ${EXECUTABLE_OUTPUT_PATH}/) | ||
INCLUDE_DIRECTORIES(./include/googletest/include/) | ||
ADD_SUBDIRECTORY(unittest) | ||
ENDIF() | ||
|
||
ADD_SUBDIRECTORY(src) | ||
ADD_SUBDIRECTORY(demo) | ||
set(CMAKE_VERBOSE_MAKEFILE ON) | ||
|
||
option(BUILD_UNITTEST "Build unittest" OFF) | ||
option(BUILD_DEMO "Build demo" ON) | ||
option(BUILD_SHARED_LIB "Build shared library" OFF) | ||
|
||
if(APPLE) | ||
set(OS_TYPE "APPLE") | ||
elseif(UNIX) | ||
set(OS_TYPE "LINUX") | ||
elseif(WIN32) | ||
set(OS_TYPE "WINDOWS") | ||
else() | ||
message(FATAL_ERROR "unkonwn os type") | ||
endif() | ||
message(STATUS "OS type: ${OS_TYPE}") | ||
|
||
if (${OS_TYPE} STREQUAL "WINDOWS") | ||
set(BUILD_TARGET "Win32") | ||
if (CMAKE_CL_64) | ||
set(BUILD_TARGET "x64") | ||
endif() | ||
message(STATUS "Build target: ${BUILD_TARGET}") | ||
if (NOT DEFINED ${CMAKE_BUILD_TYPE}) | ||
set(CMAKE_BUILD_TYPE "Release") | ||
endif() | ||
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") | ||
|
||
set(POCO_LINK_DIR ${CMAKE_SOURCE_DIR}/third_party/lib/${BUILD_TARGET}/poco) | ||
set(POCO_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/third_party/include/) | ||
set(POCO_LIBS PocoNetSSL PocoNet PocoCrypto PocoUtil PocoJSON PocoFoundation PocoXML) | ||
|
||
set(SYSTEM_LIBS "") | ||
#需要加该参数,不然VS会报错 | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8") | ||
else() | ||
set(POCO_LINK_DIR ${CMAKE_SOURCE_DIR}/third_party/lib/linux/poco/) | ||
if (${OS_TYPE} STREQUAL "APPLE") | ||
set(POCO_LINK_DIR ${CMAKE_SOURCE_DIR}/third_party/lib/macOS/poco/) | ||
endif() | ||
set(POCO_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/third_party/include/) | ||
set(POCO_LIBS PocoNetSSL PocoNet PocoCrypto PocoUtil PocoJSON PocoFoundation PocoXML) | ||
|
||
set(SYSTEM_LIBS stdc++ pthread) | ||
endif() | ||
|
||
add_subdirectory(src) | ||
|
||
if(BUILD_UNITTEST) | ||
message(STATUS "Build unittest") | ||
|
||
set(GTEST_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/third_party/include/gtest/) | ||
set(GTEST_LINK_DIR ${CMAKE_SOURCE_DIR}/third_party/lib/linux/gtest/) | ||
if (${OS_TYPE} STREQUAL "WINDOWS") | ||
set(GTEST_LINK_DIR ${CMAKE_SOURCE_DIR}/third_party/lib/${BUILD_TARGET}/gtest) | ||
endif() | ||
set(GTEST_LIBS gtest gtest_main) | ||
|
||
set(UT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/unittest/include/) | ||
|
||
add_subdirectory(unittest) | ||
endif() | ||
|
||
if(BUILD_DEMO) | ||
message(STATUS "Build demo") | ||
add_subdirectory(demo) | ||
endif() |
Oops, something went wrong.