# How to use cmake fetchcontent to download itk and it's devedent projects?

**URL:** https://discourse.itk.org/t/how-to-use-cmake-fetchcontent-to-download-itk-and-its-devedent-projects/5785
**Category:** Beginner Questions
**Created:** [March 7, 2023, 3:01am UTC](https://discourse.itk.org/t/how-to-use-cmake-fetchcontent-to-download-itk-and-its-devedent-projects/5785 "2023-03-07T03:01:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![BlackCat\_Ruelle](https://discourse.itk.org/user_avatar/discourse.itk.org/blackcat_ruelle/32/3293_2.png) [@BlackCat\_Ruelle](https://discourse.itk.org/u/BlackCat_Ruelle)
#### Post date: [March 7, 2023, 3:01am UTC](https://discourse.itk.org/t/how-to-use-cmake-fetchcontent-to-download-itk-and-its-devedent-projects/5785/1 "2023-03-07T03:01:44Z")

</div>

Hi, I am new to ITK. I am trying to use cmake to download ITK source code and build my projects. By it gives me strange error:

“CMake Error at CMakeLists.txt:18 (include):  
include called with wrong number of arguments. include() only takes one  
file.”

Does anybody know what I am doing wrong here?  
Thanks!

Here is my CMakeLists.txt file:

```auto
cmake_minimum_required(VERSION 3.19.7 FATAL_ERROR)

project(test LANGUAGES CXX)

set(BUILD_TESTING OFF)
set(BUILD_EXAMPLES OFF)

include(FetchContent)
FetchContent_Declare(
  ITK
  GIT_REPOSITORY https://github.com/InsightSoftwareConsortium/ITK.git
  GIT_TAG v5.3.0 
  FIND_PACKAGE_ARGS NAMES ITK
)
FetchContent_MakeAvailable(ITK)

find_package(ITK REQUIRED)
add_executable(test test.cpp)
target_link_libraries(test ${ITK_LIBRARIES})
```

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [March 7, 2023, 2:22pm UTC](https://discourse.itk.org/t/how-to-use-cmake-fetchcontent-to-download-itk-and-its-devedent-projects/5785/2 "2023-03-07T14:22:56Z")

</div>

What happens if you replace `find_package(ITK REQUIRED)` by this:

```plaintext
set(ITK_DIR ${itk_BINARY_DIR} CACHE PATH "ITK's build directory" FORCE)
find_package(ITK REQUIRED CONFIG)
include(${ITK_USE_FILE})

```

Not all this might be necessary, you might be missing only `include(${ITK_USE_FILE})`.

---

<div class="post-metadata">

### Author: ![BlackCat\_Ruelle](https://discourse.itk.org/user_avatar/discourse.itk.org/blackcat_ruelle/32/3293_2.png) [@BlackCat\_Ruelle](https://discourse.itk.org/u/BlackCat_Ruelle)
#### Post date: [March 7, 2023, 4:55pm UTC](https://discourse.itk.org/t/how-to-use-cmake-fetchcontent-to-download-itk-and-its-devedent-projects/5785/3 "2023-03-07T16:55:57Z")

</div>

Dženan,  
Thanks for the help, but I am still getting the same error.  
Thanks,  
BR

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [March 7, 2023, 5:03pm UTC](https://discourse.itk.org/t/how-to-use-cmake-fetchcontent-to-download-itk-and-its-devedent-projects/5785/4 "2023-03-07T17:03:38Z")

</div>

Maybe try a clean build, or at least deleting CMake cache?

---

<div class="post-metadata">

### Author: ![BlackCat\_Ruelle](https://discourse.itk.org/user_avatar/discourse.itk.org/blackcat_ruelle/32/3293_2.png) [@BlackCat\_Ruelle](https://discourse.itk.org/u/BlackCat_Ruelle)
#### Post date: [March 7, 2023, 10:03pm UTC](https://discourse.itk.org/t/how-to-use-cmake-fetchcontent-to-download-itk-and-its-devedent-projects/5785/5 "2023-03-07T22:03:32Z")

</div>

It turns out that I need to set

```auto
set(ITK_DIR ${ITK_BINARY_DIR} CACHE STRING "Make the ITK_DIR available to other modules" FORCE)
```
