diff --git a/CMakeLists.txt b/CMakeLists.txt index 4849d9df..0f70a0aa 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/drogon_ctl/create_project.cc b/drogon_ctl/create_project.cc index da430dbc..766d21d8 100644 --- a/drogon_ctl/create_project.cc +++ b/drogon_ctl/create_project.cc @@ -20,51 +20,57 @@ void create_project::handleCommand(std::vector ¶meters) static void newCmakeFile(std::ofstream &cmakeFile,const std::string &projectName) { cmakeFile<< "cmake_minimum_required(VERSION 3.2)\n" - "Project("<