# How to find third-party header files in /Applications on MacOS?

**URL:** <https://discourse.cmake.org/t/how-to-find-third-party-header-files-in-applications-on-macos/2597>\
**Category:** Code\
**Tags:** os:macos\
**Created:** [January 21, 2021, 10:08pm UTC](https://discourse.cmake.org/t/how-to-find-third-party-header-files-in-applications-on-macos/2597 "2021-01-21T22:08:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomoreilly](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)\
**Post date:** [January 21, 2021, 10:08pm UTC](https://discourse.cmake.org/t/how-to-find-third-party-header-files-in-applications-on-macos/2597/1 "2021-01-21T22:08:00Z")

</div>

What CMAKE\_ variable should I include in the PATHS argument to find\_file(), such that /Applications will be searched on MacOS?

For example: I’m running MacOS 10.13.6 (“High Sierra”), and I’ve installed a third-party application (GMT-6.1.1) and headers via a downloaded .dmg file into /Applications. My own application must be compiled with GMT headers, which are in this directory:

`/Applications//GMT-6.1.1.app/Contents/Resources/include/gmt/`

Of course I want to avoid hard-coding “/Applications” in my cmake scripts…

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [January 22, 2021, 1:54pm UTC](https://discourse.cmake.org/t/how-to-find-third-party-header-files-in-applications-on-macos/2597/2 "2021-01-22T13:54:49Z")

</div>

I would do something like:

```cmake
set(_gmt_roots ${GMT_APP_ROOTS} /Applications) # document this variable
set(_gmt_versions ${GMT_APP_VERSIONS} 6.1.1) # document this variable
set(_gmt_prefixes)
foreach (_gmt_version IN LISTS _gmt_versions)
  foreach (_gmt_root IN LISTS _gmt_roots)
    list(APPEND _gmt_prefixes "${_gmt_root}/GMT-${_gmt_version}.app/Contents/Resources/include")
  endforeach ()
endforeach ()
unset(_gmt_versions)
unset(_gmt_version)
unset(_gmt_root)
unset(_gmt_roots)

find_file(GMT_INCLUDE_DIR
  NAMES gmt/someheader.h
  PATHS ${_gmt_prefixes}
  DOC "…")
mark_as_advanced(GMT_INCLUDE_DIR)
unset(_gmt_prefixes)

```

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [January 22, 2021, 1:58pm UTC](https://discourse.cmake.org/t/how-to-find-third-party-header-files-in-applications-on-macos/2597/3 "2021-01-22T13:58:25Z")

</div>

Note that you might want other roots or prefix logic based on the platform you’re on.
