# Build INSTALL with Visual Studio

**URL:** https://discourse.itk.org/t/build-install-with-visual-studio/1194
**Category:** Engineering
**Created:** [August 11, 2018, 9:03pm UTC](https://discourse.itk.org/t/build-install-with-visual-studio/1194 "2018-08-11T21:03:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Gib](https://discourse.itk.org/user_avatar/discourse.itk.org/gib/32/4124_2.png) [@Gib](https://discourse.itk.org/u/Gib)
#### Post date: [August 11, 2018, 9:03pm UTC](https://discourse.itk.org/t/build-install-with-visual-studio/1194/1 "2018-08-11T21:03:43Z")

</div>

I use cmake to create the VS project for building ITK. Until now I’ve been only building the Release libraries, now I want to build and use the Debug libraries as well. It took me a while to realise that when I Build INSTALL, whether Release or Debug the libraries are copied to the specified install directory, with the same names. In other words although the build directory has separate lib\Release and lib\Debug directories containing the two sets of libraries, there is only one install lib directory. Is there a way to get cmake to set up the VS project in a way that will make Build INSTALL create separate Release and Debug lib directories? I am using the cmake GUI.

My ITK build directory is: D:\ITK-VS11-x64-build  
the install directory is C:\ITK  
Normally I set the environment variable ITK-DIR = C:\ITK.  
If I set ITK-DIR = D:\ITK-VS11-x64-build the right libraries are found by VS when I build a program that uses ITK, depending on which build I select. This enables building of either Release or Debug versions of my program, but seems to make the ITK install directory pointless. Am I missing something?

I have a cmake question. I use cmake to create the VS project to build my program, with these lines in CMakeLists.txt:

FIND\_PACKAGE(ITK)  
IF(ITK\_FOUND)  
INCLUDE(${ITK\_USE\_FILE})  
ELSE(ITK\_FOUND)  
MESSAGE(FATAL\_ERROR  
“ITK not found. Please set ITK\_DIR.”)  
ENDIF(ITK\_FOUND)

How can I tell cmake to use the ITK build directory, without setting ITK\_DIR?

Thanks  
Gib

---

<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: [August 13, 2018, 3:03pm UTC](https://discourse.itk.org/t/build-install-with-visual-studio/1194/2 "2018-08-13T15:03:48Z")

</div>

Install option is meant for Release or RelWithDebInfo variant, as would be done at some non-developer computer.

As you can have many ITK build directories, and have them anywhere in your directory tree, how could CMake know which one you want? Anyway, I know that CMake picks up as `ITK_DIR` one of my build trees (not the one I usually want). The point 6 on the [search list](https://cmake.org/cmake/help/v3.12/command/find_package.html) examines [package registry](https://cmake.org/cmake/help/v3.12/manual/cmake-packages.7.html#user-package-registry) - I suppose I somehow added that ITK build there.

---

<div class="post-metadata">

### Author: ![Gib](https://discourse.itk.org/user_avatar/discourse.itk.org/gib/32/4124_2.png) [@Gib](https://discourse.itk.org/u/Gib)
#### Post date: [August 14, 2018, 9:12pm UTC](https://discourse.itk.org/t/build-install-with-visual-studio/1194/3 "2018-08-14T21:12:35Z")

</div>

Thanks Dzenan, I’ve been using INSTALL wrongly then. I should always set ITK\_DIR to the build directory.

Cheers  
Gib
