using <packagename>_ROOT does not appear to be used by find_program(<packagename>)


the following lines of codes can’t find my sqlite3.exe. Is this normal?

set(EXE_SQLITE3_ROOT D:/ftarroux/Documents/FRED/BaseGit/simbox_externalProject/install/Windows-MSVC-1916-Win32/sqlite/bin/)

find_program(EXE_SQLITE3 sqlite3 REQUIRED)
message(“fred ${EXE_SQLITE3}”)

return : “fred D:/ftarroux/scoop/apps/gdb/current/bin/sqlite3.exe”
and i want D:/ftarroux/Documents/FRED/BaseGit/simbox_externalProject/install/Windows-MSVC-1916-Win32/sqlite/bin/sqlite3.exe

The _ROOT variable is only used by find_package, not arbitrary find_XXX calls. You can add HINTS ${EXE_SQLITE3_ROOT} though to use it if available.

1 Like


But in documentation we can see :

If called from within a find module or any other script loaded by a call to find_package(<PackageName>), search prefixes unique to the current package being found. Specifically, look in the <PackageName>_ROOT CMake variable and the <PackageName>_ROOT environment variable. The package root variables are maintained as a stack, so if called from nested find modules or config packages, root paths from the parent’s find module or config package will be searched after paths from the current module or package. In other words, the search order would be <CurrentPackage>_ROOT, ENV{<CurrentPackage>_ROOT}, <ParentPackage>_ROOT, ENV{<ParentPackage>_ROOT}, etc. This can be skipped if NO_PACKAGE_ROOT_PATH is passed or by setting the CMAKE_FIND_USE_PACKAGE_ROOT_PATH to FALSE. See policy CMP0074.

is it an error ?

From the docs you quoted:

Are you calling find_program from a find module or a script loaded by find_package? You made no indication of such in your original post, and it seemed you’re just calling it from your CMakeLists.txt file.

Oh, good catch. I didn’t realize that its usage was context-sensitive for other find_XXX calls. If that is the case, the _ROOT probably needs to lose the bin suffix.

Thank you,

I had missed the “if”. So I wouldn’t use <package_name>_ROOT.