File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed
Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 1+ # set OS preprocessor defines
2+ if (CMAKE_SYSTEM_NAME MATCHES "Emscripten" )
3+ set (OUP_PLATFORM_WASM TRUE )
4+ set (OUP_COMPILER_EMSCRIPTEN TRUE )
5+ elseif (APPLE )
6+ set (OUP_PLATFORM_OSX TRUE )
7+ elseif (UNIX )
8+ set (OUP_PLATFORM_LINUX TRUE )
9+ elseif (WIN32 )
10+ set (OUP_PLATFORM_WINDOWS TRUE )
11+ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
12+ set (OUP_COMPILER_MSVC TRUE )
13+ endif ()
14+ endif ()
15+
116include (FetchContent)
217
318FetchContent_Declare(
@@ -13,6 +28,13 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${Catch2_SOURCE_DIR}/extras")
1328add_executable (oup_tests ${PROJECT_SOURCE_DIR} /tests/runtime_tests.cpp)
1429target_link_libraries (oup_tests PRIVATE Catch2::Catch2WithMain)
1530target_link_libraries (oup_tests PRIVATE oup::oup)
31+ target_compile_definitions (oup_tests PRIVATE
32+ OUP_PLATFORM_OSX
33+ OUP_PLATFORM_WASM
34+ OUP_PLATFORM_LINUX
35+ OUP_PLATFORM_WINDOWS
36+ OUP_COMPILER_MSVC
37+ OUP_COMPILER_EMSCRIPTEN)
1638
1739include (CTest)
1840include (Catch)
Original file line number Diff line number Diff line change @@ -10,10 +10,14 @@ std::size_t num_allocations = 0u;
1010std::size_t double_delete = 0u ;
1111bool memory_tracking = false ;
1212
13- // NB: getting weird errors on MacOS when doing this
14- #if !defined(__APPLE__)
15- void * operator new (size_t size)
16- {
13+ #if defined(OUP_PLATFORM_OSX)
14+ // Getting weird errors on MacOS when overriding operator new and delete,
15+ // so disable the memory leak checking for this platform.
16+ # define CHECK_MEMORY_LEAKS 0
17+ #endif
18+
19+ #if defined(CHECK_MEMORY_LEAKS) && CHECK_MEMORY_LEAKS
20+ void * allocate (std::size_t size, bool array) {
1721 if (memory_tracking && num_allocations == max_allocations) {
1822 throw std::bad_alloc ();
1923 }
You can’t perform that action at this time.
0 commit comments