From 819176b6c4dc3dc6fe872f18db1bb202555f2849 Mon Sep 17 00:00:00 2001 From: Kevin W Matthews Date: Mon, 24 Jun 2019 08:39:56 -0700 Subject: [PATCH 1/3] Add newlines at EOF to CMakeLists.txt files --- exercises/armstrong-numbers/CMakeLists.txt | 2 +- exercises/circular-buffer/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/armstrong-numbers/CMakeLists.txt b/exercises/armstrong-numbers/CMakeLists.txt index 0bd718df..fdb4d1db 100644 --- a/exercises/armstrong-numbers/CMakeLists.txt +++ b/exercises/armstrong-numbers/CMakeLists.txt @@ -50,4 +50,4 @@ if(${MSVC}) endif() # Run the tests on every build -add_custom_target(test_${exercise} ALL DEPENDS ${exercise} COMMAND ${exercise}) \ No newline at end of file +add_custom_target(test_${exercise} ALL DEPENDS ${exercise} COMMAND ${exercise}) diff --git a/exercises/circular-buffer/CMakeLists.txt b/exercises/circular-buffer/CMakeLists.txt index 0bd718df..fdb4d1db 100644 --- a/exercises/circular-buffer/CMakeLists.txt +++ b/exercises/circular-buffer/CMakeLists.txt @@ -50,4 +50,4 @@ if(${MSVC}) endif() # Run the tests on every build -add_custom_target(test_${exercise} ALL DEPENDS ${exercise} COMMAND ${exercise}) \ No newline at end of file +add_custom_target(test_${exercise} ALL DEPENDS ${exercise} COMMAND ${exercise}) From 186c9ceb65d11ebd30f0575e9554618dd4b2f05c Mon Sep 17 00:00:00 2001 From: Kevin W Matthews Date: Mon, 24 Jun 2019 08:41:58 -0700 Subject: [PATCH 2/3] Add address sanitizer option to each exercise --- exercises/acronym/CMakeLists.txt | 10 ++++++++++ exercises/all-your-base/CMakeLists.txt | 10 ++++++++++ exercises/allergies/CMakeLists.txt | 10 ++++++++++ exercises/anagram/CMakeLists.txt | 10 ++++++++++ exercises/armstrong-numbers/CMakeLists.txt | 10 ++++++++++ exercises/atbash-cipher/CMakeLists.txt | 10 ++++++++++ exercises/beer-song/CMakeLists.txt | 10 ++++++++++ exercises/binary-search-tree/CMakeLists.txt | 10 ++++++++++ exercises/binary-search/CMakeLists.txt | 10 ++++++++++ exercises/binary/CMakeLists.txt | 10 ++++++++++ exercises/bob/CMakeLists.txt | 10 ++++++++++ exercises/circular-buffer/CMakeLists.txt | 10 ++++++++++ exercises/clock/CMakeLists.txt | 10 ++++++++++ exercises/crypto-square/CMakeLists.txt | 10 ++++++++++ exercises/difference-of-squares/CMakeLists.txt | 10 ++++++++++ exercises/etl/CMakeLists.txt | 10 ++++++++++ exercises/food-chain/CMakeLists.txt | 10 ++++++++++ exercises/gigasecond/CMakeLists.txt | 10 ++++++++++ exercises/grade-school/CMakeLists.txt | 10 ++++++++++ exercises/grains/CMakeLists.txt | 10 ++++++++++ exercises/hamming/CMakeLists.txt | 10 ++++++++++ exercises/hello-world/CMakeLists.txt | 10 ++++++++++ exercises/hexadecimal/CMakeLists.txt | 10 ++++++++++ exercises/isogram/CMakeLists.txt | 10 ++++++++++ exercises/leap/CMakeLists.txt | 10 ++++++++++ exercises/luhn/CMakeLists.txt | 10 ++++++++++ exercises/matching-brackets/CMakeLists.txt | 10 ++++++++++ exercises/meetup/CMakeLists.txt | 10 ++++++++++ exercises/nth-prime/CMakeLists.txt | 10 ++++++++++ exercises/nucleotide-count/CMakeLists.txt | 10 ++++++++++ exercises/pangram/CMakeLists.txt | 10 ++++++++++ exercises/pascals-triangle/CMakeLists.txt | 10 ++++++++++ exercises/phone-number/CMakeLists.txt | 10 ++++++++++ exercises/prime-factors/CMakeLists.txt | 10 ++++++++++ exercises/queen-attack/CMakeLists.txt | 10 ++++++++++ exercises/raindrops/CMakeLists.txt | 10 ++++++++++ exercises/reverse-string/CMakeLists.txt | 10 ++++++++++ exercises/rna-transcription/CMakeLists.txt | 10 ++++++++++ exercises/robot-name/CMakeLists.txt | 10 ++++++++++ exercises/robot-simulator/CMakeLists.txt | 10 ++++++++++ exercises/roman-numerals/CMakeLists.txt | 10 ++++++++++ exercises/say/CMakeLists.txt | 10 ++++++++++ exercises/scrabble-score/CMakeLists.txt | 10 ++++++++++ exercises/series/CMakeLists.txt | 10 ++++++++++ exercises/sieve/CMakeLists.txt | 10 ++++++++++ exercises/space-age/CMakeLists.txt | 10 ++++++++++ exercises/sum-of-multiples/CMakeLists.txt | 10 ++++++++++ exercises/triangle/CMakeLists.txt | 10 ++++++++++ exercises/trinary/CMakeLists.txt | 10 ++++++++++ exercises/word-count/CMakeLists.txt | 10 ++++++++++ 50 files changed, 500 insertions(+) diff --git a/exercises/acronym/CMakeLists.txt b/exercises/acronym/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/acronym/CMakeLists.txt +++ b/exercises/acronym/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/all-your-base/CMakeLists.txt b/exercises/all-your-base/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/all-your-base/CMakeLists.txt +++ b/exercises/all-your-base/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/allergies/CMakeLists.txt b/exercises/allergies/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/allergies/CMakeLists.txt +++ b/exercises/allergies/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/anagram/CMakeLists.txt b/exercises/anagram/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/anagram/CMakeLists.txt +++ b/exercises/anagram/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/armstrong-numbers/CMakeLists.txt b/exercises/armstrong-numbers/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/armstrong-numbers/CMakeLists.txt +++ b/exercises/armstrong-numbers/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/atbash-cipher/CMakeLists.txt b/exercises/atbash-cipher/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/atbash-cipher/CMakeLists.txt +++ b/exercises/atbash-cipher/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/beer-song/CMakeLists.txt b/exercises/beer-song/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/beer-song/CMakeLists.txt +++ b/exercises/beer-song/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/binary-search-tree/CMakeLists.txt b/exercises/binary-search-tree/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/binary-search-tree/CMakeLists.txt +++ b/exercises/binary-search-tree/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/binary-search/CMakeLists.txt b/exercises/binary-search/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/binary-search/CMakeLists.txt +++ b/exercises/binary-search/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/binary/CMakeLists.txt b/exercises/binary/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/binary/CMakeLists.txt +++ b/exercises/binary/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/bob/CMakeLists.txt b/exercises/bob/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/bob/CMakeLists.txt +++ b/exercises/bob/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/circular-buffer/CMakeLists.txt b/exercises/circular-buffer/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/circular-buffer/CMakeLists.txt +++ b/exercises/circular-buffer/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/clock/CMakeLists.txt b/exercises/clock/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/clock/CMakeLists.txt +++ b/exercises/clock/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/crypto-square/CMakeLists.txt b/exercises/crypto-square/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/crypto-square/CMakeLists.txt +++ b/exercises/crypto-square/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/difference-of-squares/CMakeLists.txt b/exercises/difference-of-squares/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/difference-of-squares/CMakeLists.txt +++ b/exercises/difference-of-squares/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/etl/CMakeLists.txt b/exercises/etl/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/etl/CMakeLists.txt +++ b/exercises/etl/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/food-chain/CMakeLists.txt b/exercises/food-chain/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/food-chain/CMakeLists.txt +++ b/exercises/food-chain/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/gigasecond/CMakeLists.txt b/exercises/gigasecond/CMakeLists.txt index 2da5293b..de3a5a5c 100644 --- a/exercises/gigasecond/CMakeLists.txt +++ b/exercises/gigasecond/CMakeLists.txt @@ -13,6 +13,10 @@ set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) find_package(Boost 1.59 REQUIRED COMPONENTS date_time) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -38,6 +42,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/grade-school/CMakeLists.txt b/exercises/grade-school/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/grade-school/CMakeLists.txt +++ b/exercises/grade-school/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/grains/CMakeLists.txt b/exercises/grains/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/grains/CMakeLists.txt +++ b/exercises/grains/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/hamming/CMakeLists.txt b/exercises/hamming/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/hamming/CMakeLists.txt +++ b/exercises/hamming/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/hello-world/CMakeLists.txt b/exercises/hello-world/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/hello-world/CMakeLists.txt +++ b/exercises/hello-world/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/hexadecimal/CMakeLists.txt b/exercises/hexadecimal/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/hexadecimal/CMakeLists.txt +++ b/exercises/hexadecimal/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/isogram/CMakeLists.txt b/exercises/isogram/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/isogram/CMakeLists.txt +++ b/exercises/isogram/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/leap/CMakeLists.txt b/exercises/leap/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/leap/CMakeLists.txt +++ b/exercises/leap/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/luhn/CMakeLists.txt b/exercises/luhn/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/luhn/CMakeLists.txt +++ b/exercises/luhn/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/matching-brackets/CMakeLists.txt b/exercises/matching-brackets/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/matching-brackets/CMakeLists.txt +++ b/exercises/matching-brackets/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/meetup/CMakeLists.txt b/exercises/meetup/CMakeLists.txt index 2da5293b..de3a5a5c 100644 --- a/exercises/meetup/CMakeLists.txt +++ b/exercises/meetup/CMakeLists.txt @@ -13,6 +13,10 @@ set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) find_package(Boost 1.59 REQUIRED COMPONENTS date_time) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -38,6 +42,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/nth-prime/CMakeLists.txt b/exercises/nth-prime/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/nth-prime/CMakeLists.txt +++ b/exercises/nth-prime/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/nucleotide-count/CMakeLists.txt b/exercises/nucleotide-count/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/nucleotide-count/CMakeLists.txt +++ b/exercises/nucleotide-count/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/pangram/CMakeLists.txt b/exercises/pangram/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/pangram/CMakeLists.txt +++ b/exercises/pangram/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/pascals-triangle/CMakeLists.txt b/exercises/pascals-triangle/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/pascals-triangle/CMakeLists.txt +++ b/exercises/pascals-triangle/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/phone-number/CMakeLists.txt b/exercises/phone-number/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/phone-number/CMakeLists.txt +++ b/exercises/phone-number/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/prime-factors/CMakeLists.txt b/exercises/prime-factors/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/prime-factors/CMakeLists.txt +++ b/exercises/prime-factors/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/queen-attack/CMakeLists.txt b/exercises/queen-attack/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/queen-attack/CMakeLists.txt +++ b/exercises/queen-attack/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/raindrops/CMakeLists.txt b/exercises/raindrops/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/raindrops/CMakeLists.txt +++ b/exercises/raindrops/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/reverse-string/CMakeLists.txt b/exercises/reverse-string/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/reverse-string/CMakeLists.txt +++ b/exercises/reverse-string/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/rna-transcription/CMakeLists.txt b/exercises/rna-transcription/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/rna-transcription/CMakeLists.txt +++ b/exercises/rna-transcription/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/robot-name/CMakeLists.txt b/exercises/robot-name/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/robot-name/CMakeLists.txt +++ b/exercises/robot-name/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/robot-simulator/CMakeLists.txt b/exercises/robot-simulator/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/robot-simulator/CMakeLists.txt +++ b/exercises/robot-simulator/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/roman-numerals/CMakeLists.txt b/exercises/roman-numerals/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/roman-numerals/CMakeLists.txt +++ b/exercises/roman-numerals/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/say/CMakeLists.txt b/exercises/say/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/say/CMakeLists.txt +++ b/exercises/say/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/scrabble-score/CMakeLists.txt b/exercises/scrabble-score/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/scrabble-score/CMakeLists.txt +++ b/exercises/scrabble-score/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/series/CMakeLists.txt b/exercises/series/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/series/CMakeLists.txt +++ b/exercises/series/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/sieve/CMakeLists.txt b/exercises/sieve/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/sieve/CMakeLists.txt +++ b/exercises/sieve/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/space-age/CMakeLists.txt b/exercises/space-age/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/space-age/CMakeLists.txt +++ b/exercises/space-age/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/sum-of-multiples/CMakeLists.txt b/exercises/sum-of-multiples/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/sum-of-multiples/CMakeLists.txt +++ b/exercises/sum-of-multiples/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/triangle/CMakeLists.txt b/exercises/triangle/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/triangle/CMakeLists.txt +++ b/exercises/triangle/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/trinary/CMakeLists.txt b/exercises/trinary/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/trinary/CMakeLists.txt +++ b/exercises/trinary/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/word-count/CMakeLists.txt b/exercises/word-count/CMakeLists.txt index fdb4d1db..c5346c9f 100644 --- a/exercises/word-count/CMakeLists.txt +++ b/exercises/word-count/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.1.3) # Name the project after the exercise project(${exercise} CXX) +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) +endif() + # Get a source filename from the exercise name by replacing -'s with _'s string(REPLACE "-" "_" file ${exercise}) @@ -32,6 +36,12 @@ set_target_properties(${exercise} PROPERTIES CXX_EXTENSIONS OFF ) +if(ENABLE_ASAN) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Debug") + target_compile_options(${exercise} PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer" "-O1") + target_link_libraries(${exercise} PRIVATE "-fsanitize=address") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" From 055a56ad19e6cf585f574edb5804c761cd559b07 Mon Sep 17 00:00:00 2001 From: Kevin W Matthews Date: Mon, 24 Jun 2019 08:43:05 -0700 Subject: [PATCH 3/3] Add undefined behavior sanitizer to each exercise --- exercises/acronym/CMakeLists.txt | 6 ++++++ exercises/all-your-base/CMakeLists.txt | 6 ++++++ exercises/allergies/CMakeLists.txt | 6 ++++++ exercises/anagram/CMakeLists.txt | 6 ++++++ exercises/armstrong-numbers/CMakeLists.txt | 6 ++++++ exercises/atbash-cipher/CMakeLists.txt | 6 ++++++ exercises/beer-song/CMakeLists.txt | 6 ++++++ exercises/binary-search-tree/CMakeLists.txt | 6 ++++++ exercises/binary-search/CMakeLists.txt | 6 ++++++ exercises/binary/CMakeLists.txt | 6 ++++++ exercises/bob/CMakeLists.txt | 6 ++++++ exercises/circular-buffer/CMakeLists.txt | 6 ++++++ exercises/clock/CMakeLists.txt | 6 ++++++ exercises/crypto-square/CMakeLists.txt | 6 ++++++ exercises/difference-of-squares/CMakeLists.txt | 6 ++++++ exercises/etl/CMakeLists.txt | 6 ++++++ exercises/food-chain/CMakeLists.txt | 6 ++++++ exercises/gigasecond/CMakeLists.txt | 6 ++++++ exercises/grade-school/CMakeLists.txt | 6 ++++++ exercises/grains/CMakeLists.txt | 6 ++++++ exercises/hamming/CMakeLists.txt | 6 ++++++ exercises/hello-world/CMakeLists.txt | 6 ++++++ exercises/hexadecimal/CMakeLists.txt | 6 ++++++ exercises/isogram/CMakeLists.txt | 6 ++++++ exercises/leap/CMakeLists.txt | 6 ++++++ exercises/luhn/CMakeLists.txt | 6 ++++++ exercises/matching-brackets/CMakeLists.txt | 6 ++++++ exercises/meetup/CMakeLists.txt | 6 ++++++ exercises/nth-prime/CMakeLists.txt | 6 ++++++ exercises/nucleotide-count/CMakeLists.txt | 6 ++++++ exercises/pangram/CMakeLists.txt | 6 ++++++ exercises/pascals-triangle/CMakeLists.txt | 6 ++++++ exercises/phone-number/CMakeLists.txt | 6 ++++++ exercises/prime-factors/CMakeLists.txt | 6 ++++++ exercises/queen-attack/CMakeLists.txt | 6 ++++++ exercises/raindrops/CMakeLists.txt | 6 ++++++ exercises/reverse-string/CMakeLists.txt | 6 ++++++ exercises/rna-transcription/CMakeLists.txt | 6 ++++++ exercises/robot-name/CMakeLists.txt | 6 ++++++ exercises/robot-simulator/CMakeLists.txt | 6 ++++++ exercises/roman-numerals/CMakeLists.txt | 6 ++++++ exercises/say/CMakeLists.txt | 6 ++++++ exercises/scrabble-score/CMakeLists.txt | 6 ++++++ exercises/series/CMakeLists.txt | 6 ++++++ exercises/sieve/CMakeLists.txt | 6 ++++++ exercises/space-age/CMakeLists.txt | 6 ++++++ exercises/sum-of-multiples/CMakeLists.txt | 6 ++++++ exercises/triangle/CMakeLists.txt | 6 ++++++ exercises/trinary/CMakeLists.txt | 6 ++++++ exercises/word-count/CMakeLists.txt | 6 ++++++ 50 files changed, 300 insertions(+) diff --git a/exercises/acronym/CMakeLists.txt b/exercises/acronym/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/acronym/CMakeLists.txt +++ b/exercises/acronym/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/all-your-base/CMakeLists.txt b/exercises/all-your-base/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/all-your-base/CMakeLists.txt +++ b/exercises/all-your-base/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/allergies/CMakeLists.txt b/exercises/allergies/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/allergies/CMakeLists.txt +++ b/exercises/allergies/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/anagram/CMakeLists.txt b/exercises/anagram/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/anagram/CMakeLists.txt +++ b/exercises/anagram/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/armstrong-numbers/CMakeLists.txt b/exercises/armstrong-numbers/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/armstrong-numbers/CMakeLists.txt +++ b/exercises/armstrong-numbers/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/atbash-cipher/CMakeLists.txt b/exercises/atbash-cipher/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/atbash-cipher/CMakeLists.txt +++ b/exercises/atbash-cipher/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/beer-song/CMakeLists.txt b/exercises/beer-song/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/beer-song/CMakeLists.txt +++ b/exercises/beer-song/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/binary-search-tree/CMakeLists.txt b/exercises/binary-search-tree/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/binary-search-tree/CMakeLists.txt +++ b/exercises/binary-search-tree/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/binary-search/CMakeLists.txt b/exercises/binary-search/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/binary-search/CMakeLists.txt +++ b/exercises/binary-search/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/binary/CMakeLists.txt b/exercises/binary/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/binary/CMakeLists.txt +++ b/exercises/binary/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/bob/CMakeLists.txt b/exercises/bob/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/bob/CMakeLists.txt +++ b/exercises/bob/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/circular-buffer/CMakeLists.txt b/exercises/circular-buffer/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/circular-buffer/CMakeLists.txt +++ b/exercises/circular-buffer/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/clock/CMakeLists.txt b/exercises/clock/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/clock/CMakeLists.txt +++ b/exercises/clock/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/crypto-square/CMakeLists.txt b/exercises/crypto-square/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/crypto-square/CMakeLists.txt +++ b/exercises/crypto-square/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/difference-of-squares/CMakeLists.txt b/exercises/difference-of-squares/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/difference-of-squares/CMakeLists.txt +++ b/exercises/difference-of-squares/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/etl/CMakeLists.txt b/exercises/etl/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/etl/CMakeLists.txt +++ b/exercises/etl/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/food-chain/CMakeLists.txt b/exercises/food-chain/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/food-chain/CMakeLists.txt +++ b/exercises/food-chain/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/gigasecond/CMakeLists.txt b/exercises/gigasecond/CMakeLists.txt index de3a5a5c..c7f12b17 100644 --- a/exercises/gigasecond/CMakeLists.txt +++ b/exercises/gigasecond/CMakeLists.txt @@ -15,6 +15,7 @@ find_package(Boost 1.59 REQUIRED COMPONENTS date_time) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -48,6 +49,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/grade-school/CMakeLists.txt b/exercises/grade-school/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/grade-school/CMakeLists.txt +++ b/exercises/grade-school/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/grains/CMakeLists.txt b/exercises/grains/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/grains/CMakeLists.txt +++ b/exercises/grains/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/hamming/CMakeLists.txt b/exercises/hamming/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/hamming/CMakeLists.txt +++ b/exercises/hamming/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/hello-world/CMakeLists.txt b/exercises/hello-world/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/hello-world/CMakeLists.txt +++ b/exercises/hello-world/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/hexadecimal/CMakeLists.txt b/exercises/hexadecimal/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/hexadecimal/CMakeLists.txt +++ b/exercises/hexadecimal/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/isogram/CMakeLists.txt b/exercises/isogram/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/isogram/CMakeLists.txt +++ b/exercises/isogram/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/leap/CMakeLists.txt b/exercises/leap/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/leap/CMakeLists.txt +++ b/exercises/leap/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/luhn/CMakeLists.txt b/exercises/luhn/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/luhn/CMakeLists.txt +++ b/exercises/luhn/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/matching-brackets/CMakeLists.txt b/exercises/matching-brackets/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/matching-brackets/CMakeLists.txt +++ b/exercises/matching-brackets/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/meetup/CMakeLists.txt b/exercises/meetup/CMakeLists.txt index de3a5a5c..c7f12b17 100644 --- a/exercises/meetup/CMakeLists.txt +++ b/exercises/meetup/CMakeLists.txt @@ -15,6 +15,7 @@ find_package(Boost 1.59 REQUIRED COMPONENTS date_time) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -48,6 +49,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/nth-prime/CMakeLists.txt b/exercises/nth-prime/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/nth-prime/CMakeLists.txt +++ b/exercises/nth-prime/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/nucleotide-count/CMakeLists.txt b/exercises/nucleotide-count/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/nucleotide-count/CMakeLists.txt +++ b/exercises/nucleotide-count/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/pangram/CMakeLists.txt b/exercises/pangram/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/pangram/CMakeLists.txt +++ b/exercises/pangram/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/pascals-triangle/CMakeLists.txt b/exercises/pascals-triangle/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/pascals-triangle/CMakeLists.txt +++ b/exercises/pascals-triangle/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/phone-number/CMakeLists.txt b/exercises/phone-number/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/phone-number/CMakeLists.txt +++ b/exercises/phone-number/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/prime-factors/CMakeLists.txt b/exercises/prime-factors/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/prime-factors/CMakeLists.txt +++ b/exercises/prime-factors/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/queen-attack/CMakeLists.txt b/exercises/queen-attack/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/queen-attack/CMakeLists.txt +++ b/exercises/queen-attack/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/raindrops/CMakeLists.txt b/exercises/raindrops/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/raindrops/CMakeLists.txt +++ b/exercises/raindrops/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/reverse-string/CMakeLists.txt b/exercises/reverse-string/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/reverse-string/CMakeLists.txt +++ b/exercises/reverse-string/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/rna-transcription/CMakeLists.txt b/exercises/rna-transcription/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/rna-transcription/CMakeLists.txt +++ b/exercises/rna-transcription/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/robot-name/CMakeLists.txt b/exercises/robot-name/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/robot-name/CMakeLists.txt +++ b/exercises/robot-name/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/robot-simulator/CMakeLists.txt b/exercises/robot-simulator/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/robot-simulator/CMakeLists.txt +++ b/exercises/robot-simulator/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/roman-numerals/CMakeLists.txt b/exercises/roman-numerals/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/roman-numerals/CMakeLists.txt +++ b/exercises/roman-numerals/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/say/CMakeLists.txt b/exercises/say/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/say/CMakeLists.txt +++ b/exercises/say/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/scrabble-score/CMakeLists.txt b/exercises/scrabble-score/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/scrabble-score/CMakeLists.txt +++ b/exercises/scrabble-score/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/series/CMakeLists.txt b/exercises/series/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/series/CMakeLists.txt +++ b/exercises/series/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/sieve/CMakeLists.txt b/exercises/sieve/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/sieve/CMakeLists.txt +++ b/exercises/sieve/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/space-age/CMakeLists.txt b/exercises/space-age/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/space-age/CMakeLists.txt +++ b/exercises/space-age/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/sum-of-multiples/CMakeLists.txt b/exercises/sum-of-multiples/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/sum-of-multiples/CMakeLists.txt +++ b/exercises/sum-of-multiples/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/triangle/CMakeLists.txt b/exercises/triangle/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/triangle/CMakeLists.txt +++ b/exercises/triangle/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/trinary/CMakeLists.txt b/exercises/trinary/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/trinary/CMakeLists.txt +++ b/exercises/trinary/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" diff --git a/exercises/word-count/CMakeLists.txt b/exercises/word-count/CMakeLists.txt index c5346c9f..cd7ef925 100644 --- a/exercises/word-count/CMakeLists.txt +++ b/exercises/word-count/CMakeLists.txt @@ -9,6 +9,7 @@ project(${exercise} CXX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") option(ENABLE_ASAN "Enable compiler's built-in address sanitizer" OFF) + option(ENABLE_UBSAN "Enable compiler's built-in undefined behavior sanitizer" OFF) endif() # Get a source filename from the exercise name by replacing -'s with _'s @@ -42,6 +43,11 @@ if(ENABLE_ASAN) target_link_libraries(${exercise} PRIVATE "-fsanitize=address") endif() +if(ENABLE_UBSAN) + target_compile_options(${exercise} PRIVATE "-fsanitize=undefined") + target_link_libraries(${exercise} PRIVATE "-fsanitize=undefined") +endif() + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") set_target_properties(${exercise} PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror"