Skip to content

Commit 2199b0e

Browse files
committed
refactor; use COMPILE_OPTIONS property
1 parent afb5cf5 commit 2199b0e

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

libclc/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,28 @@ if ( clspv-- IN_LIST LIBCLC_TARGETS_TO_BUILD OR clspv64-- IN_LIST LIBCLC_TARGETS
262262
set_target_properties( generate-clspv-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" )
263263
endif()
264264

265+
set_source_files_properties(
266+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_cos.cl
267+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_divide.cl
268+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp.cl
269+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp10.cl
270+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_exp2.cl
271+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log10.cl
272+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log2.cl
273+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_log.cl
274+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_powr.cl
275+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_recip.cl
276+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_rsqrt.cl
277+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sin.cl
278+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_sqrt.cl
279+
${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_tan.cl
280+
${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_exp.cl
281+
${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_log10.cl
282+
${CMAKE_CURRENT_SOURCE_DIR}/amdgpu/lib/math/native_log.cl
283+
${CMAKE_CURRENT_SOURCE_DIR}/r600/lib/math/native_rsqrt.cl
284+
PROPERTIES COMPILE_OPTIONS -fapprox-func
285+
)
286+
265287
enable_testing()
266288

267289
foreach( t ${LIBCLC_TARGETS_TO_BUILD} )

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,19 +262,17 @@ function(add_libclc_builtin_set)
262262
get_filename_component( file_dir ${file} DIRECTORY )
263263
get_filename_component( input_filename ${file} NAME_WE )
264264

265-
# If this is a 'native' function (as judged by its filename beginning with
266-
# "(clc_)?native_") then pass extra args.
267-
set( native_flag )
268-
string( REGEX MATCH "^(clc_)?native_" is_native "${input_filename}" )
269-
if( NOT "${is_native}" STREQUAL "" )
270-
set( native_flag -fapprox-func )
265+
set( file_specific_compile_options )
266+
get_source_file_property( compile_opts ${file} COMPILE_OPTIONS)
267+
if( compile_opts )
268+
set( file_specific_compile_options "${compile_opts}" )
271269
endif()
272270

273271
compile_to_bc(
274272
TRIPLE ${ARG_TRIPLE}
275273
INPUT ${input_file}
276274
OUTPUT ${output_file}
277-
EXTRA_OPTS -fno-builtin -nostdlib ${native_flag}
275+
EXTRA_OPTS -fno-builtin -nostdlib "${file_specific_compile_options}"
278276
"${ARG_COMPILE_FLAGS}" -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir}
279277
DEPENDENCIES ${input_file_dep}
280278
)

0 commit comments

Comments
 (0)