# Doxygen problems with find\_package()

**URL:** https://discourse.cmake.org/t/doxygen-problems-with-find-package/10527
**Category:** Code
**Tags:** os:windows
**Created:** [March 29, 2024, 3:28am UTC](https://discourse.cmake.org/t/doxygen-problems-with-find-package/10527 "2024-03-29T03:28:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Saviz](https://discourse.cmake.org/user_avatar/discourse.cmake.org/saviz/32/6194_2.png) [@Saviz](https://discourse.cmake.org/u/Saviz)
#### Post date: [March 29, 2024, 3:28am UTC](https://discourse.cmake.org/t/doxygen-problems-with-find-package/10527/1 "2024-03-29T03:28:49Z")

</div>

I am experiencing significant difficulties with the `find_package()` command. I find it to be rather unreliable, as there are instances where it fails to locate dependencies even under ideal conditions. Below is the code snippet I utilized for finding the **Doxygen** package:

```cmake
find_package(Doxygen REQUIRED)

set(DOXYGEN_GENERATE_HTML YES)
set(DOXYGEN_HTML_OUTPUT "${CMAKE_BINARY_DIR}/doxygen")
set(DOXYGEN_GENERATE_TREEVIEW YES)

doxygen_add_docs(documentation "${PROJECT_SOURCE_DIR}" ALL COMMENT "Generating documentation")

```

This command worked perfectly fine on my previous machine, but now that I’ve migrated to a new installation, it completely broke. I also made sure to check whether the package is installed on my new machine, and I can confirm that it is.

Now, I am considering migrating from `find_package()` to `FetchContent`. I was wondering if it is at all possible to utilize `FetchContent` instead of `find_package()` to avoid the frustrations associated with this command.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [March 29, 2024, 8:06am UTC](https://discourse.cmake.org/t/doxygen-problems-with-find-package/10527/2 "2024-03-29T08:06:26Z")

</div>

The `find_package()` command works reliably, but you are responsible for preparing the environment so it can find what you ask it to look for. The command’s documentation lists in detail the paths it searches, and in what order. It is rather involved, which is a reflection of the number of different conventions across platforms, vendors, and practices that became common enough they needed to be supported. You need to ensure that the package you expect to be found is in fact locatable in one of those locations.

The situation you describe isn’t what I would consider appropriate motivation to switch to using FetchContent. Using FetchContent would probably find things more reliably, but that’s only because you have to give it an unambiguous location for where to fetch the dependency from. There are other advantages and disadvantages to FetchContent, and it does have integration with the `find_package()` command as well since CMake 3.24. I suggest you read the docs for both `find_package()` and FetchContent fully and carefully before making a decision to switch from one strategy to another. You may find yourself just trading one set of problems for another, but you may also find details that matter to your specific case that make one a clear winner over the other.

If you are still undecided after that, you will win more friends in the open source community if you use `find_package()` to find your dependencies. It puts more onus on the developer to prepare their environment, but it is also much better supported by package managers like Conan and vcpkg.
