mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 05:21:49 +03:00
3682694f76
* Add malloc, calloc and free wrappers to trace all of the allocations * Improve memory leak reporting when multiple allocations occurs in the same file at the same line. * Change directory name from 'debugging' to 'developer_tools' and added CMakeLists.txt, also change an include name to match a file name * Edit root CMakeLists.Txt * Update developer_tools/malloc_dbg.h Co-authored-by: David Leal <halfpacho@gmail.com> * Edit CMakeLists.txt to create a static library from malloc_dbg.c * Add comments for the includes * Change test.c name to test_malloc_dbg.c, also edit CMakeLists.txt to link malloc_dbg.a only to test_malloc_dbg. * Change comment style and change EXIT_SUCCESS to 0 * Fix typo in doxygen comments * Enhance comments * Apply suggestions from code review Co-authored-by: David Leal <halfpacho@gmail.com>
36 lines
1.3 KiB
CMake
36 lines
1.3 KiB
CMake
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
|
|
# with full pathname. RELATIVE may makes it easier to extract an executable name
|
|
# automatically.
|
|
file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c )
|
|
# file( GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/*.c )
|
|
# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES)
|
|
|
|
add_library(malloc_dbg malloc_dbg.c) # Create a static library from malloc_dbg.c file
|
|
|
|
foreach( testsourcefile ${APP_SOURCES} )
|
|
string( REPLACE ".c" "" testname ${testsourcefile} )
|
|
string( REPLACE ".C" "" testname ${testname} )
|
|
string( REPLACE " " "_" testname ${testname} )
|
|
|
|
if ("${testsourcefile}" STREQUAL "malloc_dbg.c")
|
|
continue()
|
|
endif()
|
|
|
|
add_executable( ${testname} ${testsourcefile} )
|
|
|
|
if ("${testname}" STREQUAL "test_malloc_dbg")
|
|
target_link_libraries(${testname} malloc_dbg)
|
|
endif()
|
|
|
|
if(OpenMP_C_FOUND)
|
|
target_link_libraries(${testname} OpenMP::OpenMP_C)
|
|
endif()
|
|
|
|
if(MATH_LIBRARY)
|
|
target_link_libraries(${testname} ${MATH_LIBRARY})
|
|
endif()
|
|
# target_link_libraries(${testname} malloc_dbg) # Link the malloc_dbg library
|
|
install(TARGETS ${testname} DESTINATION "bin/developer_tools")
|
|
|
|
endforeach( testsourcefile ${APP_SOURCES} )
|