Unknown CMake command "drogon_create_views"
Notice If you need support or clarification regarding the usage of Drogon in your project, visit the official Drogon support channel at gitter
Please create a new issue only if you think you have found a bug or if have a feature request/enhancement.
Describe the bug I use conan2 to manage drogon, and use drogon_ctl to create the project. but cmake build error:
CMake Error at CMakeLists.txt:52 (drogon_create_views):
Unknown CMake command "drogon_create_views".
To Reproduce Steps to reproduce the behavior:
- $HOME/.conan/xxxxx/drogon_ctl create project xxxx && cd xxxx
- conan install . -s build_type=Debug -s compiler.cppstd=gnu20 --build=missing
- cmake --preset "conan-debug"
Expected behavior correct cmake
Screenshots If applicable, add screenshots to help explain your problem.
C:\Windows\system32\wsl.exe --distribution Ubuntu --exec /usr/bin/zsh -c "export CMAKE_COLOR_DIAGNOSTICS=ON && export CLION_IDE=TRUE && export JETBRAINS_IDE=TRUE && cd /home/cayin/repo/drogon-demo/build/Debug && /usr/bin/cmake --preset conan-debug -S /home/cayin/repo/drogon-demo -B /home/cayin/repo/drogon-demo/build/Debug"
Preset CMake variables:
CMAKE_BUILD_TYPE="Debug"
CMAKE_POLICY_DEFAULT_CMP0091="NEW"
CMAKE_TOOLCHAIN_FILE:FILEPATH="/home/cayin/repo/drogon-demo/build/Debug/generators/conan_toolchain.cmake"
Preset environment variables:
PATH="/home/cayin/.conan2/p/cmakecf6b18ccaa9f5/p/bin:/home/cayin/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/VulkanSDK/1.3.268.0/Bin:/mnt/c/Users/Cayin/scoop/apps/jenv/current:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files/Bandizip/:/mnt/c/Users/Cayin/AppData/Roaming/nvm:/mnt/c/Program Files/nodejs:/mnt/e/微信web开发者工具/dll:/mnt/e/App:/mnt/c/Pr:/mnt/c/Pro:/mnt/c/Pro:/mnt/c/Program Files/PowerShell/7/:/mnt/c/Program Files/Git/cmd:/Docker/host/bin:/mnt/e/App/微信web开发者工具/dll:/mnt/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit/:/mnt/c/Users/Cayin/scoop/shims:/mnt/c/Users/Cayin/miniconda3:/mnt/c/Users/Cayin/miniconda3/Library/mingw-w64/bin:/mnt/c/Users/Cayin/miniconda3/Library/usr/bin:/mnt/c/Users/Cayin/miniconda3/Library/bin:/mnt/c/Users/Cayin/miniconda3/Scripts:/mnt/c/Users/Cayin/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/Cayin/AppData/Local/Programs/oh-my-posh/bin:/mnt/c/Program Files/JetBrains/IntelliJ IDEA 2022.3.3/bin:/mnt/c/Users/Cayin/AppData/Local/GitHubDesktop/bin:/mnt/c/Users/Cayin/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/Cayin/AppData/Roaming/nvm:/mnt/c/Program Files/nodejs:/mnt/c/Users/Cayin/AppData/Local/JetBrains/Toolbox/scripts:/mnt/c/Users/Cayin/AppData/Local/Microsoft/WinGet/Links:/mnt/c/Program Files/Neovim/bin"
-- Using Conan toolchain: /home/cayin/repo/drogon-demo/build/Debug/generators/conan_toolchain.cmake
-- Conan toolchain: C++ Standard 20 with extensions ON
-- Conan: Target declared 'Drogon::Drogon'
-- Conan: Target declared 'Trantor::Trantor'
-- Conan: Component target declared 'c-ares::cares'
-- Conan: Component target declared 'OpenSSL::Crypto'
-- Conan: Component target declared 'OpenSSL::SSL'
-- Conan: Target declared 'openssl::openssl'
-- Conan: Target declared 'ZLIB::ZLIB'
-- Conan: Including build module from '/home/cayin/.conan2/p/b/opens1c9b1ba46cf62/p/lib/cmake/conan-official-openssl-variables.cmake'
-- Conan: Target declared 'JsonCpp::JsonCpp'
-- Conan: Target declared 'libuuid::libuuid'
-- Conan: Component target declared 'Boost::diagnostic_definitions'
-- Conan: Component target declared 'Boost::disable_autolinking'
-- Conan: Component target declared 'Boost::dynamic_linking'
-- Conan: Component target declared 'Boost::headers'
-- Conan: Component target declared 'Boost::boost'
-- Conan: Component target declared 'boost::_libboost'
-- Conan: Component target declared 'Boost::atomic'
-- Conan: Component target declared 'Boost::container'
-- Conan: Component target declared 'Boost::context'
-- Conan: Component target declared 'Boost::date_time'
-- Conan: Component target declared 'Boost::exception'
-- Conan: Component target declared 'Boost::math'
-- Conan: Component target declared 'Boost::math_c99'
-- Conan: Component target declared 'Boost::math_c99f'
-- Conan: Component target declared 'Boost::math_c99l'
-- Conan: Component target declared 'Boost::math_tr1'
-- Conan: Component target declared 'Boost::math_tr1f'
-- Conan: Component target declared 'Boost::math_tr1l'
-- Conan: Component target declared 'Boost::program_options'
-- Conan: Component target declared 'Boost::regex'
-- Conan: Component target declared 'Boost::serialization'
-- Conan: Component target declared 'Boost::stacktrace'
-- Conan: Component target declared 'Boost::stacktrace_addr2line'
-- Conan: Component target declared 'Boost::stacktrace_backtrace'
-- Conan: Component target declared 'Boost::stacktrace_basic'
-- Conan: Component target declared 'Boost::stacktrace_noop'
-- Conan: Component target declared 'Boost::system'
-- Conan: Component target declared 'Boost::test'
-- Conan: Component target declared 'Boost::test_exec_monitor'
-- Conan: Component target declared 'Boost::timer'
-- Conan: Component target declared 'Boost::url'
-- Conan: Component target declared 'Boost::wserialization'
-- Conan: Component target declared 'Boost::chrono'
-- Conan: Component target declared 'Boost::coroutine'
-- Conan: Component target declared 'Boost::filesystem'
-- Conan: Component target declared 'Boost::json'
-- Conan: Component target declared 'Boost::nowide'
-- Conan: Component target declared 'Boost::prg_exec_monitor'
-- Conan: Component target declared 'Boost::random'
-- Conan: Component target declared 'Boost::thread'
-- Conan: Component target declared 'Boost::type_erasure'
-- Conan: Component target declared 'Boost::unit_test_framework'
-- Conan: Component target declared 'Boost::wave'
-- Conan: Component target declared 'Boost::contract'
-- Conan: Component target declared 'Boost::fiber'
-- Conan: Component target declared 'Boost::fiber_numa'
-- Conan: Component target declared 'Boost::graph'
-- Conan: Component target declared 'Boost::iostreams'
-- Conan: Component target declared 'Boost::locale'
-- Conan: Component target declared 'Boost::log'
-- Conan: Component target declared 'Boost::log_setup'
-- Conan: Target declared 'boost::boost'
-- Conan: Target declared 'BZip2::BZip2'
-- Conan: Including build module from '/home/cayin/.conan2/p/b/bzip230ec9bc078e7f/p/lib/cmake/conan-official-bzip2-variables.cmake'
-- Conan: Target declared 'libbacktrace::libbacktrace'
-- use c++20
CMake Error at CMakeLists.txt:52 (drogon_create_views):
Unknown CMake command "drogon_create_views".
-- Configuring incomplete, errors occurred!
[Failed to reload]
Desktop (please complete the following information):
- OS: [e.g. iOS]
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
- HOST
WSL version: 2.0.9.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.3007
- cmake
cmake version 3.28.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
- conan
version: 2.0.17
python
version: 3.11.5
sys_version: 3.11.5 (main, Sep 11 2023, 13:54:46) [GCC 11.2.0]
- conanfile.py
from conan import ConanFile
from conan.tools.cmake import cmake_layout
class CompressorRecipe(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"
exports_sources = "CMakeLists.txt", "src/*", "include/*"
default_options = {
"drogon/*:with_ctl": True,
}
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires("drogon/1.9.1")
self.requires("spdlog/1.13.0")
def build_requirements(self):
self.tool_requires("cmake/3.28.1")
- CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(drogon-demo 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)
#find_package(Drogon REQUIRED)
#target_link_libraries(${PROJECT_NAME} 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)
@an-tao I've never used Conan, so I have no idea... I think there is another maintainer who has used it.
Yes, I think one of our maintainers used Conan in the past, but it wasn’t me either.
It seems that DrogonUtilities.cmake (and other 2 files) are not... exported?