Update CMakeLists.txt

This commit is contained in:
antao 2018-09-14 23:54:06 +08:00
parent 4897c29a67
commit aaea4fb5ca
3 changed files with 67 additions and 56 deletions

View File

@ -7,23 +7,28 @@ IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
if(version LESS 4.9.0)
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()
endif()
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
if(COMPILER_SUPPORTS_CXX17)
message(STATUS "support c++17")
set(CMAKE_CXX_STD_FLAGS c++17)
#add_definitions(-DUSE_STD_ANY)
set(DR_DEFS "USE_STD_ANY")
MESSAGE(STATUS "c++17")
elseif(COMPILER_SUPPORTS_CXX14)
message(STATUS "support c++14")
set(CMAKE_CXX_STD_FLAGS c++14)
elseif(COMPILER_SUPPORTS_CXX11)
message(STATUS "support c++11")
set(CMAKE_CXX_STD_FLAGS c++11)
endif()
else()
set(CMAKE_CXX_STD_FLAGS c++11)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules/)
#jsoncpp
find_package (Jsoncpp REQUIRED)

View File

@ -20,7 +20,9 @@ void create_project::handleCommand(std::vector<std::string> &parameters)
static void newCmakeFile(std::ofstream &cmakeFile,const std::string &projectName)
{
cmakeFile<< "cmake_minimum_required(VERSION 3.2)\n"
"Project("<<projectName<<")\n"
"Project("
<<projectName
<<")\n"
"link_libraries(drogon trantor uuid pthread jsoncpp ssl crypto dl z)\n"
"IF (CMAKE_SYSTEM_NAME MATCHES \"Linux\")\n"
" EXEC_PROGRAM (gcc ARGS \"--version | grep '^gcc'|awk '{print $3}' | sed s'/)//g' | sed s'/-.*//g'\" OUTPUT_VARIABLE version)\n"
@ -28,17 +30,21 @@ static void newCmakeFile(std::ofstream &cmakeFile,const std::string &projectName
" if(version LESS 4.9.0)\n"
" MESSAGE(STATUS \"gcc is too old\")\n"
" stop()\n"
" elseif (version LESS 6.1.0)\n"
" MESSAGE(STATUS \"c++11\")\n"
" set(CMAKE_CXX_STD_FLAGS c++11)\n"
" elseif(version LESS 7.1.0)\n"
" set(CMAKE_CXX_STD_FLAGS c++14)\n"
" MESSAGE(STATUS \"c++14\")\n"
" else()\n"
" endif()\n"
" include(CheckCXXCompilerFlag)\n"
" CHECK_CXX_COMPILER_FLAG(\"-std=c++11\" COMPILER_SUPPORTS_CXX11)\n"
" CHECK_CXX_COMPILER_FLAG(\"-std=c++14\" COMPILER_SUPPORTS_CXX14)\n"
" CHECK_CXX_COMPILER_FLAG(\"-std=c++17\" COMPILER_SUPPORTS_CXX17)\n"
" if(COMPILER_SUPPORTS_CXX17)\n"
" message(STATUS \"support c++17\")\n"
" set(CMAKE_CXX_STD_FLAGS c++17)\n"
" SET(DEFS \"USE_STD_ANY\")\n"
" MESSAGE(STATUS \"c++17\")\n"
"\n"
" set(DEFS \"USE_STD_ANY\")\n"
" elseif(COMPILER_SUPPORTS_CXX14)\n"
" message(STATUS \"support c++14\")\n"
" set(CMAKE_CXX_STD_FLAGS c++14)\n"
" elseif(COMPILER_SUPPORTS_CXX11)\n"
" message(STATUS \"support c++11\")\n"
" set(CMAKE_CXX_STD_FLAGS c++11)\n"
" endif()\n"
"else()\n"
" set(CMAKE_CXX_STD_FLAGS c++11)\n"

@ -1 +1 @@
Subproject commit 29a0bf275c33e76fa8830166fceb9d045b65466b
Subproject commit 863a155f1725062a38b33a845e01be1e27c9286d