0

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.

  • 1
    I think you'll need to you a package manager that checks for require dependencies before running the cmake utility, if not mistaken (depending on Linux flavor) apt, https://devconnected.com/apt-package-manager-on-linux-explained/ – MZM Dec 12 '22 at 17:01

1 Answers1

2

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.

Alex Reinking
  • 16,724
  • 5
  • 52
  • 86