Cycles: svn merge -r39870:r40266 https://svn.blender.org/svnroot/bf-blender/trunk...
[blender-staging.git] / intern / cycles / util / util_cuda.cpp
index 15ce7efd9eeb970f21af8c8a59d52852a18bfa3b..14e3f9a159bd2e49abc4a5602af623e418861e68 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#include <stdlib.h>
+
 #include "util_cuda.h"
 #include "util_debug.h"
 #include "util_dynlib.h"
+#include "util_path.h"
+#include "util_string.h"
 
 /* function defininitions */
 
@@ -369,11 +373,38 @@ bool cuLibraryInit()
        /* cuda 4.0 */
        CUDA_LIBRARY_FIND(cuCtxSetCurrent);
 
+#ifndef WITH_CUDA_BINARIES
+       if(cuCompilerPath() == "")
+               return false;
+#endif
+
        /* success */
        result = true;
 
        return result;
 }
 
+string cuCompilerPath()
+{
+#ifdef _WIN32
+       const char *defaultpath = "C:/CUDA/bin";
+       const char *executable = "nvcc.exe";
+#else
+       const char *defaultpath = "/usr/local/cuda/bin";
+       const char *executable = "nvcc";
+#endif
+
+       const char *binpath = getenv("CUDA_BIN_PATH");
+
+       string nvcc;
+
+       if(binpath)
+               nvcc = path_join(binpath, executable);
+       else
+               nvcc = path_join(defaultpath, executable);
+
+       return (path_exists(nvcc))? nvcc: "";
+}
+
 CCL_NAMESPACE_END