0

I am an absolute noob when it comes to CMake and have been stuck on this problem for the last three days. The OptiX application I am working on reads in a .ptx file compiled from a .cu file. I am struggling to get the file to be compiled into the same directory as the .exe is.

I didn't set up the CMake file so I am trying to adapt the SDK examples. The .exe get's compiled into bin/release/ or bin/debug without a problem.

I want the .ptx to be compiled to bin/release/ptx or bin/debug/ptx depending on the build mode in VS. Is there a variable which lets me access the bin/release bin/debug paths? Best I could do is ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} which get's me the bin/ folder. (If it helps, a pastebin of the root CMakeLists.txt, line 252:

set(SAMPLES_PTX_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}")

Thank you for help, I hope I could make myself clear enough!

brgalo
  • 37
  • 5
  • 1
    Does this answer your question? [How to copy DLL files into the same folder as the executable using CMake?](https://stackoverflow.com/questions/10671916/how-to-copy-dll-files-into-the-same-folder-as-the-executable-using-cmake) I think the some of the responses here apply directly to your situation. Specifically, you can use the generator expression `$/ptx`. – Kevin Jun 02 '20 at 12:42
  • For me just a ${???} pointing to default output directory of VS would do the trick. I don't know if there exists such a command. I tried some of the solutions, but can't get the file in the correct directory. – brgalo Jun 02 '20 at 14:08
  • 1
    That's essentially what `$` will do. It points to the directory containing your built `YourTarget` target, which will change depending on your VS Configuration (Debug or Release). – Kevin Jun 02 '20 at 14:10
  • 1
    Wow thank you so much! I ended up using this [thread](https://stackoverflow.com/questions/13429656/how-to-copy-contents-of-a-directory-into-build-directory-after-make-with-cmake) – brgalo Jun 02 '20 at 14:42

0 Answers0