Modify drogon_ctl
This commit is contained in:
parent
1d11c0cab4
commit
841391870e
|
@ -19,27 +19,52 @@ void create_project::handleCommand(std::vector<std::string> ¶meters)
|
||||||
}
|
}
|
||||||
static void newCmakeFile(std::ofstream &cmakeFile,const std::string &projectName)
|
static void newCmakeFile(std::ofstream &cmakeFile,const std::string &projectName)
|
||||||
{
|
{
|
||||||
cmakeFile<<"cmake_minimum_required(VERSION 3.2)\n"
|
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"
|
"link_libraries(drogon trantor uuid pthread jsoncpp ssl crypto dl z)\n"
|
||||||
"#如果您的gcc版本高于等于7.1.0,请设为'17'\n"
|
"IF (CMAKE_SYSTEM_NAME MATCHES \"Linux\")\n"
|
||||||
"set(CMAKE_CXX_STANDARD 11)\n"
|
" EXEC_PROGRAM (gcc ARGS \"--version | grep '^gcc'|awk '{print $3}' | sed s'/)//g' | sed s'/-.*//g'\" OUTPUT_VARIABLE version)\n"
|
||||||
"aux_source_directory(./ SRC_DIR)\n"
|
" MESSAGE(STATUS \"This is gcc version:: \" ${version})\n"
|
||||||
"\n"
|
" if(version LESS 4.9.0)\n"
|
||||||
"FILE(GLOB SCP_LIST ${CMAKE_CURRENT_SOURCE_DIR}/views/*.csp)\n"
|
" MESSAGE(STATUS \"gcc is too old\")\n"
|
||||||
"foreach(cspFile ${SCP_LIST})\n"
|
" stop()\n"
|
||||||
" message(STATUS \"cspFile:\" ${cspFile})\n"
|
" elseif (version LESS 6.1.0)\n"
|
||||||
" EXEC_PROGRAM(basename ARGS \"-s .csp ${cspFile}\" OUTPUT_VARIABLE classname)\n"
|
" MESSAGE(STATUS \"c++11\")\n"
|
||||||
" message(STATUS \"view classname:\" ${classname})\n"
|
" set(CMAKE_CXX_STD_FLAGS c++11)\n"
|
||||||
" add_custom_command(OUTPUT ${classname}.h ${classname}.cc\n"
|
" elseif(version LESS 7.1.0)\n"
|
||||||
" COMMAND drogon_ctl\n"
|
" set(CMAKE_CXX_STD_FLAGS c++14)\n"
|
||||||
" ARGS create view ${cspFile}\n"
|
" MESSAGE(STATUS \"c++14\")\n"
|
||||||
" DEPENDS ${cspFile}\n"
|
" else()\n"
|
||||||
" VERBATIM )\n"
|
" set(CMAKE_CXX_STD_FLAGS c++17)\n"
|
||||||
" set(VIEWSRC ${VIEWSRC} ${classname}.cc)\n"
|
" SET(DEFS \"USE_STD_ANY\")\n"
|
||||||
"endforeach()\n"
|
" MESSAGE(STATUS \"c++17\")\n"
|
||||||
"\n"
|
"\n"
|
||||||
"add_executable("<<projectName<<" ${SRC_DIR} ${VIEWSRC})";
|
" 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)
|
static void newMainFile(std::ofstream &mainFile)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue