Don't we run the cmake command from outside the build folder?

Nobutaka_Kim: <pre><code class="lang-auto">dcgan/
  CMakeLists.txt
  dcgan.cpp

Further, I will refer to the path to the unzipped LibTorch distribution as /path/to/libtorch. Note that this must be an absolute path. In particular, setting CMAKE_PREFIX_PATH to something like ../../libtorch will break in unexpected ways. Instead, write $PWD/../../libtorch to get the corresponding absolute path. Now, we are ready to build our application:

root@fa350df05ecf:/home# mkdir build
root@fa350df05ecf:/home# cd build
root@fa350df05ecf:/home/build# cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch ..
</code></pre>
<p>if I run it from there, I get</p>
<pre><code class="lang-auto">nobu@LAPTOP-DNCQ5AAC:/mnt/d/computervision/dcgan/build$ cmake -DCMAKE_PREFIX_PATH=/mnt/d/computervision/libtorch
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.


CMake Error: The source directory "/mnt/d/computervision/dcgan/build" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
</code></pre>
<p>so I had to go up one level, which is normal for cmake?</p>
<p>Actually I thought it was hanging, pressed ctrl-C and got</p>
<pre><code class="lang-auto">nobu@LAPTOP-DNCQ5AAC:/mnt/d/computervision/dcgan$ cmake -DCMAKE_PREFIX_PATH=/mnt/d/computervision/libtorch
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.


-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Torch: /mnt/d/computervision/libtorch/lib/libtorch.so
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/d/computervision/dcgan
nobu@LAPTOP-DNCQ5AAC:/mnt/d/computervision/dcgan$ ^C
nobu@LAPTOP-DNCQ5AAC:/mnt/d/computervision/dcgan$ ^C
nobu@LAPTOP-DNCQ5AAC:/mnt/d/computervision/dcgan$ ls
CMakeCache.txt  CMakeFiles  CMakeLists.txt  Makefile  build  cmake_install.cmake  dcgan.cpp
nobu@LAPTOP-DNCQ5AAC:/mnt/d/computervision/dcgan$ cd build
nobu@LAPTOP-DNCQ5AAC:/mnt/d/computervision/dcgan/build$ ls
nobu@LAPTOP-DNCQ5AAC:/mnt/d/computervision/dcgan/build$
</code></pre>

ptrblck: <p>Your first code snippet contains the expected <code>..</code>:</p>
<pre><code class="lang-auto">root@fa350df05ecf:/home/build# cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch ..
</code></pre>
<p>while the second one doesn’t:</p>
<pre><code class="lang-auto">nobu@LAPTOP-DNCQ5AAC:/mnt/d/computervision/dcgan/build$ cmake -DCMAKE_PREFIX_PATH=/mnt/d/computervision/libtorch
CMake Warning:
...
</code></pre>
<p>Why did you drop it?</p>

Nobutaka_Kim: <p>Thanks, I mixed up example app and dcgan and I vaguely recall now needing “…” after the command for going up a directory?  I’ll look it up.</p>

ptrblck: <p>You can refer to any example, such as <a href="https://pytorch.org/tutorials/advanced/cpp_export.html#depending-on-libtorch-and-building-the-application">this one</a>, which shows the usage as:</p>
<pre><code class="lang-auto">mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch ..
cmake --build . --config Release
</code></pre>
<pre><code class="lang-auto">root@4b5a67132e81:/example-app# mkdir build
root@4b5a67132e81:/example-app# cd build
root@4b5a67132e81:/example-app/build# cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
...
</code></pre>