mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-03 14:09:31 +03:00
fix library name for pkg config files (and to avoid extra patches in vcpkg)
This commit is contained in:
parent
432af2f304
commit
600ca88e87
2 changed files with 23 additions and 18 deletions
|
@ -580,7 +580,15 @@ endif()
|
||||||
|
|
||||||
# static library
|
# static library
|
||||||
if (MI_BUILD_STATIC)
|
if (MI_BUILD_STATIC)
|
||||||
|
if(WIN32)
|
||||||
|
# When building both static and shared libraries on Windows, a static library should use a
|
||||||
|
# different output name to avoid the conflict with the import library of a shared one.
|
||||||
|
string(REPLACE "mimalloc" "mimalloc-static" mi_static_libname ${mi_basename})
|
||||||
|
else()
|
||||||
|
set(mi_static_libname "${mi_basename}")
|
||||||
|
endif()
|
||||||
add_library(mimalloc-static STATIC ${mi_sources})
|
add_library(mimalloc-static STATIC ${mi_sources})
|
||||||
|
set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_static_libname})
|
||||||
set_property(TARGET mimalloc-static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET mimalloc-static PROPERTY 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} ${mi_cflags_static})
|
target_compile_options(mimalloc-static PRIVATE ${mi_cflags} ${mi_cflags_static})
|
||||||
|
@ -589,15 +597,6 @@ if (MI_BUILD_STATIC)
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:${mi_install_incdir}>
|
$<INSTALL_INTERFACE:${mi_install_incdir}>
|
||||||
)
|
)
|
||||||
if(WIN32)
|
|
||||||
# When building both static and shared libraries on Windows, a static library should use a
|
|
||||||
# different output name to avoid the conflict with the import library of a shared one.
|
|
||||||
string(REPLACE "mimalloc" "mimalloc-static" mi_output_name ${mi_basename})
|
|
||||||
set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_output_name})
|
|
||||||
else()
|
|
||||||
set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_basename})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_objdir} LIBRARY)
|
install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_objdir} LIBRARY)
|
||||||
install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir})
|
install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir})
|
||||||
endif()
|
endif()
|
||||||
|
@ -640,18 +639,24 @@ if (MI_BUILD_OBJECT)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# pkg-config file support
|
# pkg-config file support
|
||||||
set(pc_libraries "")
|
set(mi_pc_libraries "")
|
||||||
foreach(item IN LISTS mi_libraries)
|
foreach(item IN LISTS mi_libraries)
|
||||||
if(item MATCHES " *[-].*")
|
if(item MATCHES " *[-].*")
|
||||||
set(pc_libraries "${pc_libraries} ${item}")
|
set(mi_pc_libraries "${mi_pc_libraries} ${item}")
|
||||||
else()
|
else()
|
||||||
set(pc_libraries "${pc_libraries} -l${item}")
|
set(mi_pc_libraries "${mi_pc_libraries} -l${item}")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
if(MI_BUILD_STATIC) # prefer static linking with pkg-config
|
||||||
|
set(mi_pc_libname "${mi_static_libname}")
|
||||||
|
else()
|
||||||
|
set(mi_pc_libname "${mi_basename}")
|
||||||
|
endif()
|
||||||
|
|
||||||
include("cmake/JoinPaths.cmake")
|
include("cmake/JoinPaths.cmake")
|
||||||
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
join_paths(mi_pc_includedir "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
join_paths(libdir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
|
join_paths(mi_pc_libdir "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
|
||||||
configure_file(mimalloc.pc.in mimalloc.pc @ONLY)
|
configure_file(mimalloc.pc.in mimalloc.pc @ONLY)
|
||||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mimalloc.pc"
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mimalloc.pc"
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
prefix=@CMAKE_INSTALL_PREFIX@
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
libdir=@libdir_for_pc_file@
|
libdir=@mi_pc_libdir@
|
||||||
includedir=@includedir_for_pc_file@
|
includedir=@mi_pc_includedir@
|
||||||
|
|
||||||
Name: @PROJECT_NAME@
|
Name: @PROJECT_NAME@
|
||||||
Description: A compact general purpose allocator with excellent performance
|
Description: A compact general purpose allocator with excellent performance
|
||||||
Version: @PACKAGE_VERSION@
|
Version: @PACKAGE_VERSION@
|
||||||
URL: https://github.com/microsoft/mimalloc/
|
URL: https://github.com/microsoft/mimalloc/
|
||||||
Libs: -L${libdir} -lmimalloc
|
Libs: -L${libdir} -l@mi_pc_libname@
|
||||||
Libs.private: @pc_libraries@
|
Libs.private: @mi_pc_libraries@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|
Loading…
Add table
Reference in a new issue