Skip to content

Commit 44f9e33

Browse files
committed
cmake: Build CUDA 6.5 object without C++11
CUDA 7.0 is the first version that supports C++11. Though linking C++11 objects with non-C++11 ones is problematic.
1 parent 6fad1fa commit 44f9e33

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,16 @@ IF(ENABLE_CUDA)
342342
IF(NOT MSVC)
343343
SET(CUDA_FLAGS "${CUDA_FLAGS} -Xcompiler -fPIC")
344344
ENDIF()
345+
346+
SET(OLD_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
347+
IF(CUDA_VERION VERSION_LESS 7.0)
348+
STRING(REGEX REPLACE "-std=c\\+\\+.." "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
349+
ENDIF()
345350
CUDA_COMPILE(CUDA_OBJECTS
346351
src/cuda_depth_packet_processor.cu
347352
OPTIONS ${CUDA_FLAGS}
348353
)
354+
SET(CMAKE_CXX_FLAGS "${OLD_CMAKE_CXX_FLAGS}")
349355

350356
INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})
351357

src/cuda_depth_packet_processor.cu

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ __constant__ static float MAX_DEPTH;
8585
#define max(x, y) fmaxf(x, y)
8686
#define min(x, y) fminf(x, y)
8787
#define M_PI_F CUDART_PI_F
88+
#ifndef M_PI
89+
#define M_PI CUDART_PI
90+
#endif
8891

8992
typedef unsigned char uchar;
9093

0 commit comments

Comments
 (0)