Users can configure this with the CMAKE_FIND_FRAMEWORK variable.įinding executables in packages is one of the easiest things, compared to finding libraries.
rlib) won't ever be found, however we can find. The form for this is a bit odd, as languages with custom static library formats (e.g., Rust's. This is used to find both shared and static libraries. As long as you could execute it via something like exec (or CreateProcess on Windows), it can be used as an executable. Whether it is a script or an actual executable is actually irrelevant. This is used to find the path to a file that the system considers executable. We can cover them in detail in later posts.
Most of the time you don't need to worry about these additional parameters. The commands most typically used have a very large amount of documentation and thus it can be a bit overwhelming. This is the bare minimum we need for CMake to find our following find_package files. We can then add this path to our CMAKE_MODULE_PATH variable so CMake knows where to find us.
The most common place to put your cmake scripts is inside the project's root directory under a cmake/ directory. Additionally, 99.9% of the time, you'll want to use the CMake provided module FindPackageHandleStandardArgs.īefore we can use find_package, however, we need to make sure CMake can find it in the first place. Depending on what you are trying to find, you might also find yourself using execute_process, file(READ), file(STRINGS), string(REGEX MATCH), and mark_as_advanced. Each of these has a purpose, but we will not always use them. The most important ones are find_program, find_library, find_path, and lastly find_file. Within CMake, there are several commands that are used when writing a find_package file. For now, however, we'll focus on the most common workflow for CMake: Configure and Build.
#Msys2 cmake command not found how to
That said, we will eventually tackle how to handle writing a usable find_package file that can be used in cmake -find-package mode, in the so-called Script Mode or with cpack for the External Generator. Instead I'll be showing how to write what's known as a find_package MODULE file. Those have a different set of options but also tend to be smaller in practice. This tutorial is written for CMake 3.14 and later, though I personally recommend using CMake 3.16 as it is the version installed with the most recent Ubuntu LTS release, 20.04.Īdditionally, this tutorial isn't meant to discuss how to write a -config.cmake file. We'll be using some of what I've learned and figured out over the past two years to understand how find_package files work and how to make them useful for your projects and the folks who depend on them. It's called IXM, and while it's not ready for general use, it is where I realized there is a common set of operations for finding packages, their components, and setting their correct properties. In a previous post, I alluded to a project I've been working on since 2018. There's an easier way to do it these days! At the end of this, they might have a file that kind of works, but most likely is based off of a tutorial from 2008. If they are extremely unlucky, they might have to write a file to work with find_package.
If they are unlucky, they might have to find dependencies using find_package. Whether we want to or not, many folks have to interact with CMake at least once in their life.