diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index ca3f13037416d..6e0d1f93c06de 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -24,6 +24,24 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) # Common compilation step setup + check_cxx_compiler_flag(-Winstantiation-after-specialization + HAS_INST_AFTER_SPEC) + + target_compile_options( + ${LIB_OBJ_NAME} + PRIVATE + ${ARG_COMPILE_OPTIONS} + $<$:-Winstantiation-after-specialization> + PUBLIC + $<$>:-fvisibility=hidden -fvisibility-inlines-hidden> + # Sycl math built-in macros cause a GCC 4.6 'note' to be output + # repeatedly. + # => note: the ABI for passing parameters with 32-byte alignment has + # changed in GCC 4.6 + # Seems to be no way to suppress it except use -Wno-psabi + $<$>:-Wno-psabi> + ) + target_compile_definitions( ${LIB_OBJ_NAME} PRIVATE @@ -107,10 +125,6 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) ) endif() - if (ARG_COMPILE_OPTIONS) - target_compile_options(${LIB_OBJ_NAME} PRIVATE ${ARG_COMPILE_OPTIONS}) - endif() - add_dependencies(${LIB_OBJ_NAME} sycl-headers ) @@ -162,14 +176,6 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) # Install stripped PDB add_stripped_pdb(${LIB_NAME}) else() - target_compile_options(${LIB_OBJ_NAME} PUBLIC - -fvisibility=hidden -fvisibility-inlines-hidden) - - # Sycl math built-in macros cause a GCC 4.6 'note' to be output repeatedly. - # => note: the ABI for passing parameters with 32-byte alignment has changed in GCC 4.6 - # Seems to be no way to suppress it except use -Wno-psabi - target_compile_options(${LIB_OBJ_NAME} PUBLIC -Wno-psabi) - if (UNIX AND NOT APPLE) set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/ld-version-script.txt") target_link_libraries( @@ -203,13 +209,6 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) VERSION ${SYCL_VERSION_STRING} SOVERSION ${SYCL_MAJOR_VERSION}) - check_cxx_compiler_flag(-Winstantiation-after-specialization - HAS_INST_AFTER_SPEC) - if (HAS_INST_AFTER_SPEC) - target_compile_options(${LIB_OBJ_NAME} PRIVATE - -Winstantiation-after-specialization) - endif() - # When building using icx on Windows, the VERSION file # produced by cmake is used in source code # when including '' because Windows is