Format CMakeLists.txt

This commit is contained in:
antao 2018-08-27 18:36:58 +08:00
parent a314404e89
commit 4a26730c2e

View File

@ -1,26 +1,25 @@
cmake_minimum_required (VERSION 2.6)
project (DROGON CXX)
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
EXEC_PROGRAM (gcc ARGS "--version | grep '^gcc'|awk '{print $3}' | sed s'/)//g' | sed s'/-.*//g'" OUTPUT_VARIABLE version)
MESSAGE(STATUS "This is gcc version:: " ${version})
if(version LESS 4.8.5)
MESSAGE(STATUS "gcc is too old")
stop()
elseif (version LESS 6.1.0)
MESSAGE(STATUS "c++11")
set(CMAKE_CXX_STD_FLAGS c++11)
elseif(version LESS 7.1.0)
set(CMAKE_CXX_STD_FLAGS c++14)
MESSAGE(STATUS "c++14")
else()
set(CMAKE_CXX_STD_FLAGS c++17)
#add_definitions(-DUSE_STD_ANY)
set(DR_DEFS "USE_STD_ANY")
MESSAGE(STATUS "c++17")
EXEC_PROGRAM (gcc ARGS "--version | grep '^gcc'|awk '{print $3}' | sed s'/)//g' | sed s'/-.*//g'" OUTPUT_VARIABLE version)
MESSAGE(STATUS "This is gcc version:: " ${version})
if(version LESS 4.8.5)
MESSAGE(STATUS "gcc is too old")
stop()
elseif (version LESS 6.1.0)
MESSAGE(STATUS "c++11")
set(CMAKE_CXX_STD_FLAGS c++11)
elseif(version LESS 7.1.0)
set(CMAKE_CXX_STD_FLAGS c++14)
MESSAGE(STATUS "c++14")
else()
set(CMAKE_CXX_STD_FLAGS c++17)
#add_definitions(-DUSE_STD_ANY)
set(DR_DEFS "USE_STD_ANY")
MESSAGE(STATUS "c++17")
endif()
endif()
else()
set(CMAKE_CXX_STD_FLAGS c++11)
endif()
@ -31,28 +30,28 @@ find_package (Jsoncpp REQUIRED)
include_directories(${JSONCPP_INCLUDE_DIRS})
#message(STATUS ${JSONCPP_LIBRARIES})
if(NOT EXISTS ${JSONCPP_INCLUDE_DIRS}/json/version.h)
message(STATUS "jsoncpp lib is too old.....stop")
stop()
message(STATUS "jsoncpp lib is too old.....stop")
stop()
endif()
EXEC_PROGRAM(cat ARGS "${JSONCPP_INCLUDE_DIRS}/json/version.h |grep JSONCPP_VERSION_STRING|sed s'/.*define/define/'|awk '{printf $3}'|sed s'/\"//g'" OUTPUT_VARIABLE jsoncpp_ver)
message(STATUS "jsoncpp verson:" ${jsoncpp_ver})
if(jsoncpp_ver LESS 1.7)
MESSAGE(STATUS "jsoncpp lib is too old,please get new version from https://github.com/open-source-parsers/jsoncpp")
stop()
MESSAGE(STATUS "jsoncpp lib is too old,please get new version from https://github.com/open-source-parsers/jsoncpp")
stop()
endif()
find_package (UUID REQUIRED)
find_package (OpenSSL REQUIRED)
if(OpenSSL_FOUND)
#add_definitions(-DUSE_OPENSSL)
set(DR_DEFS "USE_OPENSSL;${DR_DEFS}")
include_directories(${OPENSSL_INCLUDE_DIR})
#add_definitions(-DUSE_OPENSSL)
set(DR_DEFS "USE_OPENSSL;${DR_DEFS}")
include_directories(${OPENSSL_INCLUDE_DIR})
endif()
message(STATUS "openssl inc path:" ${OPENSSL_INCLUDE_DIR})
find_package(Boost)
if(Boost_FOUND)
# add_definitions(-DUSE_BOOST)
# add_definitions(-DUSE_BOOST)
set(DR_DEFS "USE_BOOST;${DR_DEFS}")
include_directories(${Boost_INCLUDE_DIRS})
endif()
@ -124,7 +123,7 @@ file(APPEND "${CONFIG_HEADER}" "\n" "const char compileFlags[]=\"" ${CMAKE_CXX_F
get_target_property(INS drogon INCLUDE_DIRECTORIES)
file(APPEND "${CONFIG_HEADER}" "\nconst char includeDirs[]=\"")
foreach(loop_var ${INS})
file(APPEND "${CONFIG_HEADER}" "-I" ${loop_var} " ")
file(APPEND "${CONFIG_HEADER}" "-I" ${loop_var} " ")
endforeach(loop_var)
file(APPEND "${CONFIG_HEADER}" "\";\n")
EXEC_PROGRAM(${PROJECT_SOURCE_DIR}/update_config.sh ARGS "${CONFIG_HEADER} ${PROJECT_SOURCE_DIR}/lib/inc/drogon/config.h")