summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaan <daan@effp.org>2022-10-31 15:49:48 -0700
committerdaan <daan@effp.org>2022-10-31 15:49:48 -0700
commit923ef1ba743310b0e147de3ecb404f6009b78476 (patch)
tree0557054b07a89ca9ea7d31c5e9e67e9117fe3343
parent0b1012aee037bba244845ac8ade35bf067ba5bc0 (diff)
parent7cb1fdc44e2bba83497fda6b22f5fb5d441a0af0 (diff)
Merge branch 'dev' into dev-slice
-rw-r--r--CMakeLists.txt18
-rw-r--r--cmake/JoinPaths.cmake23
-rw-r--r--mimalloc.pc.in11
3 files changed, 50 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4a57a3a..1b05afe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -210,7 +210,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()
@@ -248,18 +248,23 @@ endif()
# extra needed libraries
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 "${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()
@@ -409,6 +414,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 0000000..c68d91b
--- /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 0000000..36da203
--- /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: @PACKAGE_VERSION@
+URL: https://github.com/microsoft/mimalloc/
+Libs: -L${libdir} -lmimalloc
+Libs.private: @pc_libraries@
+Cflags: -I${includedir}