Skip to content

Commit

Permalink
Merge pull request #2 from MrNeRF/ubuntu-build-fix
Browse files Browse the repository at this point in the history
Ubuntu build fix
  • Loading branch information
m-schuetz authored Nov 30, 2023
2 parents a884ac5 + 802bbd0 commit de23f1c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 13 deletions.
23 changes: 17 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.26)
cmake_minimum_required(VERSION 3.22)
project(SimLOD)

include(FetchContent)
Expand All @@ -19,7 +19,19 @@ set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT $
set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "$<TARGET_FILE_DIR:${PROJECT_NAME}>"
VS_DEBUGGER_COMMAND "$<TARGET_FILE:${PROJECT_NAME}>"
VS_DEBUGGER_ENVIRONMENT "PATH=%PATH%;${CMAKE_PREFIX_PATH}")

# Build options based on CMAKE_BUILD_TYPE
function(configure_build_type)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(${PROJECT_NAME} PRIVATE -O0 -g)
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_options(${PROJECT_NAME} PRIVATE -O3)
else()
message(WARNING "No CMAKE_BUILD_TYPE specified, defaulting to Release settings.")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build type: Release" FORCE)
target_compile_options(${PROJECT_NAME} PRIVATE -O3)
endif ()
endfunction()
configure_build_type()

target_include_directories(${PROJECT_NAME} PRIVATE
include
Expand All @@ -29,14 +41,13 @@ target_include_directories(${PROJECT_NAME} PRIVATE
# Dependencies

## CUDA toolkit
find_package(CUDAToolkit 11.7 REQUIRED)
find_package(CUDAToolkit 11.8 REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE
CUDAToolkit_INCLUDE_DIRS)

target_link_libraries(${PROJECT_NAME}
CUDA::cuda_driver
CUDA::nvrtc
CUDA::nvrtc_static
CUDA::nvrtc_builtins_static)
CUDA::nvrtc)

## OpenGL
find_package(OpenGL REQUIRED)
Expand Down
28 changes: 21 additions & 7 deletions include/CudaModularProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,32 @@ struct CudaModule{
// cout << "================================================================================" << endl;
printfmt("compiling {} ", fs::path(path).filename().string());

success = false;

string dir = fs::path(path).parent_path().string();
string optInclude = "-I " + dir;
const char* cuda_path_cstr = std::getenv("CUDA_PATH");
std::string cuda_path;
if (cuda_path_cstr) {
cuda_path = std::string(cuda_path_cstr);
if (!cuda_path.empty()) {
std::cout << "\nCUDA_PATH is set to: " << cuda_path << std::endl;
} else {
std::cout << "\nCUDA_PATH is empty. Please set it." << std::endl;
exit(-1);
}
} else {
std::cout << "\nCUDA_PATH is not set. Please set it." << std::endl;
exit(-1);
}

string cuda_path = std::getenv("CUDA_PATH");
string cuda_include = "-I " + cuda_path + "/include";
const string cuda_include = "-I " + cuda_path + "/include";
const string dir = fs::path(path).parent_path().string();
const string optInclude = "-I " + dir;

nvrtcProgram prog;
string source = readFile(path);
nvrtcCreateProgram(&prog, source.c_str(), name.c_str(), 0, NULL, NULL);
std::vector<const char*> opts = {

success = false;

std::vector<const char*> opts = {
// "--gpu-architecture=compute_75",
"--gpu-architecture=compute_86",
"--use_fast_math",
Expand Down

0 comments on commit de23f1c

Please sign in to comment.