# CMake's equivalent of AC\_SEARCH\_LIBS (to find std::filesystem)?

**URL:** https://discourse.cmake.org/t/cmakes-equivalent-of-ac-search-libs-to-find-std-filesystem/4818
**Category:** Code
**Created:** [January 12, 2022, 10:22am UTC](https://discourse.cmake.org/t/cmakes-equivalent-of-ac-search-libs-to-find-std-filesystem/4818 "2022-01-12T10:22:56Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![petwu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/petwu/32/1399_2.png) [@petwu](https://discourse.cmake.org/u/petwu)
#### Post date: [January 12, 2022, 2:24pm UTC](https://discourse.cmake.org/t/cmakes-equivalent-of-ac-search-libs-to-find-std-filesystem/4818/2 "2022-01-12T14:24:56Z")

</div>

It seems like there is an [ongoing discussion](https://gitlab.kitware.com/cmake/cmake/-/issues/17834) on whether this is something that should be addressed in upstream CMake and if so how. So unfortunately, there is no “correct” solution provided by CMake and for now every project has to come up with their own approach to solve this.

IMHO a reasonable and well working approach is to use a `FindFilesystem` module like [this](https://github.com/lethal-guitar/RigelEngine/blob/master/cmake/Modules/FindFilesystem.cmake) one. Simply save it somewhere in your project (commonly a `cmake/` directory) and prepend that path to [CMAKE\_MODULE\_PATH](https://cmake.org/cmake/help/latest/variable/CMAKE_MODULE_PATH.html) in order to use it. The module performs several `check_cxx_source_compiles()` checks (+ 1 hard-coded special case) to figure out which flag is required and then provides and interface target as an abstraction that can be used like this:

```cmake
find_package(Filesystem REQUIRED)
target_link_libraries(myLib PRIVATE Filesystem::Filesystem)

```

This approach is analogous to the [FindThreads](https://cmake.org/cmake/help/latest/module/FindThreads.html) module with its `Threads::Threads` target provided by CMake.

---

_[View the full topic](https://discourse.cmake.org/t/cmakes-equivalent-of-ac-search-libs-to-find-std-filesystem/4818)._
