Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions exercises/acronym/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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)
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
string(REPLACE "-" "_" file ${exercise})

Expand All @@ -32,6 +37,17 @@ 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(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"
Expand Down
16 changes: 16 additions & 0 deletions exercises/all-your-base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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)
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
string(REPLACE "-" "_" file ${exercise})

Expand All @@ -32,6 +37,17 @@ 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(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"
Expand Down
16 changes: 16 additions & 0 deletions exercises/allergies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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)
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
string(REPLACE "-" "_" file ${exercise})

Expand All @@ -32,6 +37,17 @@ 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(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"
Expand Down
16 changes: 16 additions & 0 deletions exercises/anagram/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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)
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
string(REPLACE "-" "_" file ${exercise})

Expand All @@ -32,6 +37,17 @@ 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(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"
Expand Down
18 changes: 17 additions & 1 deletion exercises/armstrong-numbers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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)
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
string(REPLACE "-" "_" file ${exercise})

Expand All @@ -32,6 +37,17 @@ 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(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"
Expand All @@ -50,4 +66,4 @@ if(${MSVC})
endif()

# Run the tests on every build
add_custom_target(test_${exercise} ALL DEPENDS ${exercise} COMMAND ${exercise})
add_custom_target(test_${exercise} ALL DEPENDS ${exercise} COMMAND ${exercise})
16 changes: 16 additions & 0 deletions exercises/atbash-cipher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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)
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
string(REPLACE "-" "_" file ${exercise})

Expand All @@ -32,6 +37,17 @@ 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(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"
Expand Down
16 changes: 16 additions & 0 deletions exercises/beer-song/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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)
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
string(REPLACE "-" "_" file ${exercise})

Expand All @@ -32,6 +37,17 @@ 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(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"
Expand Down
16 changes: 16 additions & 0 deletions exercises/binary-search-tree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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)
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
string(REPLACE "-" "_" file ${exercise})

Expand All @@ -32,6 +37,17 @@ 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(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"
Expand Down
16 changes: 16 additions & 0 deletions exercises/binary-search/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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)
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
string(REPLACE "-" "_" file ${exercise})

Expand All @@ -32,6 +37,17 @@ 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(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"
Expand Down
16 changes: 16 additions & 0 deletions exercises/binary/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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)
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
string(REPLACE "-" "_" file ${exercise})

Expand All @@ -32,6 +37,17 @@ 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(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"
Expand Down
16 changes: 16 additions & 0 deletions exercises/bob/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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)
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
string(REPLACE "-" "_" file ${exercise})

Expand All @@ -32,6 +37,17 @@ 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(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"
Expand Down
18 changes: 17 additions & 1 deletion exercises/circular-buffer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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)
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
string(REPLACE "-" "_" file ${exercise})

Expand All @@ -32,6 +37,17 @@ 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(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"
Expand All @@ -50,4 +66,4 @@ if(${MSVC})
endif()

# Run the tests on every build
add_custom_target(test_${exercise} ALL DEPENDS ${exercise} COMMAND ${exercise})
add_custom_target(test_${exercise} ALL DEPENDS ${exercise} COMMAND ${exercise})
Loading