Skip to content
Open
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
218 changes: 109 additions & 109 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,109 +1,109 @@
cmake_minimum_required(VERSION 3.16)
# Read version from version.txt (single source of truth)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/version.txt" VLD_VERSION_RAW)
string(STRIP "${VLD_VERSION_RAW}" VLD_VERSION_STRING)
project(VLD
VERSION ${VLD_VERSION_STRING}
DESCRIPTION "Visual Leak Detector for Visual C++"
LANGUAGES CXX C
)
# Generate version.h from version.txt
set(VLD_VERSION_COMMA "${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/setup/version.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/setup/version.h"
@ONLY
)
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Option to enable/disable MFC support
option(VLD_USE_MFC "Build with MFC support (includes MFC test projects)" OFF)
# Configure output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Per-configuration output directories
foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${CONFIG_TYPE} CONFIG_TYPE_UPPER)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_TYPE_UPPER} ${CMAKE_BINARY_DIR}/lib/${CONFIG_TYPE})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONFIG_TYPE_UPPER} ${CMAKE_BINARY_DIR}/bin/${CONFIG_TYPE})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG_TYPE_UPPER} ${CMAKE_BINARY_DIR}/bin/${CONFIG_TYPE})
endforeach()
# Platform detection
# Use CMAKE_VS_PLATFORM_NAME for reliable ARM64 detection in Visual Studio generator
# NOTE: This requires Visual Studio generators. For other generators (Ninja, NMake, etc.),
# you would need to detect platform using CMAKE_SYSTEM_PROCESSOR and CMAKE_SIZEOF_VOID_P:
# - Check CMAKE_SYSTEM_PROCESSOR for "ARM64" or "aarch64"
# - Fall back to CMAKE_SIZEOF_VOID_P to distinguish x64 (8 bytes) from Win32 (4 bytes)
if(DEFINED CMAKE_VS_PLATFORM_NAME)
if(CMAKE_VS_PLATFORM_NAME STREQUAL "ARM64")
set(VLD_PLATFORM "ARM64")
set(VLD_PLATFORM_DEFINE "WIN64")
elseif(CMAKE_VS_PLATFORM_NAME STREQUAL "x64")
set(VLD_PLATFORM "x64")
set(VLD_PLATFORM_DEFINE "WIN64")
else()
set(VLD_PLATFORM "Win32")
set(VLD_PLATFORM_DEFINE "WIN32")
endif()
else()
message(FATAL_ERROR "VLD requires Visual Studio generator. CMAKE_VS_PLATFORM_NAME is not defined.")
endif()
# MSVC specific settings
if(MSVC)
# Default to DLL runtime for tests (they need it for GetProcAddress tests)
# VLD core library overrides this to use static runtime
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
# Common compile options - use highest warning level and treat warnings as errors
add_compile_options(/W4 /WX)
add_link_options(/WX)
add_compile_definitions(
_CRT_SECURE_NO_WARNINGS
_VARIADIC_MAX=10
$<$<CONFIG:Debug>:_DEBUG>
$<$<NOT:$<CONFIG:Debug>>:NDEBUG>
)
endif()
# Status messages
message(STATUS "Configuring Visual Leak Detector v${PROJECT_VERSION}")
message(STATUS "Platform: ${VLD_PLATFORM}")
message(STATUS "MFC Support: ${VLD_USE_MFC}")
# Enable testing
enable_testing()
# Google Test configuration - use DLL runtime to match tests
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
# Add subdirectories
add_subdirectory(lib/gtest)
add_subdirectory(lib/cppformat)
add_subdirectory(src)
add_subdirectory(src/tests)
# Third-party libraries: don't treat warnings as errors and use static runtime
if(MSVC)
target_compile_options(fmt PRIVATE /W3 /WX-)
set_property(TARGET fmt PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
# IDE folder organization
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_target_properties(gtest PROPERTIES FOLDER "Libraries")
set_target_properties(fmt PROPERTIES FOLDER "Libraries")
set_target_properties(vld PROPERTIES FOLDER "VLD")
cmake_minimum_required(VERSION 3.16)

# Read version from version.txt (single source of truth)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/version.txt" VLD_VERSION_RAW)
string(STRIP "${VLD_VERSION_RAW}" VLD_VERSION_STRING)

project(VLD
VERSION ${VLD_VERSION_STRING}
DESCRIPTION "Visual Leak Detector for Visual C++"
LANGUAGES CXX C
)

# Generate version.h from version.txt
set(VLD_VERSION_COMMA "${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/setup/version.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/setup/version.h"
@ONLY
)

# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Option to enable/disable MFC support
option(VLD_USE_MFC "Build with MFC support (includes MFC test projects)" OFF)

# Configure output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Per-configuration output directories
foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${CONFIG_TYPE} CONFIG_TYPE_UPPER)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_TYPE_UPPER} ${CMAKE_BINARY_DIR}/lib/${CONFIG_TYPE})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONFIG_TYPE_UPPER} ${CMAKE_BINARY_DIR}/bin/${CONFIG_TYPE})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG_TYPE_UPPER} ${CMAKE_BINARY_DIR}/bin/${CONFIG_TYPE})
endforeach()

