Skip to content

Commit

Permalink
cmake: restore ENABLE_STATIC_CRT and ENABLE_ASAN options
Browse files Browse the repository at this point in the history
Deleted by accident in b490aab
  • Loading branch information
vszakats committed Jan 21, 2024
1 parent 11aa2bf commit 64096e3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,30 @@ else()

include(cmake/PickyWarningsC.cmake)
include(cmake/PickyWarningsCXX.cmake)

if(ENABLE_ASAN)
include(CMakePushCheckState)
cmake_push_check_state()
set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=address")
check_c_compiler_flag(-fsanitize=address C__fsanitize_address_VALID)
check_cxx_compiler_flag(-fsanitize=address CXX__fsanitize_address_VALID)
cmake_pop_check_state()
if(NOT C__fsanitize_address_VALID OR NOT CXX__fsanitize_address_VALID)
message(WARNING "ENABLE_ASAN was requested, but not supported!")
else()
set(CMAKE_C_FLAGS "-fsanitize=address ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-fsanitize=address ${CMAKE_CXX_FLAGS}")
endif()
endif()
endif()

if(ENABLE_STATIC_CRT)
foreach(lang C CXX)
foreach(suffix "" _DEBUG _MINSIZEREL _RELEASE _RELWITHDEBINFO)
set(var "CMAKE_${lang}_FLAGS${suffix}")
string(REPLACE "/MD" "/MT" ${var} "${${var}}")
endforeach()
endforeach()
endif()

if(ENABLE_DEBUG)
Expand Down

0 comments on commit 64096e3

Please sign in to comment.