I need Old fashion of Makefile.txt (as for OptiX 3.9) for OptiX 6.5

Dear All!
I faced a problem and hope that you could help me.
Some history.
I began in 2014 with Optix 3.5, then … Optix 3.9. It was enough for me. Recently I changed GPU Geforce (to GTX 1060) and installed Optix 6.5.
It happens that Win VC 2013 builds MyProject in different manner than it was for OptiX 3.9. For example, the directory “MyProject\build\lib\ptx” is absent. And files like “MyProject_generated_bi_ferrari.cu.ptx” are absent too.

I don’t know how to program CMake and used it as is: as it was suggested for SDK samples in OptiX 3.9.
Now in OptiX 6.5. I would like to have the Makefile similar to that of Optix 3.9.
Probably, necessary information exists in the Forum but I have not find it.
MyProjects include from 20 to 40 .cu files and I think that it is more safety to use .ptx instead of .cu.

Thank you!
Sudak

I’m not using the OptiX SDK examples framework in my own examples, but also have a CMake environment which makes it pretty simple to create new examples based on an existing one.
It’s worth trying it when targeting multiple compilers or OSes.

Find links to examples here.
https://devtalk.nvidia.com/default/topic/998546/optix/optix-advanced-samples-on-github/

The original OptiX Advanced Examples linked there are coded against OptiX 5.1.0 and also work with OptiX 6.5.0 but don’t make use of the RTX hardware triangle intersection.
(The FindCUDA.cmake in there is outdated. Set your CUDA_HOST_COMPILER CMake variable manually when using MSVS 2017 or newer.)

The framework in those examples is the same as in the OptiX SDK 6.5.0 and earlier. Means there are hard-coded paths to the examples source and data inside the executable which require environment values to let them run in any other location and the *.ptx files land all in one common folder which requires unique names. (I’m not using that framework because of that.)

Let’s explain the mechanism for the https://github.com/NVIDIA/OptiX_Apps
You copy one example folder, change its name in all files (.h;.cpp;.cu;.txt), add that sub-folder to the CMakeLists.txt in “apps”, generate the solution, build it, and have a copy of the example under a different name.
Then change the source, header, and CUDA files, and third party libraries as needed in the new example’s CMakeLists.txt and program what you want.
(The 3rdparty.cmake and FindASSIMP.cmake in there are not prepared to handle MSVS 2013 though, only MSVS 2015 and above, but that’d be simple to add. Updating MSVS would be more recommended.)

The translation of *.cu files to *.ptx is done via custom build rules generated with this CMake macro.
https://github.com/NVIDIA/OptiX_Apps/blob/master/3rdparty/CMake/nvcuda_compile_ptx.cmake
Search for NVCUDA_COMPILE_PTX in the CMakeLists.txt how it’s used.

I’m not using versions before OptiX 7 anymore, but here’s a FindOptiX.cmake which you can simply plug into the existing examples and have OptiX 6.5 and OptiX 7.0 examples in the same solution with a few changes. (find_package(OptiX7 REQUIRED) => find_package(OptiX REQUIRED) and OPTIX7_INCLUDE_DIR to OPTIX_INCLUDE_DIR).
(Not on the existing examples there though because OptiX 7 has a completely different host and device API than earlier OptiX versions.)

