Merge pull request #349 from tarc/feature/avoid-cmake-matches-operator
Avoid MATCHES operator to check CMake options
This commit is contained in:
commit
6327cf12c2
@ -46,7 +46,7 @@ set(mi_sources
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
if (NOT CMAKE_BUILD_TYPE)
|
if (NOT CMAKE_BUILD_TYPE)
|
||||||
if ("${CMAKE_BINARY_DIR}" MATCHES ".*(D|d)ebug$" OR MI_DEBUG_FULL MATCHES "ON")
|
if ("${CMAKE_BINARY_DIR}" MATCHES ".*(D|d)ebug$" OR MI_DEBUG_FULL)
|
||||||
message(STATUS "No build type selected, default to: Debug")
|
message(STATUS "No build type selected, default to: Debug")
|
||||||
set(CMAKE_BUILD_TYPE "Debug")
|
set(CMAKE_BUILD_TYPE "Debug")
|
||||||
else()
|
else()
|
||||||
@ -68,20 +68,20 @@ if(CMAKE_C_COMPILER_ID MATCHES "MSVC|Intel")
|
|||||||
set(MI_USE_CXX "ON")
|
set(MI_USE_CXX "ON")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MI_OVERRIDE MATCHES "ON")
|
if(MI_OVERRIDE)
|
||||||
message(STATUS "Override standard malloc (MI_OVERRIDE=ON)")
|
message(STATUS "Override standard malloc (MI_OVERRIDE=ON)")
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
if(MI_OSX_ZONE MATCHES "ON")
|
if(MI_OSX_ZONE)
|
||||||
# use zone's on macOS
|
# use zone's on macOS
|
||||||
message(STATUS " Use malloc zone to override malloc (MI_OSX_ZONE=ON)")
|
message(STATUS " Use malloc zone to override malloc (MI_OSX_ZONE=ON)")
|
||||||
list(APPEND mi_sources src/alloc-override-osx.c)
|
list(APPEND mi_sources src/alloc-override-osx.c)
|
||||||
list(APPEND mi_defines MI_OSX_ZONE=1)
|
list(APPEND mi_defines MI_OSX_ZONE=1)
|
||||||
if(NOT MI_INTERPOSE MATCHES "ON")
|
if(NOT MI_INTERPOSE)
|
||||||
message(STATUS " (enabling INTERPOSE as well since zone's require this)")
|
message(STATUS " (enabling INTERPOSE as well since zone's require this)")
|
||||||
set(MI_INTERPOSE "ON")
|
set(MI_INTERPOSE "ON")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(MI_INTERPOSE MATCHES "ON")
|
if(MI_INTERPOSE)
|
||||||
# use interpose on macOS
|
# use interpose on macOS
|
||||||
message(STATUS " Use interpose to override malloc (MI_INTERPOSE=ON)")
|
message(STATUS " Use interpose to override malloc (MI_INTERPOSE=ON)")
|
||||||
list(APPEND mi_defines MI_INTERPOSE)
|
list(APPEND mi_defines MI_INTERPOSE)
|
||||||
@ -89,42 +89,42 @@ if(MI_OVERRIDE MATCHES "ON")
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MI_SECURE MATCHES "ON")
|
if(MI_SECURE)
|
||||||
message(STATUS "Set full secure build (MI_SECURE=ON)")
|
message(STATUS "Set full secure build (MI_SECURE=ON)")
|
||||||
list(APPEND mi_defines MI_SECURE=4)
|
list(APPEND mi_defines MI_SECURE=4)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MI_SEE_ASM MATCHES "ON")
|
if(MI_SEE_ASM)
|
||||||
message(STATUS "Generate assembly listings (MI_SEE_ASM=ON)")
|
message(STATUS "Generate assembly listings (MI_SEE_ASM=ON)")
|
||||||
list(APPEND mi_cflags -save-temps)
|
list(APPEND mi_cflags -save-temps)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MI_CHECK_FULL MATCHES "ON")
|
if(MI_CHECK_FULL)
|
||||||
message(STATUS "The MI_CHECK_FULL option is deprecated, use MI_DEBUG_FULL instead")
|
message(STATUS "The MI_CHECK_FULL option is deprecated, use MI_DEBUG_FULL instead")
|
||||||
set(MI_DEBUG_FULL "ON")
|
set(MI_DEBUG_FULL "ON")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MI_DEBUG_FULL MATCHES "ON")
|
if(MI_DEBUG_FULL)
|
||||||
message(STATUS "Set debug level to full internal invariant checking (MI_DEBUG_FULL=ON)")
|
message(STATUS "Set debug level to full internal invariant checking (MI_DEBUG_FULL=ON)")
|
||||||
list(APPEND mi_defines MI_DEBUG=3) # full invariant checking
|
list(APPEND mi_defines MI_DEBUG=3) # full invariant checking
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MI_PADDING MATCHES "OFF")
|
if(NOT MI_PADDING)
|
||||||
message(STATUS "Disable padding of heap blocks in debug mode (MI_PADDING=OFF)")
|
message(STATUS "Disable padding of heap blocks in debug mode (MI_PADDING=OFF)")
|
||||||
list(APPEND mi_defines MI_PADDING=0)
|
list(APPEND mi_defines MI_PADDING=0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MI_XMALLOC MATCHES "ON")
|
if(MI_XMALLOC)
|
||||||
message(STATUS "Enable abort() calls on memory allocation failure (MI_XMALLOC=ON)")
|
message(STATUS "Enable abort() calls on memory allocation failure (MI_XMALLOC=ON)")
|
||||||
list(APPEND mi_defines MI_XMALLOC=1)
|
list(APPEND mi_defines MI_XMALLOC=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MI_SHOW_ERRORS MATCHES "ON")
|
if(MI_SHOW_ERRORS)
|
||||||
message(STATUS "Enable printing of error and warning messages by default (MI_SHOW_ERRORS=ON)")
|
message(STATUS "Enable printing of error and warning messages by default (MI_SHOW_ERRORS=ON)")
|
||||||
list(APPEND mi_defines MI_SHOW_ERRORS=1)
|
list(APPEND mi_defines MI_SHOW_ERRORS=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MI_DEBUG_TSAN MATCHES "ON")
|
if(MI_DEBUG_TSAN)
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
message(STATUS "Build with thread sanitizer (MI_DEBUG_TSAN=ON)")
|
message(STATUS "Build with thread sanitizer (MI_DEBUG_TSAN=ON)")
|
||||||
list(APPEND mi_defines MI_TSAN=1)
|
list(APPEND mi_defines MI_TSAN=1)
|
||||||
@ -135,13 +135,13 @@ if(MI_DEBUG_TSAN MATCHES "ON")
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MI_DEBUG_UBSAN MATCHES "ON")
|
if(MI_DEBUG_UBSAN)
|
||||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
message(STATUS "Build with undefined-behavior sanitizer (MI_DEBUG_UBSAN=ON)")
|
message(STATUS "Build with undefined-behavior sanitizer (MI_DEBUG_UBSAN=ON)")
|
||||||
list(APPEND mi_cflags -fsanitize=undefined -g)
|
list(APPEND mi_cflags -fsanitize=undefined -g)
|
||||||
list(APPEND CMAKE_EXE_LINKER_FLAGS -fsanitize=undefined)
|
list(APPEND CMAKE_EXE_LINKER_FLAGS -fsanitize=undefined)
|
||||||
if (MI_USE_CXX MATCHES "OFF")
|
if (NOT MI_USE_CXX)
|
||||||
message(STATUS "(switch to use C++ due to MI_DEBUG_UBSAN)")
|
message(STATUS "(switch to use C++ due to MI_DEBUG_UBSAN)")
|
||||||
set(MI_USE_CXX "ON")
|
set(MI_USE_CXX "ON")
|
||||||
endif()
|
endif()
|
||||||
@ -153,7 +153,7 @@ if(MI_DEBUG_UBSAN MATCHES "ON")
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MI_USE_CXX MATCHES "ON")
|
if(MI_USE_CXX)
|
||||||
message(STATUS "Use the C++ compiler to compile (MI_USE_CXX=ON)")
|
message(STATUS "Use the C++ compiler to compile (MI_USE_CXX=ON)")
|
||||||
set_source_files_properties(${mi_sources} PROPERTIES LANGUAGE CXX )
|
set_source_files_properties(${mi_sources} PROPERTIES LANGUAGE CXX )
|
||||||
set_source_files_properties(src/static.c test/test-api.c test/test-stress PROPERTIES LANGUAGE CXX )
|
set_source_files_properties(src/static.c test/test-api.c test/test-stress PROPERTIES LANGUAGE CXX )
|
||||||
@ -178,7 +178,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "Intel")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU|Intel" AND NOT CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU|Intel" AND NOT CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
||||||
if(MI_LOCAL_DYNAMIC_TLS MATCHES "ON")
|
if(MI_LOCAL_DYNAMIC_TLS)
|
||||||
list(APPEND mi_cflags -ftls-model=local-dynamic)
|
list(APPEND mi_cflags -ftls-model=local-dynamic)
|
||||||
else()
|
else()
|
||||||
list(APPEND mi_cflags -ftls-model=initial-exec)
|
list(APPEND mi_cflags -ftls-model=initial-exec)
|
||||||
@ -211,7 +211,7 @@ endif()
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
set(mi_install_dir "${CMAKE_INSTALL_PREFIX}/lib/mimalloc-${mi_version}")
|
set(mi_install_dir "${CMAKE_INSTALL_PREFIX}/lib/mimalloc-${mi_version}")
|
||||||
if(MI_SECURE MATCHES "ON")
|
if(MI_SECURE)
|
||||||
set(mi_basename "mimalloc-secure")
|
set(mi_basename "mimalloc-secure")
|
||||||
else()
|
else()
|
||||||
set(mi_basename "mimalloc")
|
set(mi_basename "mimalloc")
|
||||||
@ -235,7 +235,7 @@ endif()
|
|||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
message(STATUS "Library base name: ${mi_basename}")
|
message(STATUS "Library base name: ${mi_basename}")
|
||||||
message(STATUS "Build type : ${CMAKE_BUILD_TYPE_LC}")
|
message(STATUS "Build type : ${CMAKE_BUILD_TYPE_LC}")
|
||||||
if(MI_USE_CXX MATCHES "ON")
|
if(MI_USE_CXX)
|
||||||
message(STATUS "Compiler : ${CMAKE_CXX_COMPILER}")
|
message(STATUS "Compiler : ${CMAKE_CXX_COMPILER}")
|
||||||
else()
|
else()
|
||||||
message(STATUS "Compiler : ${CMAKE_C_COMPILER}")
|
message(STATUS "Compiler : ${CMAKE_C_COMPILER}")
|
||||||
@ -334,7 +334,7 @@ endif()
|
|||||||
# API surface testing
|
# API surface testing
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
if (MI_BUILD_TESTS MATCHES "ON")
|
if (MI_BUILD_TESTS)
|
||||||
add_executable(mimalloc-test-api test/test-api.c)
|
add_executable(mimalloc-test-api test/test-api.c)
|
||||||
target_compile_definitions(mimalloc-test-api PRIVATE ${mi_defines})
|
target_compile_definitions(mimalloc-test-api PRIVATE ${mi_defines})
|
||||||
target_compile_options(mimalloc-test-api PRIVATE ${mi_cflags})
|
target_compile_options(mimalloc-test-api PRIVATE ${mi_cflags})
|
||||||
@ -355,7 +355,7 @@ endif()
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Set override properties
|
# Set override properties
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
if (MI_OVERRIDE MATCHES "ON")
|
if (MI_OVERRIDE)
|
||||||
if (MI_BUILD_SHARED)
|
if (MI_BUILD_SHARED)
|
||||||
target_compile_definitions(mimalloc PRIVATE MI_MALLOC_OVERRIDE)
|
target_compile_definitions(mimalloc PRIVATE MI_MALLOC_OVERRIDE)
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user