From 7748976d3e97476455d79edcdcb41d1a50d8a491 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Mon, 9 May 2022 14:59:50 +1000 Subject: [PATCH 01/23] initial commit --- Sonarcloud.cmake | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Sonarcloud.cmake diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake new file mode 100644 index 0000000..1899925 --- /dev/null +++ b/Sonarcloud.cmake @@ -0,0 +1,40 @@ +# +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. +# + +include(SwiftTargets) # expects variable _SWIFT_SOURCE_TARGETS_ to be available +include(TestTargets) # expects variable _SWIFT_TEST_TARGETS_ to be available + +function(generate_sonar_project_properties file_path) + if (NOT ${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) + return() + endif() + + list(LENGTH _SWIFT_TARGET_SOURCE_FILES_ source_files_size) + list(LENGTH _SWIFT_TARGET_TEST_FILES_ test_files_size) + + if (source_files_size EQUAL 0) + message(FATAL_ERROR "There are no registered source files") + endif() + + if (test_files_size EQUAL 0) + message(FATAL_ERROR "There are no registered test files") + endif() + + file(WRITE ${file_path} "sonar.sourceEncoding=UTF-8\n") + + list(JOIN _SWIFT_TARGET_SOURCE_FILES_ ",\\\n " sonar_sources) + file(APPEND ${file_path} "sonar.sources=\\\n${sonar_sources}\n") + + list(JOIN _SWIFT_TARGET_TEST_FILES_ ",\\\n " sonar_tests) + file(APPEND ${file_path} "sonar.tests=\\\n${sonar_tests}\n") + +endfunction() From 251d3259ec9248ed77f02278180ff776ac080e5d Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Mon, 9 May 2022 16:13:51 +1000 Subject: [PATCH 02/23] collect swift targets --- Sonarcloud.cmake | 29 +++++++++++++++++++---------- SwiftTargets.cmake | 6 ++++++ TestTargets.cmake | 6 ++++++ 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index 1899925..d8301f5 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -10,31 +10,40 @@ # WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. # -include(SwiftTargets) # expects variable _SWIFT_SOURCE_TARGETS_ to be available -include(TestTargets) # expects variable _SWIFT_TEST_TARGETS_ to be available +include(SwiftTargets) # expects global properties SWIFT_EXECUTABLE_TARGETS and SWIFT_LIBRARY_TARGETS to be defined +include(TestTargets) # expects global properties SWIFT_UNIT_TEST_TARGETS and SWIFT_INTEGRATION_TEST_TARGETS to be defined function(generate_sonar_project_properties file_path) if (NOT ${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) return() endif() - list(LENGTH _SWIFT_TARGET_SOURCE_FILES_ source_files_size) - list(LENGTH _SWIFT_TARGET_TEST_FILES_ test_files_size) + get_property(swift_executable_targets GLOBAL PROPERTY SWIFT_EXECUTABLE_TARGETS) + get_property(swift_library_targets GLOBAL PROPERTY SWIFT_LIBRARY_TARGETS) - if (source_files_size EQUAL 0) - message(FATAL_ERROR "There are no registered source files") + get_property(swift_unit_test_targets GLOBAL PROPERTY SWIFT_UNIT_TEST_TARGETS) + get_property(swift_integration_test_targets GLOBAL PROPERTY SWIFT_INTEGRATION_TEST_TARGETS) + + set(swift_source_targets ${swift_executable_targets} ${swift_library_targets}) + list(LENGTH swift_source_targets swift_source_targets_size) + + set(swift_test_targets ${swift_unit_test_targets} ${swift_integration_test_targets}) + list(LENGTH swift_test_targets swift_test_targets_size) + + if (swift_source_targets_size EQUAL 0) + message(FATAL_ERROR "There are no registered swift source targets") endif() - if (test_files_size EQUAL 0) - message(FATAL_ERROR "There are no registered test files") + if (swift_test_targets_size EQUAL 0) + message(FATAL_ERROR "There are no registered swift test targets") endif() file(WRITE ${file_path} "sonar.sourceEncoding=UTF-8\n") - list(JOIN _SWIFT_TARGET_SOURCE_FILES_ ",\\\n " sonar_sources) + list(JOIN swift_source_targets ",\\\n " sonar_sources) file(APPEND ${file_path} "sonar.sources=\\\n${sonar_sources}\n") - list(JOIN _SWIFT_TARGET_TEST_FILES_ ",\\\n " sonar_tests) + list(JOIN swift_test_targets ",\\\n " sonar_tests) file(APPEND ${file_path} "sonar.tests=\\\n${sonar_tests}\n") endfunction() diff --git a/SwiftTargets.cmake b/SwiftTargets.cmake index f6c325d..29bdd1e 100644 --- a/SwiftTargets.cmake +++ b/SwiftTargets.cmake @@ -257,6 +257,9 @@ function(swift_add_target target type) if (type STREQUAL "executable") add_executable(${target} ${x_SOURCES}) list(APPEND extra_flags -pedantic) + + get_property(targets GLOBAL PROPERTY SWIFT_EXECUTABLE_TARGETS) + set_property(GLOBAL PROPERTY SWIFT_EXECUTABLE_TARGETS ${targets} ${target}) elseif(type STREQUAL "library") if (x_INTERFACE) add_library(${target} INTERFACE) @@ -266,6 +269,9 @@ function(swift_add_target target type) add_library(${target} ${library_type} ${x_SOURCES}) endif() list(APPEND extra_flags -pedantic) + + get_property(targets GLOBAL PROPERTY SWIFT_LIBRARY_TARGETS) + set_property(GLOBAL PROPERTY SWIFT_LIBRARY_TARGETS ${targets} ${target}) elseif(type STREQUAL "test_library") if (x_INTERFACE) add_library(${target} INTERFACE) diff --git a/TestTargets.cmake b/TestTargets.cmake index ba5a889..6d40b31 100644 --- a/TestTargets.cmake +++ b/TestTargets.cmake @@ -333,6 +333,9 @@ function(swift_add_test target) endif() if (x_INTEGRATION_TEST) + get_property(targets GLOBAL PROPERTY SWIFT_INTEGRATION_TEST_TARGETS) + set_property(GLOBAL PROPERTY SWIFT_INTEGRATION_TEST_TARGETS ${targets} ${target}) + if (NOT TARGET do-all-integration-tests) add_custom_target(do-all-integration-tests) endif() @@ -345,6 +348,9 @@ function(swift_add_test target) endif() if (x_UNIT_TEST) + get_property(targets GLOBAL PROPERTY SWIFT_UNIT_TEST_TARGETS) + set_property(GLOBAL PROPERTY SWIFT_UNIT_TEST_TARGETS ${targets} ${target}) + if (NOT TARGET do-all-unit-tests) add_custom_target(do-all-unit-tests) endif() From 6b9460a594fa7b56e31c24b1ea2f61b422cf551b Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Mon, 9 May 2022 21:51:01 +1000 Subject: [PATCH 03/23] added swift project properties --- SwiftTargets.cmake | 8 ++++++++ TestTargets.cmake | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/SwiftTargets.cmake b/SwiftTargets.cmake index 29bdd1e..f17a701 100644 --- a/SwiftTargets.cmake +++ b/SwiftTargets.cmake @@ -260,6 +260,10 @@ function(swift_add_target target type) get_property(targets GLOBAL PROPERTY SWIFT_EXECUTABLE_TARGETS) set_property(GLOBAL PROPERTY SWIFT_EXECUTABLE_TARGETS ${targets} ${target}) + set_target_properties(${target} + PROPERTIES + SWIFT_PROJECT ${PROJECT_NAME} + ) elseif(type STREQUAL "library") if (x_INTERFACE) add_library(${target} INTERFACE) @@ -272,6 +276,10 @@ function(swift_add_target target type) get_property(targets GLOBAL PROPERTY SWIFT_LIBRARY_TARGETS) set_property(GLOBAL PROPERTY SWIFT_LIBRARY_TARGETS ${targets} ${target}) + set_target_properties(${target} + PROPERTIES + SWIFT_PROJECT ${PROJECT_NAME} + ) elseif(type STREQUAL "test_library") if (x_INTERFACE) add_library(${target} INTERFACE) diff --git a/TestTargets.cmake b/TestTargets.cmake index 6d40b31..64cce74 100644 --- a/TestTargets.cmake +++ b/TestTargets.cmake @@ -335,6 +335,10 @@ function(swift_add_test target) if (x_INTEGRATION_TEST) get_property(targets GLOBAL PROPERTY SWIFT_INTEGRATION_TEST_TARGETS) set_property(GLOBAL PROPERTY SWIFT_INTEGRATION_TEST_TARGETS ${targets} ${target}) + set_target_properties(${target} + PROPERTIES + SWIFT_PROJECT ${PROJECT_NAME} + ) if (NOT TARGET do-all-integration-tests) add_custom_target(do-all-integration-tests) @@ -350,6 +354,10 @@ function(swift_add_test target) if (x_UNIT_TEST) get_property(targets GLOBAL PROPERTY SWIFT_UNIT_TEST_TARGETS) set_property(GLOBAL PROPERTY SWIFT_UNIT_TEST_TARGETS ${targets} ${target}) + set_target_properties(${target} + PROPERTIES + SWIFT_PROJECT ${PROJECT_NAME} + ) if (NOT TARGET do-all-unit-tests) add_custom_target(do-all-unit-tests) From 30b3257b47a9cf25dd5708e96ca4e7c2171d2847 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Mon, 9 May 2022 22:45:12 +1000 Subject: [PATCH 04/23] fixup --- Sonarcloud.cmake | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index d8301f5..3739cab 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -13,37 +13,57 @@ include(SwiftTargets) # expects global properties SWIFT_EXECUTABLE_TARGETS and SWIFT_LIBRARY_TARGETS to be defined include(TestTargets) # expects global properties SWIFT_UNIT_TEST_TARGETS and SWIFT_INTEGRATION_TEST_TARGETS to be defined -function(generate_sonar_project_properties file_path) +function(extract_sonarcloud_project_files output_variable) + unset(files) + + foreach (target IN ITEMS ${ARGN}) + get_target_property(swift_project ${target} SWIFT_PROJECT) + if(NOT swift_project STREQUAL ${PROJECT_NAME}) + continue() + endif() + + get_target_property(target_source_files ${target} SOURCES) + get_target_property(target_include_directories ${target} INCLUDE_DIRECTORIES) + get_target_property(target_interface_include_directories ${target} INTERFACE_INCLUDE_DIRECTORIES) + + list(APPEND files ${target_source_files}) + list(APPEND files ${target_include_directories}) + list(APPEND files ${target_interface_include_directories}) + endforeach() + + set(${output_variable} ${files} PARENT_SCOPE) +endfunction() + +function(generate_sonarcloud_project_properties file_path) if (NOT ${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) return() endif() get_property(swift_executable_targets GLOBAL PROPERTY SWIFT_EXECUTABLE_TARGETS) get_property(swift_library_targets GLOBAL PROPERTY SWIFT_LIBRARY_TARGETS) - get_property(swift_unit_test_targets GLOBAL PROPERTY SWIFT_UNIT_TEST_TARGETS) get_property(swift_integration_test_targets GLOBAL PROPERTY SWIFT_INTEGRATION_TEST_TARGETS) - set(swift_source_targets ${swift_executable_targets} ${swift_library_targets}) - list(LENGTH swift_source_targets swift_source_targets_size) + extract_sonarcloud_project_files(source_files ${swift_executable_targets} ${swift_library_targets}) + extract_sonarcloud_project_files(test_files ${swift_unit_test_targets} ${swift_integration_test_targets}) - set(swift_test_targets ${swift_unit_test_targets} ${swift_integration_test_targets}) - list(LENGTH swift_test_targets swift_test_targets_size) + list(LENGTH source_files source_files_size) + list(LENGTH test_files test_files_size) - if (swift_source_targets_size EQUAL 0) + if (source_files_size EQUAL 0) message(FATAL_ERROR "There are no registered swift source targets") endif() - if (swift_test_targets_size EQUAL 0) + if (test_files_size EQUAL 0) message(FATAL_ERROR "There are no registered swift test targets") endif() file(WRITE ${file_path} "sonar.sourceEncoding=UTF-8\n") - list(JOIN swift_source_targets ",\\\n " sonar_sources) + list(JOIN source_files ",\\\n " sonar_sources) file(APPEND ${file_path} "sonar.sources=\\\n${sonar_sources}\n") - list(JOIN swift_test_targets ",\\\n " sonar_tests) + list(JOIN test_files ",\\\n " sonar_tests) file(APPEND ${file_path} "sonar.tests=\\\n${sonar_tests}\n") endfunction() From 521f3d5ebbbde809007ec19bdc29c71c24b844ba Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Mon, 9 May 2022 22:58:45 +1000 Subject: [PATCH 05/23] SKIP_COMPILE_OPTIONS --- SwiftTargets.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/SwiftTargets.cmake b/SwiftTargets.cmake index f17a701..e29e606 100644 --- a/SwiftTargets.cmake +++ b/SwiftTargets.cmake @@ -182,7 +182,7 @@ macro(swift_collate_arguments prefix name) endmacro() function(swift_add_target target type) - set(this_option INTERFACE OBJECT STATIC SHARED MODULE) + set(this_option INTERFACE OBJECT STATIC SHARED MODULE SKIP_COMPILE_OPTIONS) set(this_single "") set(this_multi SOURCES) @@ -304,9 +304,12 @@ function(swift_add_target target type) if (NOT x_INTERFACE) set_target_properties(${target} PROPERTIES SWIFT_TYPE ${type}) - swift_set_compile_options(${target} ${compile_options_args} EXTRA_FLAGS ${extra_flags}) swift_set_language_standards(${target} ${language_standards_args}) target_code_coverage(${target} NO_RUN) + + if (NOT x_SKIP_COMPILE_OPTIONS) + swift_set_compile_options(${target} ${compile_options_args} EXTRA_FLAGS ${extra_flags}) + endif() endif() endfunction() From a48ca1bdbc55ab4b10c69f5c0f94ef2bcba05769 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Mon, 9 May 2022 23:06:15 +1000 Subject: [PATCH 06/23] format --- Sonarcloud.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index 3739cab..906abdb 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -61,9 +61,9 @@ function(generate_sonarcloud_project_properties file_path) file(WRITE ${file_path} "sonar.sourceEncoding=UTF-8\n") list(JOIN source_files ",\\\n " sonar_sources) - file(APPEND ${file_path} "sonar.sources=\\\n${sonar_sources}\n") + file(APPEND ${file_path} "sonar.sources=\\\n ${sonar_sources}\n") list(JOIN test_files ",\\\n " sonar_tests) - file(APPEND ${file_path} "sonar.tests=\\\n${sonar_tests}\n") + file(APPEND ${file_path} "sonar.tests=\\\n ${sonar_tests}\n") endfunction() From 56672ba34b638ef8772a78fb104c3b7bb7ed4eb8 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Tue, 10 May 2022 08:47:56 +1000 Subject: [PATCH 07/23] sonarcloud_to_project_directory --- Sonarcloud.cmake | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index 906abdb..7c2f10c 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -13,6 +13,19 @@ include(SwiftTargets) # expects global properties SWIFT_EXECUTABLE_TARGETS and SWIFT_LIBRARY_TARGETS to be defined include(TestTargets) # expects global properties SWIFT_UNIT_TEST_TARGETS and SWIFT_INTEGRATION_TEST_TARGETS to be defined +function(sonarcloud_to_project_directory output_variable) + unset(paths) + foreach (path IN ITEMS ${ARGN}) + if(IS_ABSOLUTE ${path}) + file(RELATIVE_PATH path ${PROJECT_SOURCE_DIR} ${path}) + list(APPEND paths ${path}) + else() + list(APPEND paths ${path}) + endif() + endforeach() + set(${output_variable} ${paths} PARENT_SCOPE) +endfunction() + function(extract_sonarcloud_project_files output_variable) unset(files) @@ -26,11 +39,18 @@ function(extract_sonarcloud_project_files output_variable) get_target_property(target_include_directories ${target} INCLUDE_DIRECTORIES) get_target_property(target_interface_include_directories ${target} INTERFACE_INCLUDE_DIRECTORIES) + sonarcloud_to_project_directory(target_source_files ${target_source_files}) + sonarcloud_to_project_directory(target_include_directories ${target_include_directories}) + sonarcloud_to_project_directory(target_interface_include_directories ${target_interface_include_directories}) + list(APPEND files ${target_source_files}) list(APPEND files ${target_include_directories}) list(APPEND files ${target_interface_include_directories}) endforeach() + list(SORT files) + list(REMOVE_DUPLICATES files) + set(${output_variable} ${files} PARENT_SCOPE) endfunction() From 562de0fc83d79099a048c04bb2f197c8ae0f2d3a Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Tue, 10 May 2022 12:29:02 +1000 Subject: [PATCH 08/23] improvements from using in Starling --- Sonarcloud.cmake | 132 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 107 insertions(+), 25 deletions(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index 7c2f10c..1bb51bf 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -13,25 +13,85 @@ include(SwiftTargets) # expects global properties SWIFT_EXECUTABLE_TARGETS and SWIFT_LIBRARY_TARGETS to be defined include(TestTargets) # expects global properties SWIFT_UNIT_TEST_TARGETS and SWIFT_INTEGRATION_TEST_TARGETS to be defined -function(sonarcloud_to_project_directory output_variable) - unset(paths) - foreach (path IN ITEMS ${ARGN}) - if(IS_ABSOLUTE ${path}) - file(RELATIVE_PATH path ${PROJECT_SOURCE_DIR} ${path}) - list(APPEND paths ${path}) - else() - list(APPEND paths ${path}) +function(transform_sonarcloud_source_files output_variable target) + # + # Based off of https://cmake.org/cmake/help/latest/prop_tgt/SOURCES.html we + # need to correcty interpret the SOURCES properties to be able to transform + # them into what sonarcloud project properties is comfortable with (ie. paths + # from project source directory + # + get_target_property(target_binary_dir ${target} BUILD_DIR) + get_target_property(target_source_dir ${target} SOURCE_DIR) + + unset(source_files) + foreach (source_file IN LISTS ARGN) + get_source_file_property(is_build_generated_file ${target_binary_dir}/${source_file} GENERATED) + + if(IS_ABSOLUTE ${source_file}) + file(RELATIVE_PATH source_file ${PROJECT_SOURCE_DIR} ${source_file}) + list(APPEND source_files ${source_file}) + continue() + endif() + + if (is_build_generated_file) + set(source_file ${target_binary_dir}/${source_file}) + file(RELATIVE_PATH source_file ${PROJECT_SOURCE_DIR} ${source_file}) + list(APPEND source_files ${source_file}) + continue() + endif() + + if (EXISTS ${target_source_dir}/${source_file}) + set(source_file ${target_source_dir}/${source_file}) + file(RELATIVE_PATH source_file ${PROJECT_SOURCE_DIR} ${source_file}) + list(APPEND source_files ${source_file}) + continue() + endif() + + if (source_file MATCHES "^\\$<.+>$") + list(APPEND source_files ${source_file}) + continue() endif() + + message(WARNING "Sonarcloud is missing source file \"${source_file}\" for target ${target}") + list(APPEND source_files ${source_file}) endforeach() - set(${output_variable} ${paths} PARENT_SCOPE) + + set(${output_variable} ${source_files} PARENT_SCOPE) +endfunction() + +function(transform_sonarcloud_include_directories output_variable target) + unset(include_directories) + + foreach (include_directory IN LISTS ARGN) + if(IS_ABSOLUTE ${include_directory}) + file(RELATIVE_PATH include_directory ${PROJECT_SOURCE_DIR} ${include_directory}) + list(APPEND include_directories ${include_directory}) + continue() + endif() + + if (include_directory MATCHES "^\\$$") + # ignoring installation interfaces + continue() + endif() + + if (include_directory MATCHES "^\\$<.+>$") + list(APPEND include_directories ${include_directory}) + continue() + endif() + + message(WARNING "Sonarcloud is missing include directory \"${include_directory}\" for target ${target}") + list(APPEND include_directories ${include_directory}) + endforeach() + + set(${output_variable} ${include_directories} PARENT_SCOPE) endfunction() function(extract_sonarcloud_project_files output_variable) - unset(files) + unset(project_files) - foreach (target IN ITEMS ${ARGN}) + foreach (target IN LISTS ARGN) get_target_property(swift_project ${target} SWIFT_PROJECT) - if(NOT swift_project STREQUAL ${PROJECT_NAME}) + if(NOT ${swift_project} STREQUAL ${PROJECT_NAME}) continue() endif() @@ -39,22 +99,33 @@ function(extract_sonarcloud_project_files output_variable) get_target_property(target_include_directories ${target} INCLUDE_DIRECTORIES) get_target_property(target_interface_include_directories ${target} INTERFACE_INCLUDE_DIRECTORIES) - sonarcloud_to_project_directory(target_source_files ${target_source_files}) - sonarcloud_to_project_directory(target_include_directories ${target_include_directories}) - sonarcloud_to_project_directory(target_interface_include_directories ${target_interface_include_directories}) + foreach(variable IN ITEMS target_source_files target_include_directories target_interface_include_directories) + if (NOT ${variable}) + unset(${variable}) + endif() + endforeach() - list(APPEND files ${target_source_files}) - list(APPEND files ${target_include_directories}) - list(APPEND files ${target_interface_include_directories}) + transform_sonarcloud_source_files(target_source_files ${target} ${target_source_files}) + transform_sonarcloud_include_directories(target_include_directories ${target} ${target_include_directories}) + transform_sonarcloud_include_directories(target_interface_include_directories ${target} ${target_interface_include_directories}) + + list(APPEND project_files ${target_source_files}) + list(APPEND project_files ${target_include_directories}) + list(APPEND project_files ${target_interface_include_directories}) endforeach() - list(SORT files) - list(REMOVE_DUPLICATES files) + list(SORT project_files) + list(REMOVE_DUPLICATES project_files) - set(${output_variable} ${files} PARENT_SCOPE) + set(${output_variable} ${project_files} PARENT_SCOPE) endfunction() -function(generate_sonarcloud_project_properties file_path) +function(generate_sonarcloud_project_properties sonarcloud_project_properties_path) + if (NOT IS_ABSOLUTE ${sonarcloud_project_properties_path}) + message(FATAL_ERROR "Function \"generate_sonarcloud_project_properties\"" + "only accepts sonarcloud project properties output as absolute paths") + endif() + if (NOT ${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) return() endif() @@ -67,6 +138,12 @@ function(generate_sonarcloud_project_properties file_path) extract_sonarcloud_project_files(source_files ${swift_executable_targets} ${swift_library_targets}) extract_sonarcloud_project_files(test_files ${swift_unit_test_targets} ${swift_integration_test_targets}) + # + # In the case were we are directly compiling the source code for mocking, we + # need to strip off the source files. + # + list(REMOVE_ITEM test_files ${source_files}) + list(LENGTH source_files source_files_size) list(LENGTH test_files test_files_size) @@ -78,12 +155,17 @@ function(generate_sonarcloud_project_properties file_path) message(FATAL_ERROR "There are no registered swift test targets") endif() - file(WRITE ${file_path} "sonar.sourceEncoding=UTF-8\n") + set(sonarcloud_project_properties_content "sonar.sourceEncoding=UTF-8\n") list(JOIN source_files ",\\\n " sonar_sources) - file(APPEND ${file_path} "sonar.sources=\\\n ${sonar_sources}\n") + string(APPEND sonarcloud_project_properties_content "sonar.sources=\\\n ${sonar_sources}\n") list(JOIN test_files ",\\\n " sonar_tests) - file(APPEND ${file_path} "sonar.tests=\\\n ${sonar_tests}\n") + string(APPEND sonarcloud_project_properties_content "sonar.tests=\\\n ${sonar_tests}\n") + + file(GENERATE + OUTPUT "${sonarcloud_project_properties_path}" + CONTENT "${sonarcloud_project_properties_content}" + ) endfunction() From 453b5832786326d511e6addac20de415a4154a45 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Tue, 10 May 2022 13:32:45 +1000 Subject: [PATCH 09/23] dealing with empty list --- Sonarcloud.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index 1bb51bf..67e2697 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -114,8 +114,10 @@ function(extract_sonarcloud_project_files output_variable) list(APPEND project_files ${target_interface_include_directories}) endforeach() - list(SORT project_files) - list(REMOVE_DUPLICATES project_files) + if (project_files) + list(SORT project_files) + list(REMOVE_DUPLICATES project_files) + endif() set(${output_variable} ${project_files} PARENT_SCOPE) endfunction() From b5ad810e1bac253be38ca80dfed161571a238bc7 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Tue, 10 May 2022 14:08:06 +1000 Subject: [PATCH 10/23] fix up cmake version issue --- Sonarcloud.cmake | 40 +++++++++++++++++++++++++++------------- SwiftTargets.cmake | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index 67e2697..1f068c2 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -11,7 +11,7 @@ # include(SwiftTargets) # expects global properties SWIFT_EXECUTABLE_TARGETS and SWIFT_LIBRARY_TARGETS to be defined -include(TestTargets) # expects global properties SWIFT_UNIT_TEST_TARGETS and SWIFT_INTEGRATION_TEST_TARGETS to be defined +include(TestTargets) # expects global properties SWIFT_TEST_TARGETS, SWIFT_UNIT_TEST_TARGETS and SWIFT_INTEGRATION_TEST_TARGETS to be defined function(transform_sonarcloud_source_files output_variable target) # @@ -90,24 +90,37 @@ function(extract_sonarcloud_project_files output_variable) unset(project_files) foreach (target IN LISTS ARGN) - get_target_property(swift_project ${target} SWIFT_PROJECT) + get_target_property(target_type ${target} TYPE) + if (${target_type} STREQUAL "INTERFACE_LIBRARY") + get_target_property(swift_project ${target} INTERFACE_SWIFT_PROJECT) + else() + get_target_property(swift_project ${target} SWIFT_PROJECT) + endif() + if(NOT ${swift_project} STREQUAL ${PROJECT_NAME}) continue() endif() - get_target_property(target_source_files ${target} SOURCES) - get_target_property(target_include_directories ${target} INCLUDE_DIRECTORIES) - get_target_property(target_interface_include_directories ${target} INTERFACE_INCLUDE_DIRECTORIES) + unset(target_source_files) + unset(target_include_directories) + unset(target_interface_include_directories) + + if (NOT ${target_type} STREQUAL "INTERFACE_LIBRARY") + get_target_property(target_source_files ${target} SOURCES) + if (target_source_files) + transform_sonarcloud_source_files(target_source_files ${target} ${target_source_files}) + endif() - foreach(variable IN ITEMS target_source_files target_include_directories target_interface_include_directories) - if (NOT ${variable}) - unset(${variable}) + get_target_property(target_include_directories ${target} INCLUDE_DIRECTORIES) + if (target_include_directories) + transform_sonarcloud_include_directories(target_include_directories ${target} ${target_include_directories}) endif() - endforeach() + endif() - transform_sonarcloud_source_files(target_source_files ${target} ${target_source_files}) - transform_sonarcloud_include_directories(target_include_directories ${target} ${target_include_directories}) - transform_sonarcloud_include_directories(target_interface_include_directories ${target} ${target_interface_include_directories}) + get_target_property(target_interface_include_directories ${target} INTERFACE_INCLUDE_DIRECTORIES) + if (target_interface_include_directories) + transform_sonarcloud_include_directories(target_interface_include_directories ${target} ${target_interface_include_directories}) + endif() list(APPEND project_files ${target_source_files}) list(APPEND project_files ${target_include_directories}) @@ -134,11 +147,12 @@ function(generate_sonarcloud_project_properties sonarcloud_project_properties_pa get_property(swift_executable_targets GLOBAL PROPERTY SWIFT_EXECUTABLE_TARGETS) get_property(swift_library_targets GLOBAL PROPERTY SWIFT_LIBRARY_TARGETS) + get_property(swift_test_targets GLOBAL PROPERTY SWIFT_TEST_TARGETS) get_property(swift_unit_test_targets GLOBAL PROPERTY SWIFT_UNIT_TEST_TARGETS) get_property(swift_integration_test_targets GLOBAL PROPERTY SWIFT_INTEGRATION_TEST_TARGETS) extract_sonarcloud_project_files(source_files ${swift_executable_targets} ${swift_library_targets}) - extract_sonarcloud_project_files(test_files ${swift_unit_test_targets} ${swift_integration_test_targets}) + extract_sonarcloud_project_files(test_files ${swift_test_targets} ${swift_unit_test_targets} ${swift_integration_test_targets}) # # In the case were we are directly compiling the source code for mocking, we diff --git a/SwiftTargets.cmake b/SwiftTargets.cmake index e29e606..1bc30cd 100644 --- a/SwiftTargets.cmake +++ b/SwiftTargets.cmake @@ -276,10 +276,25 @@ function(swift_add_target target type) get_property(targets GLOBAL PROPERTY SWIFT_LIBRARY_TARGETS) set_property(GLOBAL PROPERTY SWIFT_LIBRARY_TARGETS ${targets} ${target}) + + # + # This edge case is needed for cmake version < 3.19.0 where INTERFACE + # classes cannot contain any property other than those prefixed with + # "INTERFACE_". + # + # see: https://stackoverflow.com/questions/68502038/custom-properties-for-interface-libraries + # set_target_properties(${target} PROPERTIES - SWIFT_PROJECT ${PROJECT_NAME} + INTERFACE_SWIFT_PROJECT ${PROJECT_NAME} ) + + if (NOT x_INTERFACE) + set_target_properties(${target} + PROPERTIES + SWIFT_PROJECT ${PROJECT_NAME} + ) + endif() elseif(type STREQUAL "test_library") if (x_INTERFACE) add_library(${target} INTERFACE) @@ -288,6 +303,28 @@ function(swift_add_target target type) else() add_library(${target} ${library_type} ${x_SOURCES}) endif() + + get_property(targets GLOBAL PROPERTY SWIFT_TEST_TARGETS) + set_property(GLOBAL PROPERTY SWIFT_TEST_TARGETS ${targets} ${target}) + + # + # This edge case is needed for cmake version < 3.19.0 where INTERFACE + # classes cannot contain any property other than those prefixed with + # "INTERFACE_". + # + # see: https://stackoverflow.com/questions/68502038/custom-properties-for-interface-libraries + # + set_target_properties(${target} + PROPERTIES + INTERFACE_SWIFT_PROJECT ${PROJECT_NAME} + ) + + if (NOT x_INTERFACE) + set_target_properties(${target} + PROPERTIES + SWIFT_PROJECT ${PROJECT_NAME} + ) + endif() elseif(type STREQUAL "tool") add_executable(${target} ${x_SOURCES}) elseif(type STREQUAL "tool_library") From 319f92b09fcb9009e9bf1c895b6725b302a476d0 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Wed, 11 May 2022 09:04:07 +1000 Subject: [PATCH 11/23] remove addition --- Sonarcloud.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index 1f068c2..f1fc177 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -53,7 +53,6 @@ function(transform_sonarcloud_source_files output_variable target) endif() message(WARNING "Sonarcloud is missing source file \"${source_file}\" for target ${target}") - list(APPEND source_files ${source_file}) endforeach() set(${output_variable} ${source_files} PARENT_SCOPE) @@ -80,7 +79,6 @@ function(transform_sonarcloud_include_directories output_variable target) endif() message(WARNING "Sonarcloud is missing include directory \"${include_directory}\" for target ${target}") - list(APPEND include_directories ${include_directory}) endforeach() set(${output_variable} ${include_directories} PARENT_SCOPE) From f228b506e42d00d3348fd66da87cf5e67927d2ce Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Thu, 12 May 2022 13:35:34 +1000 Subject: [PATCH 12/23] generator expression expansion --- Sonarcloud.cmake | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index f1fc177..b067473 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -13,6 +13,8 @@ include(SwiftTargets) # expects global properties SWIFT_EXECUTABLE_TARGETS and SWIFT_LIBRARY_TARGETS to be defined include(TestTargets) # expects global properties SWIFT_TEST_TARGETS, SWIFT_UNIT_TEST_TARGETS and SWIFT_INTEGRATION_TEST_TARGETS to be defined +set(_sonarcloud_line_glue "\\\n ") + function(transform_sonarcloud_source_files output_variable target) # # Based off of https://cmake.org/cmake/help/latest/prop_tgt/SOURCES.html we @@ -48,7 +50,7 @@ function(transform_sonarcloud_source_files output_variable target) endif() if (source_file MATCHES "^\\$<.+>$") - list(APPEND source_files ${source_file}) + list(APPEND source_files "$<$:$>") continue() endif() @@ -74,7 +76,7 @@ function(transform_sonarcloud_include_directories output_variable target) endif() if (include_directory MATCHES "^\\$<.+>$") - list(APPEND include_directories ${include_directory}) + list(APPEND include_directories "$<$:$>") continue() endif() @@ -171,11 +173,11 @@ function(generate_sonarcloud_project_properties sonarcloud_project_properties_pa set(sonarcloud_project_properties_content "sonar.sourceEncoding=UTF-8\n") - list(JOIN source_files ",\\\n " sonar_sources) - string(APPEND sonarcloud_project_properties_content "sonar.sources=\\\n ${sonar_sources}\n") + list(JOIN source_files ",${_sonarcloud_line_glue}" sonar_sources) + string(APPEND sonarcloud_project_properties_content "sonar.sources=${_sonarcloud_line_glue}${sonar_sources}\n") - list(JOIN test_files ",\\\n " sonar_tests) - string(APPEND sonarcloud_project_properties_content "sonar.tests=\\\n ${sonar_tests}\n") + list(JOIN test_files ",${_sonarcloud_line_glue}" sonar_tests) + string(APPEND sonarcloud_project_properties_content "sonar.tests=${_sonarcloud_line_glue}${sonar_tests}\n") file(GENERATE OUTPUT "${sonarcloud_project_properties_path}" From 7c95253fd8264115eeb36e1a982cb998d51a3dec Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Thu, 12 May 2022 13:59:21 +1000 Subject: [PATCH 13/23] remove relative paths --- Sonarcloud.cmake | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index b067473..efbbf25 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -30,22 +30,17 @@ function(transform_sonarcloud_source_files output_variable target) get_source_file_property(is_build_generated_file ${target_binary_dir}/${source_file} GENERATED) if(IS_ABSOLUTE ${source_file}) - file(RELATIVE_PATH source_file ${PROJECT_SOURCE_DIR} ${source_file}) list(APPEND source_files ${source_file}) continue() endif() if (is_build_generated_file) - set(source_file ${target_binary_dir}/${source_file}) - file(RELATIVE_PATH source_file ${PROJECT_SOURCE_DIR} ${source_file}) - list(APPEND source_files ${source_file}) + list(APPEND source_files ${target_binary_dir}/${source_file}) continue() endif() if (EXISTS ${target_source_dir}/${source_file}) - set(source_file ${target_source_dir}/${source_file}) - file(RELATIVE_PATH source_file ${PROJECT_SOURCE_DIR} ${source_file}) - list(APPEND source_files ${source_file}) + list(APPEND source_files ${target_source_dir}/${source_file}) continue() endif() @@ -65,7 +60,6 @@ function(transform_sonarcloud_include_directories output_variable target) foreach (include_directory IN LISTS ARGN) if(IS_ABSOLUTE ${include_directory}) - file(RELATIVE_PATH include_directory ${PROJECT_SOURCE_DIR} ${include_directory}) list(APPEND include_directories ${include_directory}) continue() endif() From f21ea9c321189f965ec9e0c5a858a3f849571938 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Thu, 12 May 2022 16:13:51 +1000 Subject: [PATCH 14/23] fixed missing comma and inclusion of NOT FOUND --- Sonarcloud.cmake | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index efbbf25..ca81c14 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -13,7 +13,7 @@ include(SwiftTargets) # expects global properties SWIFT_EXECUTABLE_TARGETS and SWIFT_LIBRARY_TARGETS to be defined include(TestTargets) # expects global properties SWIFT_TEST_TARGETS, SWIFT_UNIT_TEST_TARGETS and SWIFT_INTEGRATION_TEST_TARGETS to be defined -set(_sonarcloud_line_glue "\\\n ") +set(_sonarcloud_newline "\\\n ") function(transform_sonarcloud_source_files output_variable target) # @@ -45,7 +45,7 @@ function(transform_sonarcloud_source_files output_variable target) endif() if (source_file MATCHES "^\\$<.+>$") - list(APPEND source_files "$<$:$>") + list(APPEND source_files "$<$:$${_sonarcloud_newline}>>") continue() endif() @@ -70,7 +70,7 @@ function(transform_sonarcloud_include_directories output_variable target) endif() if (include_directory MATCHES "^\\$<.+>$") - list(APPEND include_directories "$<$:$>") + list(APPEND include_directories "$<$:$${_sonarcloud_newline}>>") continue() endif() @@ -95,25 +95,27 @@ function(extract_sonarcloud_project_files output_variable) continue() endif() - unset(target_source_files) - unset(target_include_directories) - unset(target_interface_include_directories) - if (NOT ${target_type} STREQUAL "INTERFACE_LIBRARY") get_target_property(target_source_files ${target} SOURCES) if (target_source_files) transform_sonarcloud_source_files(target_source_files ${target} ${target_source_files}) + else() + unset(target_source_files) endif() get_target_property(target_include_directories ${target} INCLUDE_DIRECTORIES) if (target_include_directories) transform_sonarcloud_include_directories(target_include_directories ${target} ${target_include_directories}) + else() + unset(target_include_directories) endif() endif() get_target_property(target_interface_include_directories ${target} INTERFACE_INCLUDE_DIRECTORIES) if (target_interface_include_directories) transform_sonarcloud_include_directories(target_interface_include_directories ${target} ${target_interface_include_directories}) + else() + unset(target_interface_include_directories) endif() list(APPEND project_files ${target_source_files}) @@ -167,11 +169,11 @@ function(generate_sonarcloud_project_properties sonarcloud_project_properties_pa set(sonarcloud_project_properties_content "sonar.sourceEncoding=UTF-8\n") - list(JOIN source_files ",${_sonarcloud_line_glue}" sonar_sources) - string(APPEND sonarcloud_project_properties_content "sonar.sources=${_sonarcloud_line_glue}${sonar_sources}\n") + list(JOIN source_files ",${_sonarcloud_newline}" sonar_sources) + string(APPEND sonarcloud_project_properties_content "sonar.sources=${_sonarcloud_newline}${sonar_sources}\n") - list(JOIN test_files ",${_sonarcloud_line_glue}" sonar_tests) - string(APPEND sonarcloud_project_properties_content "sonar.tests=${_sonarcloud_line_glue}${sonar_tests}\n") + list(JOIN test_files ",${_sonarcloud_newline}" sonar_tests) + string(APPEND sonarcloud_project_properties_content "sonar.tests=${_sonarcloud_newline}${sonar_tests}\n") file(GENERATE OUTPUT "${sonarcloud_project_properties_path}" From 455832f8df549363e8266345aa48ff728dbaef85 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Thu, 12 May 2022 17:08:04 +1000 Subject: [PATCH 15/23] major refactor --- .cmake-format.yaml | 4 ++-- Sonarcloud.cmake | 54 +++++++++++++++++++++------------------------- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/.cmake-format.yaml b/.cmake-format.yaml index 0fc7d53..89d3a7e 100644 --- a/.cmake-format.yaml +++ b/.cmake-format.yaml @@ -51,10 +51,10 @@ lint: min_statement_spacing: 1 max_statement_spacing: 2 max_returns: 6 - max_branches: 30 # Default target: 12 + max_branches: 40 # Default target: 12 max_arguments: 6 # Default target: 5 max_localvars: 15 - max_statements: 110 # Default target: 50 + max_statements: 120 # Default target: 50 encode: emit_byteorder_mark: false input_encoding: utf-8 diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index ca81c14..c9ed3c2 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -80,8 +80,9 @@ function(transform_sonarcloud_include_directories output_variable target) set(${output_variable} ${include_directories} PARENT_SCOPE) endfunction() -function(extract_sonarcloud_project_files output_variable) - unset(project_files) +function(extract_sonarcloud_project_files output_project_source_files output_project_include_directories) + unset(project_source_files) + unset(project_include_directories) foreach (target IN LISTS ARGN) get_target_property(target_type ${target} TYPE) @@ -118,17 +119,23 @@ function(extract_sonarcloud_project_files output_variable) unset(target_interface_include_directories) endif() - list(APPEND project_files ${target_source_files}) - list(APPEND project_files ${target_include_directories}) - list(APPEND project_files ${target_interface_include_directories}) + list(APPEND project_source_files ${target_source_files}) + list(APPEND project_include_directories ${target_include_directories}) + list(APPEND project_include_directories ${target_interface_include_directories}) endforeach() - if (project_files) - list(SORT project_files) - list(REMOVE_DUPLICATES project_files) + if (project_source_files) + list(SORT project_source_files) + list(REMOVE_DUPLICATES project_source_files) endif() - set(${output_variable} ${project_files} PARENT_SCOPE) + if (project_include_directories) + list(SORT project_include_directories) + list(REMOVE_DUPLICATES project_include_directories) + endif() + + set(${output_project_source_files} ${project_source_files} PARENT_SCOPE) + set(${output_project_include_directories} ${project_include_directories} PARENT_SCOPE) endfunction() function(generate_sonarcloud_project_properties sonarcloud_project_properties_path) @@ -147,33 +154,20 @@ function(generate_sonarcloud_project_properties sonarcloud_project_properties_pa get_property(swift_unit_test_targets GLOBAL PROPERTY SWIFT_UNIT_TEST_TARGETS) get_property(swift_integration_test_targets GLOBAL PROPERTY SWIFT_INTEGRATION_TEST_TARGETS) - extract_sonarcloud_project_files(source_files ${swift_executable_targets} ${swift_library_targets}) - extract_sonarcloud_project_files(test_files ${swift_test_targets} ${swift_unit_test_targets} ${swift_integration_test_targets}) - - # - # In the case were we are directly compiling the source code for mocking, we - # need to strip off the source files. - # - list(REMOVE_ITEM test_files ${source_files}) - - list(LENGTH source_files source_files_size) - list(LENGTH test_files test_files_size) - - if (source_files_size EQUAL 0) - message(FATAL_ERROR "There are no registered swift source targets") - endif() - - if (test_files_size EQUAL 0) - message(FATAL_ERROR "There are no registered swift test targets") - endif() + extract_sonarcloud_project_files(source_source_files source_include_directories ${swift_executable_targets} ${swift_library_targets}) + extract_sonarcloud_project_files(test_source_files test_include_directories ${swift_test_targets} ${swift_unit_test_targets} ${swift_integration_test_targets}) set(sonarcloud_project_properties_content "sonar.sourceEncoding=UTF-8\n") +# string(APPEND sonarcloud_project_properties_content "sonar.sources=${_sonarcloud_newline}${PROJECT_SOURCE_DIR},${_sonarcloud_newline}${PROJECT_BINARY_DIR}\n") +# string(APPEND sonarcloud_project_properties_content "sonar.tests=${_sonarcloud_newline}${PROJECT_SOURCE_DIR},${_sonarcloud_newline}${PROJECT_BINARY_DIR}\n") + set(source_files ${source_source_files}) list(JOIN source_files ",${_sonarcloud_newline}" sonar_sources) - string(APPEND sonarcloud_project_properties_content "sonar.sources=${_sonarcloud_newline}${sonar_sources}\n") + string(APPEND sonarcloud_project_properties_content "sonar.sources.inclusions=${_sonarcloud_newline}${sonar_sources}\n") + set(test_files ${test_source_files}) list(JOIN test_files ",${_sonarcloud_newline}" sonar_tests) - string(APPEND sonarcloud_project_properties_content "sonar.tests=${_sonarcloud_newline}${sonar_tests}\n") + string(APPEND sonarcloud_project_properties_content "sonar.tests.inclusions=${_sonarcloud_newline}${sonar_tests}\n") file(GENERATE OUTPUT "${sonarcloud_project_properties_path}" From 9164f7ea6b498e2ca893d194c4020a4e01323fdc Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Thu, 12 May 2022 23:37:03 +1000 Subject: [PATCH 16/23] commit --- Sonarcloud.cmake | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index c9ed3c2..517eb09 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -158,12 +158,10 @@ function(generate_sonarcloud_project_properties sonarcloud_project_properties_pa extract_sonarcloud_project_files(test_source_files test_include_directories ${swift_test_targets} ${swift_unit_test_targets} ${swift_integration_test_targets}) set(sonarcloud_project_properties_content "sonar.sourceEncoding=UTF-8\n") -# string(APPEND sonarcloud_project_properties_content "sonar.sources=${_sonarcloud_newline}${PROJECT_SOURCE_DIR},${_sonarcloud_newline}${PROJECT_BINARY_DIR}\n") -# string(APPEND sonarcloud_project_properties_content "sonar.tests=${_sonarcloud_newline}${PROJECT_SOURCE_DIR},${_sonarcloud_newline}${PROJECT_BINARY_DIR}\n") - set(source_files ${source_source_files}) + set(source_files ${source_source_files} ${source_include_directories}) list(JOIN source_files ",${_sonarcloud_newline}" sonar_sources) - string(APPEND sonarcloud_project_properties_content "sonar.sources.inclusions=${_sonarcloud_newline}${sonar_sources}\n") + string(APPEND sonarcloud_project_properties_content "sonar.inclusions=${_sonarcloud_newline}${sonar_sources}\n") set(test_files ${test_source_files}) list(JOIN test_files ",${_sonarcloud_newline}" sonar_tests) From 039d8fa1ff6f84bc493b4d63036089b453678423 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Fri, 13 May 2022 15:57:41 +1000 Subject: [PATCH 17/23] refactor --- SwiftTargets.cmake | 96 +++++++++++++++++++++------------------------- TestTargets.cmake | 14 ++++--- 2 files changed, 52 insertions(+), 58 deletions(-) diff --git a/SwiftTargets.cmake b/SwiftTargets.cmake index 1bc30cd..59b8891 100644 --- a/SwiftTargets.cmake +++ b/SwiftTargets.cmake @@ -156,6 +156,26 @@ define_property(TARGET BRIEF_DOCS "Swift target type" FULL_DOCS "For use by other modules in this repository which need to know the classification of target. One of executable, library, tool, tool_library, test, test_library") +define_property(TARGET + PROPERTY INTERFACE_SWIFT_TYPE + BRIEF_DOCS "Swift target type" + FULL_DOCS "Identical use as SWIFT_TYPE except that this applies to ALL target types, including INTERFACE") + +define_property(TARGET + PROPERTY SWIFT_PROJECT + BRIEF_DOCS "Swift project name" + FULL_DOCS "For use by other modules in this repository which need to know the project which this target belongs to") + +define_property(TARGET + PROPERTY INTERFACE_SWIFT_PROJECT + BRIEF_DOCS "Swift project name" + FULL_DOCS "Identical use as SWIFT_PROJECT except that this applies to ALL target types, including INTERFACE") + +define_property(TARGET + PROPERTY SWIFT_TEST_TYPE + BRIEF_DOCS "Swift test type" + FULL_DOCS "When target's SWIFT_PROJECT property is \"test\", this option, if set, will identify what type of test it is. Currently support \"unit\" or \"integration\"") + macro(swift_collate_arguments prefix name) set(exclusion_list ${ARGN}) set(${name}_args "") @@ -257,13 +277,6 @@ function(swift_add_target target type) if (type STREQUAL "executable") add_executable(${target} ${x_SOURCES}) list(APPEND extra_flags -pedantic) - - get_property(targets GLOBAL PROPERTY SWIFT_EXECUTABLE_TARGETS) - set_property(GLOBAL PROPERTY SWIFT_EXECUTABLE_TARGETS ${targets} ${target}) - set_target_properties(${target} - PROPERTIES - SWIFT_PROJECT ${PROJECT_NAME} - ) elseif(type STREQUAL "library") if (x_INTERFACE) add_library(${target} INTERFACE) @@ -273,28 +286,6 @@ function(swift_add_target target type) add_library(${target} ${library_type} ${x_SOURCES}) endif() list(APPEND extra_flags -pedantic) - - get_property(targets GLOBAL PROPERTY SWIFT_LIBRARY_TARGETS) - set_property(GLOBAL PROPERTY SWIFT_LIBRARY_TARGETS ${targets} ${target}) - - # - # This edge case is needed for cmake version < 3.19.0 where INTERFACE - # classes cannot contain any property other than those prefixed with - # "INTERFACE_". - # - # see: https://stackoverflow.com/questions/68502038/custom-properties-for-interface-libraries - # - set_target_properties(${target} - PROPERTIES - INTERFACE_SWIFT_PROJECT ${PROJECT_NAME} - ) - - if (NOT x_INTERFACE) - set_target_properties(${target} - PROPERTIES - SWIFT_PROJECT ${PROJECT_NAME} - ) - endif() elseif(type STREQUAL "test_library") if (x_INTERFACE) add_library(${target} INTERFACE) @@ -303,28 +294,6 @@ function(swift_add_target target type) else() add_library(${target} ${library_type} ${x_SOURCES}) endif() - - get_property(targets GLOBAL PROPERTY SWIFT_TEST_TARGETS) - set_property(GLOBAL PROPERTY SWIFT_TEST_TARGETS ${targets} ${target}) - - # - # This edge case is needed for cmake version < 3.19.0 where INTERFACE - # classes cannot contain any property other than those prefixed with - # "INTERFACE_". - # - # see: https://stackoverflow.com/questions/68502038/custom-properties-for-interface-libraries - # - set_target_properties(${target} - PROPERTIES - INTERFACE_SWIFT_PROJECT ${PROJECT_NAME} - ) - - if (NOT x_INTERFACE) - set_target_properties(${target} - PROPERTIES - SWIFT_PROJECT ${PROJECT_NAME} - ) - endif() elseif(type STREQUAL "tool") add_executable(${target} ${x_SOURCES}) elseif(type STREQUAL "tool_library") @@ -339,8 +308,31 @@ function(swift_add_target target type) message(FATAL_ERROR "Unknown Swift target type ${type}") endif() + # + # This edge case is needed for cmake version < 3.19.0 where INTERFACE + # classes cannot contain any property other than those prefixed with + # "INTERFACE_". + # + # see: https://stackoverflow.com/questions/68502038/custom-properties-for-interface-libraries + # + # Until we migrate the cmake scripts to require 3.19.0, we should use the + # "INTERFACE_*" properties. If you want to go the extra mile, make sure to + # check both `INTERFACE_` and non `INTERFACE_` properties, later on we can + # delete the `INTERFACE_` once this illogical constraint is removed. + # + set_target_properties(${target} + PROPERTIES + INTERFACE_SWIFT_PROJECT ${PROJECT_NAME} + INTERFACE_SWIFT_TYPE ${type} + ) + if (NOT x_INTERFACE) - set_target_properties(${target} PROPERTIES SWIFT_TYPE ${type}) + set_target_properties(${target} + PROPERTIES + SWIFT_PROJECT ${PROJECT_NAME} + SWIFT_TYPE ${type} + ) + swift_set_language_standards(${target} ${language_standards_args}) target_code_coverage(${target} NO_RUN) diff --git a/TestTargets.cmake b/TestTargets.cmake index 64cce74..f5cf83d 100644 --- a/TestTargets.cmake +++ b/TestTargets.cmake @@ -332,12 +332,16 @@ function(swift_add_test target) add_dependencies(do-all-tests do-${target}) endif() + set_target_properties(${target} + PROPERTIES + SWIFT_PROJECT ${PROJECT_NAME} + INTERFACE_SWIFT_PROJECT ${PROJECT_NAME} + ) + if (x_INTEGRATION_TEST) - get_property(targets GLOBAL PROPERTY SWIFT_INTEGRATION_TEST_TARGETS) - set_property(GLOBAL PROPERTY SWIFT_INTEGRATION_TEST_TARGETS ${targets} ${target}) set_target_properties(${target} PROPERTIES - SWIFT_PROJECT ${PROJECT_NAME} + SWIFT_TEST_TYPE integration ) if (NOT TARGET do-all-integration-tests) @@ -352,11 +356,9 @@ function(swift_add_test target) endif() if (x_UNIT_TEST) - get_property(targets GLOBAL PROPERTY SWIFT_UNIT_TEST_TARGETS) - set_property(GLOBAL PROPERTY SWIFT_UNIT_TEST_TARGETS ${targets} ${target}) set_target_properties(${target} PROPERTIES - SWIFT_PROJECT ${PROJECT_NAME} + SWIFT_TEST_TYPE unit ) if (NOT TARGET do-all-unit-tests) From 09cd3a32c182758586f30379f3a4cfd4d85d485d Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Fri, 13 May 2022 20:54:31 +1000 Subject: [PATCH 18/23] changes --- ListTargets.cmake | 16 +++++++++++++--- Sonarcloud.cmake | 25 ++++++++++++++++--------- SwiftTargets.cmake | 7 +++++++ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/ListTargets.cmake b/ListTargets.cmake index 3919ada..6e10b4e 100644 --- a/ListTargets.cmake +++ b/ListTargets.cmake @@ -70,22 +70,32 @@ function(swift_list_targets out_var) set(all_targets) foreach(target IN LISTS x_all_targets) + get_target_property(type ${target} TYPE) if(x_TYPES) - get_target_property(type ${target} TYPE) if(NOT ${type} IN_LIST x_TYPES) continue() endif() endif() if(x_SWIFT_TYPES) - get_target_property(type ${target} SWIFT_TYPE) + if (type STREQUAL "INTERFACE_LIBRARY") + get_target_property(type ${target} INTERFACE_SWIFT_TYPE) + else() + get_target_property(type ${target} SWIFT_TYPE) + endif() + if(NOT ${type} IN_LIST x_SWIFT_TYPES) continue() endif() endif() if(x_ONLY_THIS_REPO) - get_target_property(target_dir ${target} SOURCE_DIR) + if (type STREQUAL "INTERFACE_LIBRARY") + get_target_property(target_dir ${target} INTERFACE_SOURCE_DIR) + else() + get_target_property(target_dir ${target} SOURCE_DIR) + endif() + # This replacement makes sure that we only filter out third_party subdirectories which actually exist in the root project source dir - ie, a git repo cloned in to a path # which just so happens to contain third_party should not break this function string(REPLACE ${CMAKE_SOURCE_DIR} "" target_dir ${target_dir}) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index 517eb09..78c7ca9 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -10,8 +10,7 @@ # WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. # -include(SwiftTargets) # expects global properties SWIFT_EXECUTABLE_TARGETS and SWIFT_LIBRARY_TARGETS to be defined -include(TestTargets) # expects global properties SWIFT_TEST_TARGETS, SWIFT_UNIT_TEST_TARGETS and SWIFT_INTEGRATION_TEST_TARGETS to be defined +include(ListTargets) set(_sonarcloud_newline "\\\n ") @@ -148,14 +147,22 @@ function(generate_sonarcloud_project_properties sonarcloud_project_properties_pa return() endif() - get_property(swift_executable_targets GLOBAL PROPERTY SWIFT_EXECUTABLE_TARGETS) - get_property(swift_library_targets GLOBAL PROPERTY SWIFT_LIBRARY_TARGETS) - get_property(swift_test_targets GLOBAL PROPERTY SWIFT_TEST_TARGETS) - get_property(swift_unit_test_targets GLOBAL PROPERTY SWIFT_UNIT_TEST_TARGETS) - get_property(swift_integration_test_targets GLOBAL PROPERTY SWIFT_INTEGRATION_TEST_TARGETS) + swift_list_targets(source_targets + ONLY_THIS_REPO + SWIFT_TYPES + executable + library + ) + + swift_list_targets(test_targets + ONLY_THIS_REPO + SWIFT_TYPES + test + test_library + ) - extract_sonarcloud_project_files(source_source_files source_include_directories ${swift_executable_targets} ${swift_library_targets}) - extract_sonarcloud_project_files(test_source_files test_include_directories ${swift_test_targets} ${swift_unit_test_targets} ${swift_integration_test_targets}) + extract_sonarcloud_project_files(source_source_files source_include_directories ${source_targets}) + extract_sonarcloud_project_files(test_source_files test_include_directories ${test_targets}) set(sonarcloud_project_properties_content "sonar.sourceEncoding=UTF-8\n") diff --git a/SwiftTargets.cmake b/SwiftTargets.cmake index 59b8891..1d4f2b4 100644 --- a/SwiftTargets.cmake +++ b/SwiftTargets.cmake @@ -176,6 +176,12 @@ define_property(TARGET BRIEF_DOCS "Swift test type" FULL_DOCS "When target's SWIFT_PROJECT property is \"test\", this option, if set, will identify what type of test it is. Currently support \"unit\" or \"integration\"") +define_property(TARGET + PROPERTY INTERFACE_SOURCE_DIR + BRIEF_DOCS "Target's source directory" + FULL_DOCS "Identical use as SOURCE_DIR except that this applies to ALL target types, including INTERFACE") + + macro(swift_collate_arguments prefix name) set(exclusion_list ${ARGN}) set(${name}_args "") @@ -324,6 +330,7 @@ function(swift_add_target target type) PROPERTIES INTERFACE_SWIFT_PROJECT ${PROJECT_NAME} INTERFACE_SWIFT_TYPE ${type} + INTERFACE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) if (NOT x_INTERFACE) From 24bf5da8bbf20efc86c0094a430bf49c57123638 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Fri, 13 May 2022 21:17:18 +1000 Subject: [PATCH 19/23] update --- Sonarcloud.cmake | 19 +++++-------------- SwiftTargets.cmake | 1 - 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index 78c7ca9..094305a 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -17,9 +17,9 @@ set(_sonarcloud_newline "\\\n ") function(transform_sonarcloud_source_files output_variable target) # # Based off of https://cmake.org/cmake/help/latest/prop_tgt/SOURCES.html we - # need to correcty interpret the SOURCES properties to be able to transform - # them into what sonarcloud project properties is comfortable with (ie. paths - # from project source directory + # need to correctly interpret the SOURCES properties to be able to transform + # them into what sonarcloud project properties is comfortable with (ie. + # relative path from project source directory). # get_target_property(target_binary_dir ${target} BUILD_DIR) get_target_property(target_source_dir ${target} SOURCE_DIR) @@ -85,17 +85,8 @@ function(extract_sonarcloud_project_files output_project_source_files output_pro foreach (target IN LISTS ARGN) get_target_property(target_type ${target} TYPE) - if (${target_type} STREQUAL "INTERFACE_LIBRARY") - get_target_property(swift_project ${target} INTERFACE_SWIFT_PROJECT) - else() - get_target_property(swift_project ${target} SWIFT_PROJECT) - endif() - - if(NOT ${swift_project} STREQUAL ${PROJECT_NAME}) - continue() - endif() - if (NOT ${target_type} STREQUAL "INTERFACE_LIBRARY") + if (NOT target_type STREQUAL "INTERFACE_LIBRARY") get_target_property(target_source_files ${target} SOURCES) if (target_source_files) transform_sonarcloud_source_files(target_source_files ${target} ${target_source_files}) @@ -140,7 +131,7 @@ endfunction() function(generate_sonarcloud_project_properties sonarcloud_project_properties_path) if (NOT IS_ABSOLUTE ${sonarcloud_project_properties_path}) message(FATAL_ERROR "Function \"generate_sonarcloud_project_properties\"" - "only accepts sonarcloud project properties output as absolute paths") + "only accepts absolute paths to avoid ambiguity") endif() if (NOT ${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/SwiftTargets.cmake b/SwiftTargets.cmake index 1d4f2b4..54505e5 100644 --- a/SwiftTargets.cmake +++ b/SwiftTargets.cmake @@ -181,7 +181,6 @@ define_property(TARGET BRIEF_DOCS "Target's source directory" FULL_DOCS "Identical use as SOURCE_DIR except that this applies to ALL target types, including INTERFACE") - macro(swift_collate_arguments prefix name) set(exclusion_list ${ARGN}) set(${name}_args "") From b4c3eec82a8e8e3044932f96426ebd0fddadaeef Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Fri, 13 May 2022 21:47:05 +1000 Subject: [PATCH 20/23] fix up --- ListTargets.cmake | 6 +++--- Sonarcloud.cmake | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ListTargets.cmake b/ListTargets.cmake index 6e10b4e..cd360e9 100644 --- a/ListTargets.cmake +++ b/ListTargets.cmake @@ -79,12 +79,12 @@ function(swift_list_targets out_var) if(x_SWIFT_TYPES) if (type STREQUAL "INTERFACE_LIBRARY") - get_target_property(type ${target} INTERFACE_SWIFT_TYPE) + get_target_property(swift_type ${target} INTERFACE_SWIFT_TYPE) else() - get_target_property(type ${target} SWIFT_TYPE) + get_target_property(swift_type ${target} SWIFT_TYPE) endif() - if(NOT ${type} IN_LIST x_SWIFT_TYPES) + if(NOT ${swift_type} IN_LIST x_SWIFT_TYPES) continue() endif() endif() diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index 094305a..a343f68 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -86,6 +86,9 @@ function(extract_sonarcloud_project_files output_project_source_files output_pro foreach (target IN LISTS ARGN) get_target_property(target_type ${target} TYPE) + unset(target_source_files) + unset(target_include_directories) + if (NOT target_type STREQUAL "INTERFACE_LIBRARY") get_target_property(target_source_files ${target} SOURCES) if (target_source_files) From 3df95d0fe4c0e11babee655bed5bc77c61d260c7 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Mon, 16 May 2022 10:03:53 +1000 Subject: [PATCH 21/23] documentation and scoping --- Sonarcloud.cmake | 56 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index a343f68..0c240e5 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -10,11 +10,51 @@ # WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. # +# +# OVERVIEW +# ======== +# +# Offers a way to generate the necessary Sonarcloud project file from the +# information available via cmake build system. User can call on +# "generate_sonarcloud_project_properties" to produce this project file which +# outlines to Sonarcloud what files/directories are deemed source files and +# which files are test files. +# +# This module will work in conjunction with "TestTargets" and "SwiftTargets", +# and "ListTargets" to identify all Swift production source/test code through. +# This means that only targets created via "swift_add_*" functions that are +# categorized as "production" code will be included in the analysis. No other +# none C/C++ source code will be included in the Sonarcloud project properties +# file (at the moment). +# +# USAGE +# ===== +# +# To generate the Sonarcloud project file, simply call the following method at +# the end of your projects CMakeLists.txt file: +# +# generate_sonarcloud_project_properties(${CMAKE_BINARY_DIR}/sonar-project.properties) +# +# This will generate a sonar project file in your root build directory (please +# don't ever write this to your source directory). Prior to uploading the +# results to Sonarcloud, you will need to manually transform all absolute path +# references to relative paths. This manual step can be done easily with the +# following Linux command: +# +# sed -i -E "s|^(\s+)(${PWD}/)|\1|g" 'sonar-project.properties' +# +# The reason why this extra step is required and was not taken care by cmake, +# is because targets have generator expressions to them which can only be +# evaluated at the end of the configuration stage. At that point there is no +# find/replace functionality. +# + + include(ListTargets) set(_sonarcloud_newline "\\\n ") -function(transform_sonarcloud_source_files output_variable target) +function(_transform_sonarcloud_source_files output_variable target) # # Based off of https://cmake.org/cmake/help/latest/prop_tgt/SOURCES.html we # need to correctly interpret the SOURCES properties to be able to transform @@ -54,7 +94,7 @@ function(transform_sonarcloud_source_files output_variable target) set(${output_variable} ${source_files} PARENT_SCOPE) endfunction() -function(transform_sonarcloud_include_directories output_variable target) +function(_transform_sonarcloud_include_directories output_variable target) unset(include_directories) foreach (include_directory IN LISTS ARGN) @@ -79,7 +119,7 @@ function(transform_sonarcloud_include_directories output_variable target) set(${output_variable} ${include_directories} PARENT_SCOPE) endfunction() -function(extract_sonarcloud_project_files output_project_source_files output_project_include_directories) +function(_extract_sonarcloud_project_files output_project_source_files output_project_include_directories) unset(project_source_files) unset(project_include_directories) @@ -92,14 +132,14 @@ function(extract_sonarcloud_project_files output_project_source_files output_pro if (NOT target_type STREQUAL "INTERFACE_LIBRARY") get_target_property(target_source_files ${target} SOURCES) if (target_source_files) - transform_sonarcloud_source_files(target_source_files ${target} ${target_source_files}) + _transform_sonarcloud_source_files(target_source_files ${target} ${target_source_files}) else() unset(target_source_files) endif() get_target_property(target_include_directories ${target} INCLUDE_DIRECTORIES) if (target_include_directories) - transform_sonarcloud_include_directories(target_include_directories ${target} ${target_include_directories}) + _transform_sonarcloud_include_directories(target_include_directories ${target} ${target_include_directories}) else() unset(target_include_directories) endif() @@ -107,7 +147,7 @@ function(extract_sonarcloud_project_files output_project_source_files output_pro get_target_property(target_interface_include_directories ${target} INTERFACE_INCLUDE_DIRECTORIES) if (target_interface_include_directories) - transform_sonarcloud_include_directories(target_interface_include_directories ${target} ${target_interface_include_directories}) + _transform_sonarcloud_include_directories(target_interface_include_directories ${target} ${target_interface_include_directories}) else() unset(target_interface_include_directories) endif() @@ -155,8 +195,8 @@ function(generate_sonarcloud_project_properties sonarcloud_project_properties_pa test_library ) - extract_sonarcloud_project_files(source_source_files source_include_directories ${source_targets}) - extract_sonarcloud_project_files(test_source_files test_include_directories ${test_targets}) + _extract_sonarcloud_project_files(source_source_files source_include_directories ${source_targets}) + _extract_sonarcloud_project_files(test_source_files test_include_directories ${test_targets}) set(sonarcloud_project_properties_content "sonar.sourceEncoding=UTF-8\n") From bd65687445d9c4be8be7e3135e9215c39285fd88 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Mon, 16 May 2022 10:06:54 +1000 Subject: [PATCH 22/23] nit --- Sonarcloud.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/Sonarcloud.cmake b/Sonarcloud.cmake index 0c240e5..5fba790 100644 --- a/Sonarcloud.cmake +++ b/Sonarcloud.cmake @@ -49,7 +49,6 @@ # find/replace functionality. # - include(ListTargets) set(_sonarcloud_newline "\\\n ") From 0256b61e639f129ce41e3091087701c540cb46c0 Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Mon, 16 May 2022 10:48:51 +1000 Subject: [PATCH 23/23] documentation --- SwiftTargets.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SwiftTargets.cmake b/SwiftTargets.cmake index 54505e5..4d4a1b9 100644 --- a/SwiftTargets.cmake +++ b/SwiftTargets.cmake @@ -115,6 +115,9 @@ # C_EXTENSIONS_ON: C extensions are disabled by default, adding this keyword # enables C extensions. # +# SKIP_COMPILE_OPTIONS: will forgo invoking the swift_set_compile_options on +# the target. +# # SINGLE VALUE KEYWORDS # # C_STANDARD: allow uses to override the default C standard used in a target,