# ExternalProject\_Add error MSB1009: Project file does not exist

**URL:** https://discourse.cmake.org/t/externalproject-add-error-msb1009-project-file-does-not-exist/8893
**Category:** Usage
**Created:** [September 6, 2023, 12:48am UTC](https://discourse.cmake.org/t/externalproject-add-error-msb1009-project-file-does-not-exist/8893 "2023-09-06T00:48:30Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![jaquilio](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jaquilio/32/3789_2.png) [@jaquilio](https://discourse.cmake.org/u/jaquilio)
#### Post date: [September 6, 2023, 12:48am UTC](https://discourse.cmake.org/t/externalproject-add-error-msb1009-project-file-does-not-exist/8893/1 "2023-09-06T00:48:30Z")

</div>

I am trying to build an external library using ExternalProject\_Add. I am getting the _Project file does not exist_ error while building with MS Visual Studio.

```auto
  MSBuild version 17.7.2+d6990bcfa for .NET Framework
  
    Checking Build System
    Performing update step for 'poissonRecon'
    No patch step for 'poissonRecon'
    Performing configure step for 'poissonRecon'
    -- Configuring done (0.0s)
    -- Generating done (0.1s)
    -- Build files have been written to: C:/qlabRoot/build/External/poissonRecon/poissonRecon
    Performing build step for 'poissonRecon'
    MSBuild version 17.7.2+d6990bcfa for .NET Framework
    
      QPOISSON_RECON_LIB.vcxproj -> C:\qlabRoot\build\External\poissonRecon\poissonRecon\Debug\QPOISSON_RECON_LIB.lib
    Performing install step for 'poissonRecon'
    MSBuild version 17.7.2+d6990bcfa for .NET Framework
C:\qlabRoot\projects\CommonExternal\MSBUILD : error MSB1009: Project file does not exist. 

```

Can someone please provide some insight about the cause of this error?

My CMakeLists.txt file:

```auto
cmake_minimum_required(VERSION 3.24)
project(poissonRecon)

include(ExternalProject)

get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (NOT isMultiConfig)
  if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE
        Debug
        CACHE STRING "" FORCE)
  endif ()
  set(build_type_dir ${CMAKE_BUILD_TYPE})
  set(build_type_arg -DCMAKE_BUILD_TYPE=$<CONFIG>)
else ()
  set(build_config_arg --config=$<CONFIG>)
endif ()

ExternalProject_Add(
  poissonRecon
  GIT_REPOSITORY https://github.com/CloudCompare/PoissonRecon.git
  GIT_TAG 85c010229a1c5f2e186488290c2f93fec7da4ad5 
  BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/poissonRecon/${build_type_dir}
  INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/poissonRecon/${CMAKE_BUILD_TYPE}
  CMAKE_COMMAND ${CMAKE_COMMAND}
  CMAKE_ARGS ${build_type_arg} -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>

  BUILD_COMMAND cmake --build <BINARY_DIR> ${build_config_arg}
)

```

---

<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: [September 6, 2023, 12:19pm UTC](https://discourse.cmake.org/t/externalproject-add-error-msb1009-project-file-does-not-exist/8893/2 "2023-09-06T12:19:20Z")

</div>

If you use `INSTALL_COMMAND cmake --build <BINARY_DIR> --install ${build_config_arg}`, does that help?

---

<div class="post-metadata">

### Author: ![jaquilio](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jaquilio/32/3789_2.png) [@jaquilio](https://discourse.cmake.org/u/jaquilio)
#### Post date: [September 6, 2023, 4:48pm UTC](https://discourse.cmake.org/t/externalproject-add-error-msb1009-project-file-does-not-exist/8893/3 "2023-09-06T16:48:37Z")

</div>

When I add the exact line you suggested, I get the error “Unknown argument --install”.

---

<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: [September 6, 2023, 8:23pm UTC](https://discourse.cmake.org/t/externalproject-add-error-msb1009-project-file-does-not-exist/8893/4 "2023-09-06T20:23:58Z")

</div>

Oh, try `cmake --install <BINARY_DIR>` instead.

---

<div class="post-metadata">

### Author: ![jaquilio](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jaquilio/32/3789_2.png) [@jaquilio](https://discourse.cmake.org/u/jaquilio)
#### Post date: [September 6, 2023, 8:49pm UTC](https://discourse.cmake.org/t/externalproject-add-error-msb1009-project-file-does-not-exist/8893/5 "2023-09-06T20:49:16Z")

</div>

I added “INSTALL\_COMMAND cmake --install \<BINARY\_DIR\>” within the ExternalProject\_Add and that built without errors.

(1) Can you please explain why this results in no errors while earlier without it, the error I originally reported was getting triggered? I would like to understand this clearly so I can debug and fix issues like this in future.  
(2) In the output window, I see the following. I am building the debug configuration, but, the line there says _Install configuration: “Release”_

```auto
  QPOISSON_RECON_LIB.vcxproj -> C:\qlabRoot\build\External\poissonRecon\poissonRecon\Debug\QPOISSON_RECON_LIB.lib
Performing install step for 'poissonRecon'
-- Install configuration: "Release"

```

Thanks!

---

<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: [September 6, 2023, 9:35pm UTC](https://discourse.cmake.org/t/externalproject-add-error-msb1009-project-file-does-not-exist/8893/6 "2023-09-06T21:35:31Z")

</div>

My guess is that the `BINARY_DIR` setting with a genex is confusing things. This is probably worth [an issue](https://gitlab.kitware.com/cmake/cmake/-/issues) with a minimal reproducer to update docs or the implementation, depending on the root cause.

Cc: @craig.scott

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [September 6, 2023, 9:50pm UTC](https://discourse.cmake.org/t/externalproject-add-error-msb1009-project-file-does-not-exist/8893/7 "2023-09-06T21:50:02Z")

</div>

The `INSTALL_DIR` option is not the most intuitive. It does NOT control where things are installed. All it does is provide a value for the `<INSTALL_DIR>` placeholder. It is up to the project to provide an `INSTALL_COMMAND` if they want to install to anywhere other than the default location.

I’ve often found this behavior to be really unintuitive. It would be nice to eventually make `INSTALL_DIR` affect where things get installed if the `INSTALL_COMMAND` isn’t given, but I suspect there are difficulties with the implementation of that. I don’t have the bandwidth to pursue this one, but if someone wants to investigate and put up a merge request, I’ll make time to review it.

---

<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: [September 6, 2023, 10:23pm UTC](https://discourse.cmake.org/t/externalproject-add-error-msb1009-project-file-does-not-exist/8893/8 "2023-09-06T22:23:25Z")

</div>

I don’t think `INSTALL_DIR` is relevant here as it seems to be the working directory of the command which is confused (based on the “no such `.*proj` file” error at least). That’s why I think a minimal reproducer would be good to have here (this starts off really close to one; I think a “dummy” project may be more suitable though).

---

<div class="post-metadata">

### Author: ![jaquilio](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jaquilio/32/3789_2.png) [@jaquilio](https://discourse.cmake.org/u/jaquilio)
#### Post date: [September 6, 2023, 11:44pm UTC](https://discourse.cmake.org/t/externalproject-add-error-msb1009-project-file-does-not-exist/8893/10 "2023-09-06T23:44:02Z")

</div>

To create a minimal reproducer, I just placed the CMakeLists.txt I had posted in my original post above in a separate folder to make it a stand-alone file. With that I still get an error, though the error now is **error : unknown target ‘install’**

I am pasting below the CMakeLists.txt again as a minimal reproducer example. I am building this on a Windows 11 machine using the latest version (17.7.3) of Microsoft Visual Studio 2022 Community Edition.

```auto
cmake_minimum_required(VERSION 3.24)
project(poissonRecon)

include(ExternalProject)

get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (NOT isMultiConfig)
  if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE
        Debug
        CACHE STRING "" FORCE)
  endif ()
  set(build_type_dir ${CMAKE_BUILD_TYPE})
  set(build_type_arg -DCMAKE_BUILD_TYPE=$<CONFIG>)
else ()
  set(build_config_arg --config=$<CONFIG>)
endif ()

message("poissonRecon: CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message("poissonRecon: CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message("poissonRecon: CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}")
ExternalProject_Add(
  poissonRecon
  GIT_REPOSITORY https://github.com/CloudCompare/PoissonRecon.git
  GIT_TAG 85c010229a1c5f2e186488290c2f93fec7da4ad5 

  BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/poissonRecon/${build_type_dir}
  INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/poissonRecon/${CMAKE_BUILD_TYPE}
  CMAKE_COMMAND ${CMAKE_COMMAND}
  CMAKE_ARGS ${build_type_arg} -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>

  BUILD_COMMAND cmake --build <BINARY_DIR> ${build_config_arg}
)

```

---

<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: [September 13, 2023, 1:18am UTC](https://discourse.cmake.org/t/externalproject-add-error-msb1009-project-file-does-not-exist/8893/11 "2023-09-13T01:18:30Z")

</div>

Thanks.

> [@jaquilio](#):
>
> error : unknown target ‘install’

An `install(FILES)` or something in the example project should resolve that at least.
