mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-13 10:41:49 +08:00
247dc608bf
Resolves #37489.
66 lines
2.2 KiB
Diff
66 lines
2.2 KiB
Diff
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
|
|
index e76ffa6..a925a37 100644
|
|
--- a/test/CMakeLists.txt
|
|
+++ b/test/CMakeLists.txt
|
|
@@ -1,4 +1,4 @@
|
|
-cmake_minimum_required(VERSION 3.0)
|
|
+cmake_minimum_required(VERSION 3.5)
|
|
project(mimalloc-test C CXX)
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
@@ -19,21 +19,30 @@ endif()
|
|
find_package(mimalloc 2.0 REQUIRED NO_SYSTEM_ENVIRONMENT_PATH)
|
|
message(STATUS "Found mimalloc installed at: ${MIMALLOC_LIBRARY_DIR} (${MIMALLOC_VERSION_DIR})")
|
|
|
|
+set(THREADS_PREFER_PTHREAD_FLAG 1)
|
|
+find_package(Threads REQUIRED)
|
|
+
|
|
+if(BUILD_SHARED_LIBS)
|
|
# overriding with a dynamic library
|
|
add_executable(dynamic-override main-override.c)
|
|
target_link_libraries(dynamic-override PUBLIC mimalloc)
|
|
|
|
add_executable(dynamic-override-cxx main-override.cpp)
|
|
target_link_libraries(dynamic-override-cxx PUBLIC mimalloc)
|
|
+target_link_libraries(dynamic-override-cxx PRIVATE Threads::Threads)
|
|
+endif()
|
|
|
|
|
|
+if(0)
|
|
# overriding with a static object file works reliable as the symbols in the
|
|
# object file have priority over those in library files
|
|
add_executable(static-override-obj main-override.c ${MIMALLOC_OBJECT_DIR}/mimalloc.o)
|
|
target_include_directories(static-override-obj PUBLIC ${MIMALLOC_INCLUDE_DIR})
|
|
target_link_libraries(static-override-obj PUBLIC pthread)
|
|
+endif()
|
|
|
|
|
|
+if(NOT BUILD_SHARED_LIBS)
|
|
# overriding with a static library works too if using the `mimalloc-override.h`
|
|
# header to redefine malloc/free. (the library already overrides new/delete)
|
|
add_executable(static-override-static main-override-static.c)
|
|
@@ -47,6 +56,10 @@ target_link_libraries(static-override PUBLIC mimalloc-static)
|
|
|
|
add_executable(static-override-cxx main-override.cpp)
|
|
target_link_libraries(static-override-cxx PUBLIC mimalloc-static)
|
|
+target_link_libraries(static-override-cxx PRIVATE Threads::Threads)
|
|
+endif()
|
|
+
|
|
+include("${VCPKG_TESTS}")
|
|
|
|
|
|
## test memory errors
|
|
diff --git a/test/main-override.cpp b/test/main-override.cpp
|
|
index c1607b6..9e9824c 100644
|
|
--- a/test/main-override.cpp
|
|
+++ b/test/main-override.cpp
|
|
@@ -19,7 +19,7 @@
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
|
-#include <Windows.h>
|
|
+#include <windows.h>
|
|
static void msleep(unsigned long msecs) { Sleep(msecs); }
|
|
#else
|
|
#include <unistd.h>
|