# Platform detection
# Use CMAKE_VS_PLATFORM_NAME for reliable ARM64 detection in Visual Studio generator
# NOTE: This requires Visual Studio generators. For other generators (Ninja, NMake, etc.),
# you would need to detect platform using CMAKE_SYSTEM_PROCESSOR and CMAKE_SIZEOF_VOID_P:
# - Check CMAKE_SYSTEM_PROCESSOR for "ARM64" or "aarch64"
# - Fall back to CMAKE_SIZEOF_VOID_P to distinguish x64 (8 bytes) from Win32 (4 bytes)
if(DEFINED CMAKE_VS_PLATFORM_NAME)
if(CMAKE_VS_PLATFORM_NAME STREQUAL "ARM64")
set(VLD_PLATFORM "ARM64")
set(VLD_PLATFORM_DEFINE "WIN64")
elseif(CMAKE_VS_PLATFORM_NAME STREQUAL "x64")
set(VLD_PLATFORM "x64")
set(VLD_PLATFORM_DEFINE "WIN64")
else()
set(VLD_PLATFORM "Win32")
set(VLD_PLATFORM_DEFINE "WIN32")
endif()
else()
message(FATAL_ERROR "VLD requires Visual Studio generator. CMAKE_VS_PLATFORM_NAME is not defined.")
endif()

# MSVC specific settings
if(MSVC)
# Default to DLL runtime for tests (they need it for GetProcAddress tests)
# VLD core library overrides this to use static runtime
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")

# Common compile options - use highest warning level and treat warnings as errors
add_compile_options(/W4 /WX)
add_link_options(/WX)

add_compile_definitions(
_CRT_SECURE_NO_WARNINGS
_VARIADIC_MAX=10
$<$<CONFIG:Debug>:_DEBUG>
$<$<NOT:$<CONFIG:Debug>>:NDEBUG>
)
endif()

# Status messages
message(STATUS "Configuring Visual Leak Detector v${PROJECT_VERSION}")
message(STATUS "Platform: ${VLD_PLATFORM}")
message(STATUS "MFC Support: ${VLD_USE_MFC}")

# Enable testing
enable_testing()

# Google Test configuration - use DLL runtime to match tests
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)

# Add subdirectories
add_subdirectory(lib/gtest)
add_subdirectory(lib/cppformat)
add_subdirectory(src)
add_subdirectory(src/tests)

# Third-party libraries: don't treat warnings as errors and use static runtime
if(MSVC)
target_compile_options(fmt PRIVATE /W3 /WX-)
set_property(TARGET fmt PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

# IDE folder organization
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_target_properties(gtest PROPERTIES FOLDER "Libraries")
set_target_properties(fmt PROPERTIES FOLDER "Libraries")
set_target_properties(vld PROPERTIES FOLDER "VLD")
18 changes: 9 additions & 9 deletions COPYING.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.

Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
Expand Down Expand Up @@ -111,7 +111,7 @@ modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.

GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

Expand Down Expand Up @@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.

1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
Expand All @@ -158,7 +158,7 @@ Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.

2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
Expand Down Expand Up @@ -216,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.

Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
Expand Down Expand Up @@ -267,7 +267,7 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.

6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
Expand Down Expand Up @@ -329,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.

7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
Expand Down Expand Up @@ -370,7 +370,7 @@ subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.

11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
Expand Down Expand Up @@ -422,7 +422,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.

14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
Expand Down
10 changes: 5 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,21 @@ target_compile_definitions(vld PRIVATE
if(MSVC)
# VLD core uses static runtime (different from tests which use DLL runtime)
set_property(TARGET vld PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

# Precompiled header
target_precompile_headers(vld PRIVATE stdafx.h)

# Compiler options - disable inlining in Release/RelWithDebInfo to avoid issues with
# __forceinline functions that have their body in .cpp files (bug in source)
target_compile_options(vld PRIVATE
$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:/Ob0> # Disable inlining
)

# Disable C4244 warning for x86 builds (fmt library triggers this with 64-bit to 32-bit conversions)
if(VLD_PLATFORM STREQUAL "Win32")
target_compile_options(vld PRIVATE /wd4244)
endif()

# Linker settings
if(VLD_PLATFORM STREQUAL "ARM64" OR VLD_PLATFORM STREQUAL "x64")
# ARM64 and x64 require base address >= 4GB for ASLR optimization
Expand All @@ -125,7 +125,7 @@ if(MSVC)
/BASE:0x03200000
)
endif()

# Additional Windows libraries
target_link_libraries(vld PRIVATE
kernel32
Expand Down
4 changes: 2 additions & 2 deletions src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class Map {
// Return Value:
//
// Returns the Iterator after it has been incremented.
//
//
Iterator& operator ++ (int)
{
m_node = m_tree->next(m_node);
Expand All @@ -177,7 +177,7 @@ class Map {
// Return Value:
//
// Returns the Iterator before it has been incremented.
//
//
Iterator operator ++ ()
{
typename Tree<Pair<Tk, Tv> >::node_t *cur = m_node;
Expand Down
2 changes: 1 addition & 1 deletion src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Used by vld.rc

// Next default values for new objects
//
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
Expand Down
4 changes: 2 additions & 2 deletions src/set.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Set {
// Return Value:
//
// Returns the Iterator after it has been incremented.
//
//
Iterator& operator ++ (int)
{
m_node = m_tree->next(m_node);
Expand All @@ -127,7 +127,7 @@ class Set {
// Return Value:
//
// Returns the Iterator before it has been incremented.
//
//
Iterator operator ++ ()
{
typename Tree<Tk>::node_t *cur = m_node;
Expand Down
Loading