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

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 ..

if I run it from there, I get

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.

so I had to go up one level, which is normal for cmake?

Actually I thought it was hanging, pressed ctrl-C and got

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$

Your first code snippet contains the expected ..:

root@fa350df05ecf:/home/build# cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch ..

while the second one doesn’t:

nobu@LAPTOP-DNCQ5AAC:/mnt/d/computervision/dcgan/build$ cmake -DCMAKE_PREFIX_PATH=/mnt/d/computervision/libtorch
CMake Warning:
...

Why did you drop it?

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.

You can refer to any example, such as this one, which shows the usage as:

mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch ..
cmake --build . --config Release
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
...