Skip to content

Commit

Permalink
CMake: Add an option to enable AddressSanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Oct 24, 2024
1 parent 1e4040c commit e31fb31
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ if(ANDROID OR MSVC OR IOS)
endif()

get_directory_property(hasParent PARENT_DIRECTORY)
if(NOT hasParent)
option(JNGL_SANITIZE_ADDRESS "Enable AddressSanitizer" OFF)
if(JNGL_SANITIZE_ADDRESS)
string(APPEND CMAKE_CXX_FLAGS " -fsanitize=address")
string(APPEND CMAKE_LINKER_FLAGS " -fsanitize=address")
endif()
endif()
if(ANDROID OR MSVC OR IOS)
CPMAddPackage(NAME freetype
URL https://sourceforge.net/projects/freetype/files/freetype2/2.11.1/freetype-2.11.1.tar.xz/download
Expand Down Expand Up @@ -383,6 +390,8 @@ else()
add_executable(audioplayer examples/audioplayer.cpp)
target_link_libraries(audioplayer PRIVATE jngl)
add_custom_command(TARGET audioplayer COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/data/test.ogg "$<TARGET_FILE_DIR:audioplayer>")
# add_executable(benchmark-shapes src/benchmarks/benchmark-shapes.cpp)
# target_link_libraries(benchmark-shapes jngl)
endif()
endif()
target_link_libraries(jngl-test jngl)
Expand Down

0 comments on commit e31fb31

Please sign in to comment.