diff --git a/clang/test/dpct/cmake_migration/case_042/case_042_set_source_files_properties.cpp b/clang/test/dpct/cmake_migration/case_042/case_042_set_source_files_properties.cpp new file mode 100644 index 000000000000..a62d747147a8 --- /dev/null +++ b/clang/test/dpct/cmake_migration/case_042/case_042_set_source_files_properties.cpp @@ -0,0 +1,10 @@ +// RUN: rm -rf %T && mkdir -p %T +// RUN: cd %T +// RUN: cp %S/input.cmake ./input.cmake +// RUN: dpct -in-root ./ -out-root out ./input.cmake --migrate-build-script-only +// RUN: echo "begin" > %T/diff.txt +// RUN: diff --strip-trailing-cr %S/expected.txt %T/out/input.cmake >> %T/diff.txt +// RUN: echo "end" >> %T/diff.txt + +// CHECK: begin +// CHECK-NEXT: end diff --git a/clang/test/dpct/cmake_migration/case_042/expected.txt b/clang/test/dpct/cmake_migration/case_042/expected.txt new file mode 100644 index 000000000000..4be9bb800d44 --- /dev/null +++ b/clang/test/dpct/cmake_migration/case_042/expected.txt @@ -0,0 +1,11 @@ +# simplest case +set_source_files_properties(${src_files} PROPERTIES LANGUAGE CXX) + +# add space test +set_source_files_properties(${src_files} PROPERTIES LANGUAGE CXX) + +# with more properties after LANGUAGE +set_source_files_properties(${src_files} PROPERTIES LANGUAGE CXX COMPILE_DEFINITIONS SOME_DEFINE) + +# add properties on right +set_source_files_properties(${src_files} PROPERTIES COMPILE_FLAGS "--some-flag" LANGUAGE CXX COMPILE_DEFINITIONS) diff --git a/clang/test/dpct/cmake_migration/case_042/input.cmake b/clang/test/dpct/cmake_migration/case_042/input.cmake new file mode 100644 index 000000000000..80f19a1fc1e5 --- /dev/null +++ b/clang/test/dpct/cmake_migration/case_042/input.cmake @@ -0,0 +1,11 @@ +# simplest case +set_source_files_properties(${src_files} PROPERTIES LANGUAGE CUDA) + +# add space test +set_source_files_properties (${src_files} PROPERTIES LANGUAGE CUDA) + +# with more properties after LANGUAGE +set_source_files_properties(${src_files} PROPERTIES LANGUAGE CUDA COMPILE_DEFINITIONS SOME_DEFINE) + +# add properties on right +set_source_files_properties(${src_files} PROPERTIES COMPILE_FLAGS "--some-flag" LANGUAGE CUDA COMPILE_DEFINITIONS) diff --git a/clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml b/clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml index b4bbb7e13d1f..e40f4f396076 100644 --- a/clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml +++ b/clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml @@ -2241,3 +2241,10 @@ Out: ONEAPI_LIB_DIR MatchMode: Full RuleId: "replace_cuda_toolkit_lib_with_oneapi_lib" + +- Rule: rule_set_source_files_properties + Kind: CMakeRule + Priority: Fallback + CmakeSyntax: set_source_files_properties_lang + In: set_source_files_properties${empty}(${src_files} PROPERTIES${some_other_prop}LANGUAGE CUDA${other_props}) + Out: set_source_files_properties(${src_files} PROPERTIES${some_other_prop}LANGUAGE CXX${other_props})