File tree Expand file tree Collapse file tree 4 files changed +27
-18
lines changed Expand file tree Collapse file tree 4 files changed +27
-18
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,30 @@ target_compile_features(cuco INTERFACE cxx_std_17 cuda_std_17)
9494option (CUCO_DOWNLOAD_ROARING_TESTDATA "Download RoaringFormatSpec test data" ON )
9595include (${CMAKE_CURRENT_LIST_DIR} /cmake/roaring_testdata.cmake)
9696
97+ ###################################################################################################
98+ # - common compile options function ---------------------------------------------------------------
99+
100+ function (cuco_set_common_compile_options target_name)
101+ # Parse optional arguments
102+ cmake_parse_arguments (CUCO_OPTS "ADD_LINEINFO" "" "" ${ARGN} )
103+
104+ # Base compile options common to all targets
105+ target_compile_options (${target_name} PRIVATE
106+ --compiler-options =-Wall --compiler-options =-Wextra --compiler-options =-Werror
107+ -Wno-deprecated-gpu-targets --expt-extended-lambda -Werror=all -warnings
108+ )
109+
110+ # Add lineinfo option if requested (typically for benchmarks)
111+ if (CUCO_OPTS_ADD_LINEINFO)
112+ target_compile_options (${target_name} PRIVATE -lineinfo)
113+ endif ()
114+
115+ # Add GCC-specific warning suppression only for GCC
116+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
117+ target_compile_options (${target_name} PRIVATE -Xcompiler -Wno-subobject-linkage)
118+ endif ()
119+ endfunction ()
120+
97121###################################################################################################
98122# - optionally build tests ------------------------------------------------------------------------
99123
Original file line number Diff line number Diff line change @@ -27,12 +27,7 @@ function(ConfigureBench BENCH_NAME)
2727 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /benchmarks" )
2828 target_include_directories (${BENCH_NAME} PRIVATE
2929 "${CMAKE_CURRENT_SOURCE_DIR} " )
30- target_compile_options (${BENCH_NAME} PRIVATE --compiler-options =-Wall --compiler-options =-Wextra
31- --compiler-options =-Werror -Wno-deprecated-gpu-targets --expt-extended-lambda -lineinfo -Xcudafe --promote_warnings)
32- # Add GCC-specific warning suppression only for GCC
33- if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
34- target_compile_options (${BENCH_NAME} PRIVATE -Xcompiler -Wno-subobject-linkage)
35- endif ()
30+ cuco_set_common_compile_options(${BENCH_NAME} ADD_LINEINFO)
3631 target_link_libraries (${BENCH_NAME} PRIVATE
3732 nvbench::main
3833 pthread
Original file line number Diff line number Diff line change @@ -24,12 +24,7 @@ function(ConfigureExample EXAMPLE_NAME EXAMPLE_SRC)
2424 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /examples" )
2525 target_include_directories (${EXAMPLE_NAME} PRIVATE
2626 "${CMAKE_CURRENT_SOURCE_DIR} " )
27- target_compile_options (${EXAMPLE_NAME} PRIVATE --compiler-options =-Wall --compiler-options =-Wextra
28- --compiler-options =-Werror -Wno-deprecated-gpu-targets --expt-extended-lambda -Xcudafe --promote_warnings)
29- # Add GCC-specific warning suppression only for GCC
30- if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
31- target_compile_options (${EXAMPLE_NAME} PRIVATE -Xcompiler -Wno-subobject-linkage)
32- endif ()
27+ cuco_set_common_compile_options(${EXAMPLE_NAME} )
3328 target_link_libraries (${EXAMPLE_NAME} PRIVATE cuco CUDA::cudart)
3429endfunction (ConfigureExample)
3530
Original file line number Diff line number Diff line change @@ -38,12 +38,7 @@ function(ConfigureTest TEST_NAME)
3838 target_include_directories (${TEST_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} )
3939 set_target_properties (${TEST_NAME} PROPERTIES
4040 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /tests" )
41- target_compile_options (${TEST_NAME} PRIVATE --compiler-options =-Wall --compiler-options =-Wextra
42- --compiler-options =-Werror -Wno-deprecated-gpu-targets --expt-extended-lambda -Xcudafe --promote_warnings)
43- # Add GCC-specific warning suppression only for GCC
44- if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
45- target_compile_options (${TEST_NAME} PRIVATE -Xcompiler -Wno-subobject-linkage)
46- endif ()
41+ cuco_set_common_compile_options(${TEST_NAME} )
4742 catch_discover_tests(${TEST_NAME} EXTRA_ARGS --allow-running-no -tests)
4843endfunction (ConfigureTest)
4944
You can’t perform that action at this time.
0 commit comments