Skip to content

Configurable drogon_ctl location#2453

Closed
gav2xlin wants to merge 1 commit intodrogonframework:masterfrom
gav2xlin:configurable_drogon_ctl_location
Closed

Configurable drogon_ctl location#2453
gav2xlin wants to merge 1 commit intodrogonframework:masterfrom
gav2xlin:configurable_drogon_ctl_location

Conversation

@gav2xlin
Copy link
Copy Markdown

@gav2xlin gav2xlin commented Feb 11, 2026

Hello. Please make the location of the drogon_ctl command configurable from CMake scripts directly.

https://cmake.org/cmake/help/latest/command/find_program.html

https://cmake.org/cmake/help/latest/variable/CMAKE_PROGRAM_PATH.html

Semicolon-separated list of directories specifying a search path for the find_program() command. By default it is empty, it is intended to be set by the project.

The Drogon library is not always installed on the system so that the path to the drogon_ctl command globally set in the PATH environment variable. At the same time, the CMAKE_PROGRAM_PATH variable is configurable from CMake scripts.

https://github.com/drogonframework/drogon/blob/master/cmake/DrogonUtilities.cmake

I'm considering a scenario where the Drogon library is installed by package managers such as Conan which creates its own environment.

From my system:
~/.conan2$ find . -iname 'drogon_ctl' ./p/b/drogoa449f6147cb12/p/bin/drogon_ctl ./p/b/drogoa449f6147cb12/b/build/Release/drogon_ctl ./p/b/drogoa449f6147cb12/b/build/Release/drogon_ctl/drogon_ctl ./p/b/drogoa449f6147cb12/b/src/drogon_ctl ./p/b/drogo79535e018a23d/p/bin/drogon_ctl ./p/b/drogo79535e018a23d/b/build/Debug/drogon_ctl ./p/b/drogo79535e018a23d/b/build/Debug/drogon_ctl/drogon_ctl ./p/b/drogo79535e018a23d/b/src/drogon_ctl ./p/drogo60067c88c49b2/s/src/drogon_ctl

This has been fixed. Hence, this script is included automatically in the builds, but the drogon_create_views() function still does not work because it is impossible to configure the path to this command anywhere 🤔

./p/b/drogoa449f6147cb12/p/lib/cmake/Drogon/DrogonUtilities.cmake
./p/b/drogoa449f6147cb12/b/src/cmake/DrogonUtilities.cmake
./p/b/drogo79535e018a23d/p/lib/cmake/Drogon/DrogonUtilities.cmake
./p/b/drogo79535e018a23d/b/src/cmake/DrogonUtilities.cmake
./p/drogo60067c88c49b2/s/src/cmake/DrogonUtilities.cmake

@gav2xlin
Copy link
Copy Markdown
Author

gav2xlin commented Feb 12, 2026

I've tested my change, but I use Conan

find_program(DROGON_CTL drogon_ctl REQUIRED) message(STATUS "DROGON_CTL ${DROGON_CTL}")

conan install -r conancenter --update . --build=missing

conan install . --build=missing

and

cmake --preset conan-release -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build --preset conan-release

The first command prints this
-- DROGON_CTL /home/gav2xlin/.conan2/p/b/drogo038e8a0079189/p/bin/drogon_ctl

from this project https://github.com/PacktPublishing/Software-Architecture-with-Cpp-2E/tree/ch12-drogon-ctl/Chapter12/customer

$ find . -iname 'greet*'
./build/Release/src/customer/CMakeFiles/customer.dir/greet.cc.o
./build/Release/src/customer/CMakeFiles/customer.dir/greet.cc.o.d
./build/Release/src/customer/greet.h
./build/Release/src/customer/greet.cc
./src/customer/views/greet.csp

Chapter12/customer/src/customer/CMakeLists.txt

drogon_create_views(customer ${CMAKE_CURRENT_SOURCE_DIR}/views/
                    ${CMAKE_CURRENT_BINARY_DIR})

build/Release/generators/CMakePresets.json
"configurePresets": [ { "name": "conan-release", "displayName": "'conan-release' config", "description": "'conan-release' configure using 'Unix Makefiles' generator", "generator": "Unix Makefiles", "cacheVariables": { "CMAKE_POLICY_DEFAULT_CMP0091": "NEW", "CMAKE_BUILD_TYPE": "Release" }, "environment": { "PATH": "/home/gav2xlin/.conan2/p/b/drogo038e8a0079189/p/bin:$penv{PATH}", "LD_LIBRARY_PATH": "/home/gav2xlin/.conan2/p/b/drogo038e8a0079189/p/lib:$penv{LD_LIBRARY_PATH}", "DYLD_LIBRARY_PATH": "/home/gav2xlin/.conan2/p/b/drogo038e8a0079189/p/lib:$penv{DYLD_LIBRARY_PATH}" }, "toolchainFile": "generators/conan_toolchain.cmake", "binaryDir": "/home/gav2xlin/Book/Software-Architecture-with-Cpp-2E/Chapter12/customer/build/Release" } ],

drogon_ctl is compiled and installed here
/home/gav2xlin/.conan2/p/b/drogo038e8a0079189/p/bin

In your tests and builds, find_program(DROGON_CTL drogon_ctl REQUIRED) is called before the drogon_ctl command is built and installed 🤔

@gav2xlin gav2xlin closed this Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant