drogonframework / drogonframework/drogon
Simple project cmake build fails with error "Unknown CMake command "drogon_create_views""
- Dominant language
- C++
- Stars
- 14.3k
- Forks
- 1.4k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 14
Description
Simple project build fails with error "Unknown CMake command "drogon_create_views""
Steps to reproduce the behavior:
1. drogon_ctl.exe create project drogon-test
2. cd drogon-test
3. create conanfile.txt and add into conanfile.txt the following lines:
```
[requires]
drogon/1.9.1
jsoncpp/1.9.5
boost/1.83.0
[generators]
CMakeDeps
CMakeToolchain
```
4. cd build
5. conan install .. --build=missing -s compiler.cppstd=20
6. cmake .. -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -G "Visual Studio 17 2022" -A x64 -DCMAKE_POLICY_DEFAULT_CMP0091=NEW
Context:
[!] drogon_ctl.exe version
```
Version: 1.9.10
Git commit: f6b5404dbb8f0b5a914b0dbdc3868f1f28d55bb7
Compilation:
Compiler: cl.exe
Compiler ID: MSVC
Compilation flags: /Ob0 /Od /RTC1 -std=c++17 -IC:/Users/saint/.conan2/p/b/jsonccf57c65ee1f79/p/include -ID:/include
Libraries:
postgresql: no (pipeline mode: no)
mariadb: no
sqlite3: yes
ssl/tls backend: OpenSSL
brotli: yes
hiredis: yes
c-ares: no
yaml-cpp: no
```
[!] CMakeLists.txt
```
cmake_minimum_required(VERSION 3.5)
project(drogon-test CXX)
include(CheckIncludeFileCXX)
check_include_file_cxx(any HAS_ANY)
check_include_file_cxx(string_view HAS_STRING_VIEW)
check_include_file_cxx(coroutine HAS_COROUTINE)
if (NOT "${CMAKE_CXX_STANDARD}" STREQUAL "")
# Do nothing
elseif (HAS_ANY AND HAS_STRING_VIEW AND HAS_COROUTINE)
set(CMAKE_CXX_STANDARD 20)
elseif (HAS_ANY AND HAS_STRING_VIEW)
set(CMAKE_CXX_STANDARD 17)
else ()
set(CMAKE_CXX_STANDARD 14)
endif ()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_executable(${PROJECT_NAME} main.cc)
# ##############################################################################
# If you include the drogon source code locally in your project, use this method
# to add drogon
# add_subdirectory(drogon)
# target_link_libraries(${PROJECT_NAME} PRIVATE drogon)
#
# and comment out the following lines
find_package(Drogon CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon)
# ##############################################################################
if (CMAKE_CXX_STANDARD LESS 17)
message(FATAL_ERROR "c++17 or higher is required")
elseif (CMAKE_CXX_STANDARD LESS 20)
message(STATUS "use c++17")
else ()
message(STATUS "use c++20")
endif ()
aux_source_directory(controllers CTL_SRC)
aux_source_directory(filters FILTER_SRC)
aux_source_directory(plugins PLUGIN_SRC)
aux_source_directory(models MODEL_SRC)
drogon_create_views(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/views
${CMAKE_CURRENT_BINARY_DIR})
# 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}
${CMAKE_CURRENT_SOURCE_DIR}/models)
target_sources(${PROJECT_NAME}
PRIVATE
${SRC_DIR}
${CTL_SRC}
${FILTER_SRC}
${PLUGIN_SRC}
${MODEL_SRC})
# ##############################################################################
# uncomment the following line for dynamically loading views
# set_property(TARGET ${PROJECT_NAME} PROPERTY ENABLE_EXPORTS ON)
# ##############################################################################
add_subdirectory(test)
```
Screenshots:

Additional context:
I have compiled drogon into directory:
D:\saint\tools\Drogon
The directory where project is created using drogon_ctl.exe is at:
C:\Users\saint\source\repos\drogon-test
Contributor guide
Assessment
This issue has not been assessed yet.