Modify drogon_ctl

This commit is contained in:
antao 2018-09-12 10:31:30 +08:00
parent 1d11c0cab4
commit 841391870e
1 changed files with 46 additions and 21 deletions

View File

@ -19,27 +19,52 @@ 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"
"link_libraries(drogon trantor uuid pthread jsoncpp ssl crypto dl z)\n"
"#如果您的gcc版本高于等于7.1.0,请设为'17'\n"
"set(CMAKE_CXX_STANDARD 11)\n"
"aux_source_directory(./ SRC_DIR)\n"
"\n"
"FILE(GLOB SCP_LIST ${CMAKE_CURRENT_SOURCE_DIR}/views/*.csp)\n"
"foreach(cspFile ${SCP_LIST})\n"
" message(STATUS \"cspFile:\" ${cspFile})\n"
" EXEC_PROGRAM(basename ARGS \"-s .csp ${cspFile}\" OUTPUT_VARIABLE classname)\n"
" message(STATUS \"view classname:\" ${classname})\n"
" add_custom_command(OUTPUT ${classname}.h ${classname}.cc\n"
" COMMAND drogon_ctl\n"
" ARGS create view ${cspFile}\n"
" DEPENDS ${cspFile}\n"
" VERBATIM )\n"
" set(VIEWSRC ${VIEWSRC} ${classname}.cc)\n"
"endforeach()\n"
"\n"
"add_executable("<<projectName<<" ${SRC_DIR} ${VIEWSRC})";
cmakeFile<< "cmake_minimum_required(VERSION 3.2)\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"
" MESSAGE(STATUS \"This is gcc version:: \" ${version})\n"
" 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"
" set(CMAKE_CXX_STD_FLAGS c++17)\n"
" SET(DEFS \"USE_STD_ANY\")\n"
" MESSAGE(STATUS \"c++17\")\n"
"\n"
" endif()\n"
"else()\n"
" set(CMAKE_CXX_STD_FLAGS c++11)\n"
"endif()\n"
"if(CMAKE_BUILD_TYPE STREQUAL \"\")\n"
" set(CMAKE_BUILD_TYPE Release)\n"
"endif()\n"
"\n"
"set(CMAKE_CXX_FLAGS_DEBUG \"${CMAKE_CXX_FLAGS_DEBUG} -Wall -std=${CMAKE_CXX_STD_FLAGS}\")\n"
"set(CMAKE_CXX_FLAGS_RELEASE \"${CMAKE_CXX_FLAGS_RELEASE} -Wall -std=${CMAKE_CXX_STD_FLAGS}\")\n"
"aux_source_directory(./ SRC_DIR)\n"
"\n"
"FILE(GLOB SCP_LIST ${CMAKE_CURRENT_SOURCE_DIR}/views/*.csp)\n"
"foreach(cspFile ${SCP_LIST})\n"
" message(STATUS \"cspFile:\" ${cspFile})\n"
" EXEC_PROGRAM(basename ARGS \"-s .csp ${cspFile}\" OUTPUT_VARIABLE classname)\n"
" message(STATUS \"view classname:\" ${classname})\n"
" add_custom_command(OUTPUT ${classname}.h ${classname}.cc\n"
" COMMAND drogon_ctl\n"
" ARGS create view ${cspFile}\n"
" DEPENDS ${cspFile}\n"
" VERBATIM )\n"
" set(VIEWSRC ${VIEWSRC} ${classname}.cc)\n"
"endforeach()\n"
"\n"
"add_executable("<<projectName<<" ${SRC_DIR} ${VIEWSRC})";
}
static void newMainFile(std::ofstream &mainFile)
{