Skip to content

NVCC Compiler for CUDA not working as expected #1722

@mobereng

Description

@mobereng

Describe your question

Hi, I'm currently using some CUDA functionalities along my LibIGL project, I spend a few days stuck on compilations issues thinking that it was related to my compiler, but then I try the same compilation but without libigl included on the cmake file, and it worked. I'm guessing some c++ important options used by nvcc are removed once LibIGL library is added, but I'm not sure what's happening, or how to solve it.

Here you can see the error reported, which as I said, this does not happen when I compile without LibIGL

image

CmakeList is the following

cmake_minimum_required(VERSION 3.19.2)
project(CudaTest LANGUAGES CXX)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# LIBIGL PACKAGE
option(LIBIGL_WITH_OPENGL              "Use OpenGL"         ON)
option(LIBIGL_WITH_OPENGL_GLFW         "Use GLFW"           ON)
option(LIBIGL_WITH_OPENGL_GLFW_IMGUI   "Use ImGui"          ON)
find_package(LIBIGL REQUIRED QUIET)

# BOOST PACKAGE
find_package(Boost 1.75.0 REQUIRED COMPONENTS program_options filesystem serialization unit_test_framework)

# CUDA PACKAGE
find_package(CUDA)
add_compile_definitions(CUDA_CAPABLE=${CUDA_FOUND})
if (CUDA_FOUND)
  enable_language(CUDA)
endif()

# OPENMP PACKAGE
find_package(OpenMP)
if (OPENMP_FOUND)
  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

# Add your project files
file(GLOB_RECURSE SRCFILES src/*.cpp src/*.hpp)
if (CUDA_FOUND)
  file(GLOB_RECURSE CU_SRCFILES src/*.cu)
  add_executable(${PROJECT_NAME} ${CU_SRCFILES} ${SRCFILES})
else()
  add_executable(${PROJECT_NAME} ${SRCFILES})
endif()

# Include
target_include_directories(${PROJECT_NAME} PRIVATE ${Boost_INCLUDE_DIRS} tools/include/)
if (CUDA_FOUND)
  target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
endif()

# Linker
target_link_libraries(${PROJECT_NAME} igl::core igl::opengl igl::opengl_glfw igl::opengl_glfw_imgui ${Boost_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_SERIALIZATION_LIBRARY} Boost::program_options Boost::filesystem Boost::serialization Boost::unit_test_framework)
if (CUDA_FOUND)
  target_link_libraries(${PROJECT_NAME} ${CUDA_LIBRARIES} ${CUDA_cusparse_LIBRARY} ${CUDA_cusolver_LIBRARY})
endif()

...

Check all that apply (change to [x])

  • Windows
  • macOS
  • Linux

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions