CMake. Custom find module for FLTK with FetchContent

67 views
Skip to first unread message

Daniel An.

unread,
Jul 10, 2024, 3:21:01 PMJul 10
to fltk.general
I plan to write a FLTK find module for my project. So using this module in user code will look like this:

find_package(FLTK <verion> MODULE REQUIRED)

Inside the module, a check will be performed for the availability of the requested version by searching for config fileSomething like this:
unset(FLTK_FIND_VERSION_COMPLETE)
find_package(FLTK CONFIG)
find_package_handle_standard_args(FLTK CONFIG_MODE)

If the requested version is not available, then this module downloads and build FLTK from Github (FetchContent_Declare, FethContent_MakeAvailable).

My question. Is it idiomatically correct to make downloads from the WEB inside the find module? Have you seen anything similar in other projects?

wea...@gmail.com

unread,
Jul 11, 2024, 5:22:39 AMJul 11
to fltk.general
I'm not an FLTK developer, but I have been playing around with cmake too. I think it is not in the scope of a find module to download and install content.
I solved this problem on a higher level in my hobby project. The user has the possibility to use system provided libraries (e.g. FLTK, spdlog, DCMTK, ...), separate option for each (-DUSE_SYSTEM_FLTK=1 or something like this), or if no system provided library is enabled then it downloads, compiles and installs the missing libraries. This is all in the top level cmake.

Albrecht Schlosser

unread,
Jul 11, 2024, 11:24:44 AMJul 11
to fltkg...@googlegroups.com
On 7/11/24 11:22 wea...@gmail.com wrote:
I'm not an FLTK developer, but I have been playing around with cmake too. I think it is not in the scope of a find module to download and install content.

I agree, and I suggest to ask such questions in the CMake (Discourse) Forum where CMake developers participate.
Reply all
Reply to author
Forward
0 new messages