Looks like this:
(Compare to https://github.com/NVIDIA/OptiX_Apps/blob/master/3rdparty/CMake/FindOptiX7.cmake)

# OPTIX_PATH

# OPTIX_FOUND
# OPTIX_INCLUDE_DIR
# OPTIX_LIBRARY_DIR
# OPTIX_LIBRARIES

# DAR Note that this script does not include the optixu library 
# because it is not used in any of my OptiX applications.
# The respective parts are commented out below.

set(OPTIX_PATH $ENV{OPTIX_PATH})

if ("${OPTIX_PATH}" STREQUAL "")
  set(OPTIX_PATH "C:/ProgramData/NVIDIA Corporation/OptiX SDK 6.5.0")
endif()

find_path(OPTIX_INCLUDE_DIR optix.h ${OPTIX_PATH}/include)

#if ("${OPTIX_INCLUDE_DIR}" STREQUAL "OPTIX_INCLUDE_DIR-NOTFOUND")
#  set(OPTIX_PATH "C:/sdk/OptiX SDK 6.5.0") # My personal SDK installations default.
#  find_path(OPTIX_INCLUDE_DIR optix.h ${OPTIX_PATH}/include)
#endif()

# OptiX SDKs before 5.1.0 named the library optix.1.lib
# Linux handles this via symlinks and doesn't need changes to the library name.
set(OptiX_version "1")

# The OptiX library is named with the major and minor digits since OptiX 5.1.0.
# Dynamically find the matching library name by parsing the OptiX_INSTALL_DIR.
# This only works if the installation retained the original folder format "OptiX SDK major.minor.micro".
# We want the concatenated major and minor numbers if the version is greater or equal to 5.1.0.
if(WIN32)
  if(OPTIX_PATH)
    string(REPLACE " " ";" OptiX_install_dir_list ${OPTIX_PATH})
    list(LENGTH OptiX_install_dir_list OptiX_install_dir_list_length)
    if(${OptiX_install_dir_list_length} GREATER 0)
      # Get the last list element, something like "5.1.0".
      list(GET OptiX_install_dir_list -1 OptiX_version_string)
      # Component-wise integer version number comparison (version format is major[.minor[.patch[.tweak]]]).
      # Starting with OptiX 6.0.0, the full version number is used to avoid the Windows DLL hell.
      if(${OptiX_version_string} VERSION_GREATER_EQUAL "6.0.0")
        set(OptiX_version ${OptiX_version_string})
      elseif(${OptiX_version_string} VERSION_GREATER_EQUAL "5.1.0")
        set(OptiX_version "")
        string(REPLACE "." ";" OptiX_major_minor_micro_list ${OptiX_version_string})
        foreach(index RANGE 0 1)
          list(GET OptiX_major_minor_micro_list ${index} number)
          string(APPEND OptiX_version ${number})
        endforeach()
      endif()
    endif()
  endif()
endif(WIN32)

message("OptiX_version = " "${OptiX_version}")

find_path( OPTIX_INCLUDE_DIR optix.h ${OPTIX_PATH}/include )
find_library( OPTIX_LIBRARY NAMES optix.${OptiX_version} liboptix PATHS ${OPTIX_PATH}/lib64 )
# find_library( OPTIX_OPTIXU_LIBRARY NAMES optixu.1 liboptixu PATHS ${OPTIX_PATH}/lib64 )

message("OPTIX_INCLUDE_DIR = " "${OPTIX_INCLUDE_DIR}")
message("OPTIX_LIBRARY = " "${OPTIX_LIBRARY}")
# message("OPTIX_OPTIXU_LIBRARY = " "${OPTIX_OPTIXU_LIBRARY}")

get_filename_component( OPTIX_LIBRARY_DIR "${OPTIX_LIBRARY}" PATH CACHE )

# set( OPTIX_INCLUDE_DIRS ${OPTIX_INCLUDE_DIR} )
# set( OPTIX_LIBRARY_DIRS ${OPTIX_LIBRARY_DIR} )
# set( OPTIX_LIBRARIES ${OPTIX_LIBRARY} ${OPTIX_OPTIXU_LIBRARY}  )
set( OPTIX_LIBRARIES ${OPTIX_LIBRARY} )

# message("OPTIX_INCLUDE_DIRS = " "${OPTIX_INCLUDE_DIR}")
# message("OPTIX_LIBRARY_DIRS = " "${OPTIX_LIBRARY}")
message("OPTIX_LIBRARIES = " "${OPTIX_LIBRARIES}")

include(FindPackageHandleStandardArgs)

# find_package_handle_standard_args( OPTIX DEFAULT_MSG
#            OPTIX_LIBRARY OPTIX_OPTIXU_LIBRARY OPTIX_INCLUDE_DIR )
find_package_handle_standard_args( OPTIX DEFAULT_MSG
           OPTIX_LIBRARY OPTIX_INCLUDE_DIR )

# mark_as_advanced( OPTIX_INCLUDE_DIR OPTIX_LIBRARY_DIR OPTIX_LIBRARY OPTIX_OPTIXU_LIBRARY )
mark_as_advanced( OPTIX_INCLUDE_DIR OPTIX_LIBRARY_DIR OPTIX_LIBRARY )

# message("OPTIX_FOUND = " "${OPTIX_FOUND}")

Adding *.cu files and headers with dependencies and generating the custom build rules for each file looks like this (lines 80 - 117):
https://github.com/NVIDIA/OptiX_Apps/blob/master/apps/intro_runtime/CMakeLists.txt#L80
That would need to change the “-I${OPTIX7_INCLUDE_DIR}” to “-I${OPTIX_INCLUDE_DIR}”

That said, I wouldn’t recommend starting with new projects on any version before OptiX 7.0.0. It’s more flexible, multi-threading safe and faster overall.

Dear Detlef,
thank You for fast reply!

I look at GitHub.
It seems I will overcome my problem.

" I wouldn’t recommend starting with new projects on any version before OptiX 7.0.0. It’s more flexible, multi-threading safe and faster overall."
Thank You! I hope no new revolutions with CMake.

Best regards,
Sudak