mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Support build with mimalloc (#348)
* Support build with mimalloc * Use latest stable tag
This commit is contained in:
@@ -1,11 +1,30 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(c3c)
|
||||
include(FetchContent)
|
||||
include(FeatureSummary)
|
||||
|
||||
set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
|
||||
set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
|
||||
set(C3_LLVM_VERSION "auto" CACHE STRING "Use LLVM version [default: auto]")
|
||||
option(C3_USE_MIMALLOC "Use built-in mimalloc" ON)
|
||||
set(C3_MIMALLOC_TAG "v1.7.3" CACHE STRING "Used version of mimalloc")
|
||||
|
||||
if(WIN32)
|
||||
set(C3_USE_MIMALLOC OFF)
|
||||
endif()
|
||||
|
||||
if(C3_USE_MIMALLOC)
|
||||
option(MI_BUILD_TESTS OFF)
|
||||
option(MI_BUILD_SHARED OFF)
|
||||
option(MI_PADDING OFF)
|
||||
option(MI_DEBUG_FULL OFF)
|
||||
FetchContent_Declare(
|
||||
mimalloc
|
||||
GIT_REPOSITORY https://github.com/microsoft/mimalloc.git
|
||||
GIT_TAG ${C3_MIMALLOC_TAG}
|
||||
)
|
||||
FetchContent_MakeAvailable(mimalloc)
|
||||
endif()
|
||||
|
||||
if(NOT C3_LLVM_VERSION STREQUAL "auto")
|
||||
if(${C3_LLVM_VERSION} VERSION_LESS 12 OR ${C3_LLVM_VERSION} VERSION_GREATER 14)
|
||||
@@ -192,6 +211,9 @@ if(UNIX)
|
||||
target_link_libraries(c3c_wrappers ${llvm_libs} ${lld_libs})
|
||||
target_link_libraries(c3c m ${llvm_libs} c3c_wrappers ${lld_libs})
|
||||
# target_link_libraries(c3c m ${llvm_libs} c3c_wrappers ${TB_LIB} ${lld_libs})
|
||||
if(C3_USE_MIMALLOC)
|
||||
target_link_libraries(c3c m mimalloc-static)
|
||||
endif()
|
||||
else()
|
||||
# todo: maybe get this from llvm-config somehow? it should be in LLVM_DIR\..\..\..\bin I think.
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -LIBPATH:C:\\llvm\\llvm\\build\\Release\\lib") # needed for lldCommon.lib
|
||||
|
||||
Reference in New Issue
Block a user