What's the right way to use Find*.cmake modules in cmake/Qt6?
-
There are many 3rd party
Find*.cmake
modules in/usr/lib64/cmake/Qt6
, i.e.,FindWrapBrotli.cmake
,FindMySQL.cmake
, .etc.I try using it as following:
find(QT NAMES Qt6 REQUIRED COMPONENTS Core Widgets ...) # XX: import module include("${QT_DIR}/FindMySQL.cmake") add_executable(mydemo ...) # XX: use variables output by FindMySQL.cmake target_include_directories(mydemo PUBLIC ${MySQL_INCLUDE_DIR}) target_link_libraries(mydemo PUBLIC ${MySQL_LIBRARY})
In the above example, contains this line:
include("${QT_DIR}/FindMySQL.cmake")
Is there any problem in this use case? Or is there an
Offical
way/guide that makes the same purpose? -
@Sauntor simply use
Find_package(MySQL) even though I don't know why you want to use MySQL directly.
See https://cmake.org/cmake/help/latest/command/find_package.html
-
@Christian-Ehrlicher Those
Find*.cmake
seems deal cross platform problem already, i.e., deliver my project on windows and linux, if on windows, theFind*.cmake
would checkvcpkg
, on linux, it may find components usingpkg-config
, so, I do not have to write my own script when build using cmake. That's why I want to use thosecmake
scripts/modules! -
@Sauntor So what's the problem - simply use them as I wrote.