# Correct usage of FindSQLite3 module in Windows

**URL:** https://discourse.cmake.org/t/correct-usage-of-findsqlite3-module-in-windows/174
**Category:** Usage
**Created:** [November 9, 2019, 12:29am UTC](https://discourse.cmake.org/t/correct-usage-of-findsqlite3-module-in-windows/174 "2019-11-09T00:29:41Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![arcesino](https://discourse.cmake.org/user_avatar/discourse.cmake.org/arcesino/32/143_2.png) [@arcesino](https://discourse.cmake.org/u/arcesino)
#### Post date: [November 10, 2019, 9:31am UTC](https://discourse.cmake.org/t/correct-usage-of-findsqlite3-module-in-windows/174/3 "2019-11-10T09:31:40Z")

</div>

Hi Ben,

My understanding is that the `.dll` is required for both: linking and at runtime.

After looking closer at the **FindSQLite3.cmake** module’s source code and further investigating CMake commands [find\_path](https://cmake.org/cmake/help/latest/command/find_path.html) & [find\_library](https://cmake.org/cmake/help/latest/command/find_library.html), which are used by the module to set variables _SQLite3\_INCLUDE\_DIR_ & \* SQLite3\_LIBRARY\* respectively, I came up with the following solution:

```
add_executable(sqlite-cache sqlite-cache/main.cpp)

if(WIN32)
  set(CMAKE_PREFIX_PATH C:\\sdk\\sqlite-3.30.1)
endif()

find_package(SQLite3 REQUIRED)
target_include_directories(sqlite-cache PRIVATE ${SQLite3_INCLUDE_DIRS})
target_link_libraries(sqlite-cache ${SQLite3_LIBRARIES})

```

According to the documentation of _find\_path_ and _find\_library_ commands, one of the steps of their search algorithm is to look inside paths specified in **CMAKE\_PREFIX\_PATH** ; per these commands documentation will search for include paths as:

> `<prefix>/include/<arch>` if `CMAKE_LIBRARY_ARCHITECTURE` is set, and `<prefix>/include` for each `<prefix>` in `CMAKE_PREFIX_PATH`

and for libraries as:

> `<prefix>/lib/<arch>` if `CMAKE_LIBRARY_ARCHITECTURE` is set, and `<prefix>/lib` for each `<prefix>` in `CMAKE_PREFIX_PATH`

As you can see, the commands enforce that headers must be inside an `include/` dir and libraries inside a `lib/` dir and since my SQLite installation happens to have that format, then the solution above works. The search algorithm also looks in directories declared in system env vars like _PATH_ and _INCLUDE_, but I prefer this approach since headers & libraries will be found faster.

---

_[View the full topic](https://discourse.cmake.org/t/correct-usage-of-findsqlite3-module-in-windows/174)._
