From 8cb6ba22215c923805ec10d621f5a9f23a7e4140 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Mon, 6 Jun 2022 16:18:33 +0000 Subject: [PATCH 1/4] add support for IntelLLVM --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b7023009..dfcf34c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,7 +179,7 @@ if(MI_USE_CXX) if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang|Clang") list(APPEND mi_cflags -Wno-deprecated) endif() - if(CMAKE_CXX_COMPILER_ID MATCHES "Intel") + if(CMAKE_CXX_COMPILER_ID MATCHES "Intel" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM") list(APPEND mi_cflags -Kc++) endif() endif() From eb97236652d3c571948844d88efac717b821b14a Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 19 Jun 2022 13:20:53 -0400 Subject: [PATCH 2/4] cmake: add pkg-config file pkg-config allows using the library in build systems that are not cmake, by exporting the same information from the cmake -config files in a buildsystem-neutral format. Fixes #16 --- CMakeLists.txt | 15 ++++++++++++++- cmake/JoinPaths.cmake | 23 +++++++++++++++++++++++ mimalloc.pc.in | 11 +++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 cmake/JoinPaths.cmake create mode 100644 mimalloc.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index b7023009..a43377e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,18 +217,22 @@ endif() # extra needed libraries if(WIN32) list(APPEND mi_libraries psapi shell32 user32 advapi32 bcrypt) + set(pc_libraries "-lpsapi -lshell32 -luser32 -ladvapi32 -lbcrypt") else() find_library(MI_LIBPTHREAD pthread) if (MI_LIBPTHREAD) list(APPEND mi_libraries ${MI_LIBPTHREAD}) + set(pc_libraries "-pthread") endif() find_library(MI_LIBRT rt) if(MI_LIBRT) list(APPEND mi_libraries ${MI_LIBRT}) - endif() + set(pc_libraries "${pc_libraries} -lrt") + endif() find_library(MI_LIBATOMIC atomic) if (MI_LIBATOMIC OR MI_USE_LIBATOMIC) list(APPEND mi_libraries atomic) + set(pc_libraries "${pc_libraries} -latomic") endif() endif() @@ -376,6 +380,15 @@ if (MI_BUILD_OBJECT) RENAME ${mi_basename}${CMAKE_C_OUTPUT_EXTENSION} ) endif() +# pkg-config file support +include("cmake/JoinPaths.cmake") +join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") +join_paths(libdir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_LIBDIR}") + +configure_file(mimalloc.pc.in mimalloc.pc @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mimalloc.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/") + # ----------------------------------------------------------------------------- # API surface testing # ----------------------------------------------------------------------------- diff --git a/cmake/JoinPaths.cmake b/cmake/JoinPaths.cmake new file mode 100644 index 00000000..c68d91b8 --- /dev/null +++ b/cmake/JoinPaths.cmake @@ -0,0 +1,23 @@ +# This module provides function for joining paths +# known from most languages +# +# SPDX-License-Identifier: (MIT OR CC0-1.0) +# Copyright 2020 Jan Tojnar +# https://github.com/jtojnar/cmake-snips +# +# Modelled after Python’s os.path.join +# https://docs.python.org/3.7/library/os.path.html#os.path.join +# Windows not supported +function(join_paths joined_path first_path_segment) + set(temp_path "${first_path_segment}") + foreach(current_segment IN LISTS ARGN) + if(NOT ("${current_segment}" STREQUAL "")) + if(IS_ABSOLUTE "${current_segment}") + set(temp_path "${current_segment}") + else() + set(temp_path "${temp_path}/${current_segment}") + endif() + endif() + endforeach() + set(${joined_path} "${temp_path}" PARENT_SCOPE) +endfunction() diff --git a/mimalloc.pc.in b/mimalloc.pc.in new file mode 100644 index 00000000..e0cb4820 --- /dev/null +++ b/mimalloc.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@libdir_for_pc_file@ +includedir=@includedir_for_pc_file@ + +Name: @PROJECT_NAME@ +Description: a compact general purpose allocator with excellent performance +Version: @PROJECT_VERSION@ +URL: https://github.com/microsoft/mimalloc/ +Libs: -L${libdir} -lmimalloc +Libs.private: @pc_libraries@ +Cflags: -I${includedir} From 4dcd7e68429f74867ba6fd6eb39872a2c505b8bf Mon Sep 17 00:00:00 2001 From: daan Date: Mon, 31 Oct 2022 15:47:00 -0700 Subject: [PATCH 3/4] fix version number in pc-config --- mimalloc.pc.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mimalloc.pc.in b/mimalloc.pc.in index e0cb4820..36da2038 100644 --- a/mimalloc.pc.in +++ b/mimalloc.pc.in @@ -3,8 +3,8 @@ libdir=@libdir_for_pc_file@ includedir=@includedir_for_pc_file@ Name: @PROJECT_NAME@ -Description: a compact general purpose allocator with excellent performance -Version: @PROJECT_VERSION@ +Description: A compact general purpose allocator with excellent performance +Version: @PACKAGE_VERSION@ URL: https://github.com/microsoft/mimalloc/ Libs: -L${libdir} -lmimalloc Libs.private: @pc_libraries@ From 7cb1fdc44e2bba83497fda6b22f5fb5d441a0af0 Mon Sep 17 00:00:00 2001 From: daan Date: Mon, 31 Oct 2022 15:49:04 -0700 Subject: [PATCH 4/4] nicer style for pc_libraries --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24566266..144395d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,10 +250,11 @@ if(WIN32) list(APPEND mi_libraries psapi shell32 user32 advapi32 bcrypt) set(pc_libraries "-lpsapi -lshell32 -luser32 -ladvapi32 -lbcrypt") else() + set(pc_libraries "") find_library(MI_LIBPTHREAD pthread) if (MI_LIBPTHREAD) list(APPEND mi_libraries ${MI_LIBPTHREAD}) - set(pc_libraries "-pthread") + set(pc_libraries "${pc_libraries} -pthread") endif() find_library(MI_LIBRT rt) if(MI_LIBRT)