diff --git a/cmake/DrogonUtilities.cmake b/cmake/DrogonUtilities.cmake index 11ac95a7..7cb97996 100644 --- a/cmake/DrogonUtilities.cmake +++ b/cmake/DrogonUtilities.cmake @@ -1,6 +1,6 @@ # ############################################################################## # function drogon_create_views(target source_path output_path -# [use_path_as_namespace]) +# [TRUE to use_path_as_namespace] [prefixed namespace]) # ############################################################################## function(drogon_create_views arg) if(ARGC LESS 3) @@ -27,15 +27,27 @@ function(drogon_create_views arg) "" outputFile ${f2}) + set(p2ns "") + if("${ARGV3}" STREQUAL "TRUE") + set(p2ns "--path-to-namespace") + endif() + if ( (ARGC EQUAL 5) AND ( NOT "${ARGV4}" STREQUAL "") ) + string(REPLACE "::" "_" nSpace ${ARGV4}) + set(outputFile "${nSpace}_${outputFile}") + set(ns -n ${ARGV4}) + else() + set(ns "") + endif() add_custom_command(OUTPUT ${ARGV2}/${outputFile}.h ${ARGV2}/${outputFile}.cc COMMAND drogon_ctl ARGS create view ${inFile} - --path-to-namespace + ${p2ns} -o ${ARGV2} + ${ns} DEPENDS ${cspFile} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM) diff --git a/drogon_ctl/create.cc b/drogon_ctl/create.cc index 574ce34b..67a2da4f 100644 --- a/drogon_ctl/create.cc +++ b/drogon_ctl/create.cc @@ -24,8 +24,8 @@ std::string create::detail() "Usage:drogon_ctl create " "[-options] \n\n" "drogon_ctl create view [-o ] [-n " - "]|[--path-to-namespace]//create HttpView source files " - "from csp files\n\n" + "] [--path-to-namespace] //create HttpView source files " + "from csp files, namespace is prefixed of path-to-namespace\n\n" "drogon_ctl create controller [-s] <[namespace::]class_name> //" "create HttpSimpleController source files\n\n" "drogon_ctl create controller -h <[namespace::]class_name> //" diff --git a/drogon_ctl/templates/cmake.csp b/drogon_ctl/templates/cmake.csp index cbaf5261..5a5c4bac 100644 --- a/drogon_ctl/templates/cmake.csp +++ b/drogon_ctl/templates/cmake.csp @@ -54,6 +54,10 @@ drogon_create_views(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/views # use the following line to create views with namespaces. # drogon_create_views(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/views # ${CMAKE_CURRENT_BINARY_DIR} TRUE) +# use the following line to create views with namespace CHANGE_ME prefixed +# and path namespaces. +# drogon_create_views(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/views +# ${CMAKE_CURRENT_BINARY_DIR} TRUE CHANGE_ME) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}