Skip to content

Commit ea2b855

Browse files
committed
build: Propagate cpp version (#1797)
OIIO recently pushed its master to be C++17 minimum. When using a C++17-minimum OIIO, you need to build OSL with C++17 as well. This broke a couple CI cases for OSL. There were a few spots where we were hard-coded to C++14 on the OSL side rather than even using the C++ version specified for the OSL build, so these are some fixes here to address this. Signed-off-by: Larry Gritz <[email protected]>
1 parent c294cdd commit ea2b855

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/cmake/cuda_macros.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ function ( NVCC_COMPILE cuda_src extra_headers ptx_generated extra_nvcc_args )
5151
${LLVM_COMPILE_FLAGS}
5252
-DOSL_USE_FAST_MATH=1
5353
-m64 -arch ${CUDA_TARGET_ARCH} -ptx
54-
--std=c++14 -dc --use_fast_math ${CUDA_OPT_FLAG_NVCC} ${NVCC_FTZ_FLAG} --expt-relaxed-constexpr
54+
--std=c++${CMAKE_CXX_STANDARD}
55+
-dc --use_fast_math ${CUDA_OPT_FLAG_NVCC} ${NVCC_FTZ_FLAG}
56+
--expt-relaxed-constexpr
5557
${extra_nvcc_args}
5658
${OSL_EXTRA_NVCC_ARGS}
5759
${cuda_src} -o ${cuda_ptx}

testsuite/example-cuda/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ find_library(CUDA_cuda_LIBRARY cuda HINTS ${CUDA_TOOLKIT_ROOT_DIR} PATH_SUFFIXES
3838
# TODO: move to sm_60?
3939
set(CUDA_TARGET_ARCH sm_35)
4040

41+
set (CMAKE_CXX_STANDARD 14 CACHE STRING
42+
"C++ standard to build with (14, 17, 20, etc.)")
43+
4144
# Compile our "renderer" to PTX
4245
cuda_compile_ptx(CUDA_PTX_FILES cuda_grid_renderer.cu
43-
OPTIONS --gpu-architecture=${CUDA_TARGET_ARCH} --use_fast_math -dc --std=c++14
46+
OPTIONS --gpu-architecture=${CUDA_TARGET_ARCH} --use_fast_math -dc
47+
--std=c++${CMAKE_CXX_STANDARD}
4448
--expt-relaxed-constexpr
4549
-I${OSL_INCLUDES}
4650
-I${IMATH_INCLUDES}
@@ -58,7 +62,8 @@ add_custom_target(cuda_grid_renderer_ptx ALL
5862

5963
# Compile the rend_lib shadeops to PTX
6064
cuda_compile_ptx(CUDA_PTX_FILES rend_lib.cu
61-
OPTIONS --gpu-architecture=${CUDA_TARGET_ARCH} --use_fast_math -dc --std=c++14
65+
OPTIONS --gpu-architecture=${CUDA_TARGET_ARCH} --use_fast_math -dc
66+
--std=c++${CMAKE_CXX_STANDARD}
6267
--expt-relaxed-constexpr
6368
-I${OSL_INCLUDES}
6469
-I${IMATH_INCLUDES}

testsuite/example-cuda/example-cuda.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ register_closures(ShadingSystem& ss)
337337

338338
const char* cuda_compile_options[] = { "--gpu-architecture=compute_35",
339339
"--use_fast_math", "-dc",
340-
"--std=c++11" };
340+
"--std=c++" #OSL_CPLUSPLUS_VERSION };
341341

342342
std::string
343343
build_trampoline_ptx(OSL::ShaderGroup& group, std::string init_name,

0 commit comments

Comments
 (0)