integrate jemalloc into cmake build
well that was painful
This commit is contained in:
parent
c43f15d659
commit
11548e74ba
3 changed files with 41 additions and 1 deletions
|
@ -25,7 +25,8 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
|||
endif()
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE neo_GIT_REVISION
|
||||
ERROR_QUIET
|
||||
|
@ -36,6 +37,8 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
|||
endif()
|
||||
endif()
|
||||
|
||||
include(./contrib/jemalloc.cmake)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
add_subdirectory(demo)
|
||||
|
|
35
contrib/jemalloc.cmake
Normal file
35
contrib/jemalloc.cmake
Normal file
|
@ -0,0 +1,35 @@
|
|||
# See the end of this file for copyright and license terms.
|
||||
|
||||
set(JEMALLOC_SRCDIR "${CMAKE_SOURCE_DIR}/contrib/jemalloc")
|
||||
set(JEMALLOC_PREFIX "${CMAKE_BINARY_DIR}/contrib/jemalloc")
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
libjemalloc
|
||||
SOURCE_DIR ${JEMALLOC_SRCDIR}
|
||||
TMP_DIR ${JEMALLOC_PREFIX}
|
||||
STAMP_DIR ${JEMALLOC_PREFIX}
|
||||
CONFIGURE_COMMAND ${JEMALLOC_SRCDIR}/autogen.sh --without-export --enable-static --disable-cxx --srcdir ${JEMALLOC_SRCDIR} --prefix=${JEMALLOC_PREFIX} --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
|
||||
PREFIX ${JEMALLOC_SRCDIR}
|
||||
BUILD_COMMAND make build_lib_static
|
||||
BUILD_IN_SOURCE 1
|
||||
BUILD_BYPRODUCTS ${JEMALLOC_PREFIX}/lib/libjemalloc.a
|
||||
)
|
||||
|
||||
add_library(jemalloc STATIC IMPORTED GLOBAL)
|
||||
add_dependencies(jemalloc libjemalloc)
|
||||
set_property(
|
||||
TARGET jemalloc
|
||||
PROPERTY IMPORTED_LOCATION ${JEMALLOC_PREFIX}/lib/libjemalloc.a
|
||||
)
|
||||
|
||||
# This file is part of libneo.
|
||||
# Copyright (c) 2021 Fefie <owo@fef.moe>.
|
||||
#
|
||||
# libneo is non-violent software: you may only use, redistribute,
|
||||
# and/or modify it under the terms of the CNPLv6+ as found in
|
||||
# the LICENSE file in the source code root directory or at
|
||||
# <https://git.pixie.town/thufie/CNPL>.
|
||||
#
|
||||
# libneo comes with ABSOLUTELY NO WARRANTY, to the extent
|
||||
# permitted by applicable law. See the CNPLv6+ for details.
|
|
@ -5,6 +5,8 @@ add_library(neo)
|
|||
add_compile_options(-nostdlib -nodefaultlibs)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib")
|
||||
|
||||
target_link_libraries(neo PRIVATE jemalloc)
|
||||
|
||||
configure_file(
|
||||
./include/neo/buildconfig.h.in
|
||||
${CMAKE_BINARY_DIR}/include/neo/buildconfig.h
|
||||
|
|
Loading…
Reference in a new issue