mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-20 22:19:30 +03:00
LTO/IPO optional support proposal.
cmake version jump mostly for windows/VS.
This commit is contained in:
parent
ddc9841019
commit
f1fa26f503
1 changed files with 14 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
project(libmimalloc C CXX)
|
project(libmimalloc C CXX)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
@ -21,6 +21,7 @@ option(MI_LOCAL_DYNAMIC_TLS "Use slightly slower, dlopen-compatible TLS mechanis
|
||||||
option(MI_BUILD_SHARED "Build shared library" ON)
|
option(MI_BUILD_SHARED "Build shared library" ON)
|
||||||
option(MI_BUILD_STATIC "Build static library" ON)
|
option(MI_BUILD_STATIC "Build static library" ON)
|
||||||
option(MI_BUILD_OBJECT "Build object library" ON)
|
option(MI_BUILD_OBJECT "Build object library" ON)
|
||||||
|
option(MI_BUILD_IPO "Build library with IPO/LTO" OFF)
|
||||||
option(MI_BUILD_TESTS "Build test executables" ON)
|
option(MI_BUILD_TESTS "Build test executables" ON)
|
||||||
option(MI_DEBUG_TSAN "Build with thread sanitizer (needs clang)" OFF)
|
option(MI_DEBUG_TSAN "Build with thread sanitizer (needs clang)" OFF)
|
||||||
option(MI_DEBUG_UBSAN "Build with undefined-behavior sanitizer (needs clang++)" OFF)
|
option(MI_DEBUG_UBSAN "Build with undefined-behavior sanitizer (needs clang++)" OFF)
|
||||||
|
@ -325,6 +326,7 @@ if(NOT(CMAKE_BUILD_TYPE_LC MATCHES "^(release|relwithdebinfo|minsizerel|none)$")
|
||||||
set(mi_basename "${mi_basename}-${CMAKE_BUILD_TYPE_LC}") #append build type (e.g. -debug) if not a release version
|
set(mi_basename "${mi_basename}-${CMAKE_BUILD_TYPE_LC}") #append build type (e.g. -debug) if not a release version
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(mi_ipo FALSE)
|
||||||
if(MI_BUILD_SHARED)
|
if(MI_BUILD_SHARED)
|
||||||
list(APPEND mi_build_targets "shared")
|
list(APPEND mi_build_targets "shared")
|
||||||
endif()
|
endif()
|
||||||
|
@ -334,6 +336,13 @@ endif()
|
||||||
if(MI_BUILD_OBJECT)
|
if(MI_BUILD_OBJECT)
|
||||||
list(APPEND mi_build_targets "object")
|
list(APPEND mi_build_targets "object")
|
||||||
endif()
|
endif()
|
||||||
|
if(MI_BUILD_IPO)
|
||||||
|
include(CheckIPOSupported)
|
||||||
|
check_ipo_supported(RESULT HAS_IPO)
|
||||||
|
if (HAS_IPO)
|
||||||
|
set(mi_ipo TRUE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
if(MI_BUILD_TESTS)
|
if(MI_BUILD_TESTS)
|
||||||
list(APPEND mi_build_targets "tests")
|
list(APPEND mi_build_targets "tests")
|
||||||
endif()
|
endif()
|
||||||
|
@ -351,6 +360,7 @@ message(STATUS "Compiler flags : ${mi_cflags}")
|
||||||
message(STATUS "Compiler defines : ${mi_defines}")
|
message(STATUS "Compiler defines : ${mi_defines}")
|
||||||
message(STATUS "Link libraries : ${mi_libraries}")
|
message(STATUS "Link libraries : ${mi_libraries}")
|
||||||
message(STATUS "Build targets : ${mi_build_targets}")
|
message(STATUS "Build targets : ${mi_build_targets}")
|
||||||
|
message(STATUS "IPO/LTO support : ${mi_ipo}")
|
||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
@ -360,7 +370,7 @@ message(STATUS "")
|
||||||
# shared library
|
# shared library
|
||||||
if(MI_BUILD_SHARED)
|
if(MI_BUILD_SHARED)
|
||||||
add_library(mimalloc SHARED ${mi_sources})
|
add_library(mimalloc SHARED ${mi_sources})
|
||||||
set_target_properties(mimalloc PROPERTIES VERSION ${mi_version} SOVERSION ${mi_version_major} OUTPUT_NAME ${mi_basename} )
|
set_target_properties(mimalloc PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${mi_ipo} VERSION ${mi_version} SOVERSION ${mi_version_major} OUTPUT_NAME ${mi_basename} )
|
||||||
target_compile_definitions(mimalloc PRIVATE ${mi_defines} MI_SHARED_LIB MI_SHARED_LIB_EXPORT)
|
target_compile_definitions(mimalloc PRIVATE ${mi_defines} MI_SHARED_LIB MI_SHARED_LIB_EXPORT)
|
||||||
target_compile_options(mimalloc PRIVATE ${mi_cflags})
|
target_compile_options(mimalloc PRIVATE ${mi_cflags})
|
||||||
target_link_libraries(mimalloc PRIVATE ${mi_libraries})
|
target_link_libraries(mimalloc PRIVATE ${mi_libraries})
|
||||||
|
@ -390,7 +400,8 @@ endif()
|
||||||
# static library
|
# static library
|
||||||
if (MI_BUILD_STATIC)
|
if (MI_BUILD_STATIC)
|
||||||
add_library(mimalloc-static STATIC ${mi_sources})
|
add_library(mimalloc-static STATIC ${mi_sources})
|
||||||
set_property(TARGET mimalloc-static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
#set_property(TARGET mimalloc-static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
|
set_target_properties(mimalloc-static PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${mi_ipo} POSITION_INDEPENDENT_CODE ON)
|
||||||
target_compile_definitions(mimalloc-static PRIVATE ${mi_defines} MI_STATIC_LIB)
|
target_compile_definitions(mimalloc-static PRIVATE ${mi_defines} MI_STATIC_LIB)
|
||||||
target_compile_options(mimalloc-static PRIVATE ${mi_cflags})
|
target_compile_options(mimalloc-static PRIVATE ${mi_cflags})
|
||||||
target_link_libraries(mimalloc-static PRIVATE ${mi_libraries})
|
target_link_libraries(mimalloc-static PRIVATE ${mi_libraries})
|
||||||
|
|
Loading…
Add table
Reference in a new issue