Add option to install directly in CMAKE_INSTALL_PREFIX

This commit is contained in:
Uwe L. Korn 2020-05-30 07:19:57 +02:00 committed by Uwe L. Korn
parent a09a64e29b
commit 1f08317f3c

View File

@ -20,6 +20,7 @@ option(MI_BUILD_STATIC "Build static library" ON)
option(MI_BUILD_OBJECT "Build object library" ON) option(MI_BUILD_OBJECT "Build object library" ON)
option(MI_BUILD_TESTS "Build test executables" ON) option(MI_BUILD_TESTS "Build test executables" ON)
option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF) option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF)
option(MI_INSTALL_TOPLEVEL "Install directly into $CMAKE_INSTALL_PREFIX instead of PREFIX/lib/mimalloc-version" OFF)
include("cmake/mimalloc-config-version.cmake") include("cmake/mimalloc-config-version.cmake")
@ -175,7 +176,11 @@ endif()
# Install and output names # Install and output names
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
set(mi_install_dir "${CMAKE_INSTALL_PREFIX}/lib/mimalloc-${mi_version}") if (MI_INSTALL_TOPLEVEL MATCHES "ON")
set(mi_install_dir "${CMAKE_INSTALL_PREFIX}")
else()
set(mi_install_dir "${CMAKE_INSTALL_PREFIX}/lib/mimalloc-${mi_version}")
endif()
if(MI_SECURE MATCHES "ON") if(MI_SECURE MATCHES "ON")
set(mi_basename "mimalloc-secure") set(mi_basename "mimalloc-secure")
else() else()
@ -227,7 +232,14 @@ if(MI_BUILD_SHARED)
COMMENT "Copy mimalloc-redirect.dll to output directory") COMMENT "Copy mimalloc-redirect.dll to output directory")
endif() endif()
install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_dir} LIBRARY) if (MI_INSTALL_TOPLEVEL MATCHES "ON")
install(TARGETS mimalloc EXPORT mimalloc LIBRARY
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
else()
install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_dir} LIBRARY)
endif()
install(EXPORT mimalloc DESTINATION ${mi_install_dir}/cmake) install(EXPORT mimalloc DESTINATION ${mi_install_dir}/cmake)
endif() endif()
@ -261,7 +273,7 @@ install(FILES include/mimalloc-new-delete.h DESTINATION ${mi_install_dir}/includ
install(FILES cmake/mimalloc-config.cmake DESTINATION ${mi_install_dir}/cmake) install(FILES cmake/mimalloc-config.cmake DESTINATION ${mi_install_dir}/cmake)
install(FILES cmake/mimalloc-config-version.cmake DESTINATION ${mi_install_dir}/cmake) install(FILES cmake/mimalloc-config-version.cmake DESTINATION ${mi_install_dir}/cmake)
if(NOT WIN32 AND MI_BUILD_SHARED) if(NOT WIN32 AND MI_BUILD_SHARED AND NOT MI_INSTALL_TOPLEVEL)
# install a symlink in the /usr/local/lib to the versioned library # install a symlink in the /usr/local/lib to the versioned library
set(mi_symlink "${CMAKE_SHARED_MODULE_PREFIX}${mi_basename}${CMAKE_SHARED_LIBRARY_SUFFIX}") set(mi_symlink "${CMAKE_SHARED_MODULE_PREFIX}${mi_basename}${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(mi_soname "mimalloc-${mi_version}/${mi_symlink}.${mi_version}") set(mi_soname "mimalloc-${mi_version}/${mi_symlink}.${mi_version}")