Home > Blockchain >  cmake - How to make sure a program(dependency) is installed on users machine
cmake - How to make sure a program(dependency) is installed on users machine

Time:12-14

My c programm(for linux) needs users to have a specific programm lets say "foo" be installed to work. I am using cmake to generate build files.

This program is to be distributed.

How can I make sure that it is installed using cmake.

I found this but it's for checking at runtime. I want to check it before building the program.

CodePudding user response:

If foo provides a CMake package, use find_package to find foo:

find_package(foo REQUIRED)

# Use the foo::foo imported target or foo_EXECUTABLE cache variable

There are many built-in packages for CMake including Python and FLEX.


If foo does not provide a CMake package and you only need the path to the executable, then you can use find_program:

find_program(Foo_EXECUTABLE foo REQUIRED)

From here you can use the Foo_EXECUTABLE variable in your execute_process or add_custom_command calls.

  • Related