1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0033565: Configuration - JeMalloc process different build types

Accept only static build of JeMalloc
This commit is contained in:
dpasukhi 2024-10-12 17:26:39 +00:00
parent 6c92579764
commit 50f1e73469

View File

@ -1,5 +1,90 @@
# JeMalloc
macro (JEMALLOC_LIB_SEARCH MMGR_LIB PREFIX)
if (NOT 3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB})
set (JEMALLOC_PATH_SUFFIXES "lib" "bin")
set (3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB} "3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB}-NOTFOUND")
if (3RDPARTY_JEMALLOC_DIR AND EXISTS "${3RDPARTY_JEMALLOC_DIR}")
find_library (3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB} NAMES ${MMGR_LIB}
PATHS "${3RDPARTY_JEMALLOC_LIBRARY_DIR}" "${3RDPARTY_JEMALLOC_DIR}"
PATH_SUFFIXES ${JEMALLOC_PATH_SUFFIXES}
CMAKE_FIND_ROOT_PATH_BOTH
NO_DEFAULT_PATH)
else()
find_library (3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB} NAMES ${MMGR_LIB}
PATH_SUFFIXES ${JEMALLOC_PATH_SUFFIXES}
CMAKE_FIND_ROOT_PATH_BOTH)
endif()
if (3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB})
get_filename_component (3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB} "${3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB}}" PATH)
set (3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB} "${3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB}}")
else()
set (3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB} "")
endif()
endif()
if (3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB})
list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB}}")
set (3RDPARTY_JEMALLOC_LIBRARY_DIR "${3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB}}" CACHE PATH "The directory containing JEMALLOC libraries" FORCE)
elseif("${PREFIX}" STREQUAL "SHARED")
return()
else()
message(STATUS "Cannot find ${MMGR_LIB} library in jemalloc 3rdparty")
list (APPEND 3RDPARTY_NO_LIBS 3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB})
set (3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB} "")
endif()
set (JEMALLOC_IS_STATIC_LIB FALSE)
if (((${3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB}} MATCHES "\.lib$")) OR ((${3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB}} MATCHES "\.a$")))
get_filename_component(STATIC_LIB_NAME ${3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB}} NAME)
list(APPEND CSF_MMGR "${STATIC_LIB_NAME}")
set (JEMALLOC_IS_STATIC_LIB TRUE)
endif()
# install instructions
if (INSTALL_JEMALLOC AND NOT JEMALLOC_IS_STATIC_LIB)
OCCT_MAKE_OS_WITH_BITNESS()
OCCT_MAKE_COMPILER_SHORT_NAME()
get_filename_component(3RDPARTY_JEMALLOC_LIBRARY ${3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB}} REALPATH)
if (SINGLE_GENERATOR)
install (FILES "${3RDPARTY_JEMALLOC_LIBRARY}"
DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_LIB}")
else()
install (FILES "${3RDPARTY_JEMALLOC_LIBRARY}"
CONFIGURATIONS Debug
DESTINATION "${JEMALLOC_INSTALL_DESTINATION}d")
install (FILES "${3RDPARTY_JEMALLOC_LIBRARY}"
CONFIGURATIONS Release
DESTINATION "${JEMALLOC_INSTALL_DESTINATION}")
install (FILES "${3RDPARTY_JEMALLOC_LIBRARY}"
CONFIGURATIONS RelWithDebInfo
DESTINATION "${JEMALLOC_INSTALL_DESTINATION}i")
endif()
set (USED_3RDPARTY_JEMALLOC_DIR "")
elseif(NOT JEMALLOC_IS_STATIC_LIB)
# the library directory for using by the executable
set (USED_3RDPARTY_JEMALLOC_DIR ${3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB}})
endif()
unset(3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB} CACHE)
unset(3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB} CACHE)
endmacro()
macro (SEARCH_JEMALLOC)
# find static jemalloc lib
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".a")
if (WIN32)
JEMALLOC_LIB_SEARCH ("jemalloc" "STATIC")
elseif(NOT WIN32)
JEMALLOC_LIB_SEARCH ("jemalloc_pic" "STATIC")
SET(CMAKE_FIND_LIBRARY_SUFFIXES "" "so")
JEMALLOC_LIB_SEARCH ("jemalloc.so.2" "SHARED")
endif()
# find shared jemalloc lib
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".so")
JEMALLOC_LIB_SEARCH ("jemalloc" "SHARED")
endmacro()
# Reset CSF variable
set (CSF_MMGR "")
if (NOT DEFINED INSTALL_JEMALLOC)
set (INSTALL_JEMALLOC OFF CACHE BOOL "${INSTALL_INSTALL_JEMALLOC_DESCR}")
endif()
@ -61,83 +146,5 @@ else()
set (JEMALLOC_INSTALL_DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_LIB}")
endif()
macro (JEMALLOC_LIB_SEARCH MMGR_LIB PREFIX)
if (NOT 3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB})
set (JEMALLOC_PATH_SUFFIXES "lib" "bin")
set (3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB} "3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB}-NOTFOUND")
if (3RDPARTY_JEMALLOC_DIR AND EXISTS "${3RDPARTY_JEMALLOC_DIR}")
find_library (3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB} NAMES ${MMGR_LIB}
PATHS "${3RDPARTY_JEMALLOC_LIBRARY_DIR}" "${3RDPARTY_JEMALLOC_DIR}"
PATH_SUFFIXES ${JEMALLOC_PATH_SUFFIXES}
CMAKE_FIND_ROOT_PATH_BOTH
NO_DEFAULT_PATH)
else()
find_library (3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB} NAMES ${MMGR_LIB}
PATH_SUFFIXES ${JEMALLOC_PATH_SUFFIXES}
CMAKE_FIND_ROOT_PATH_BOTH)
endif()
if (3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB})
get_filename_component (3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB} "${3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB}}" PATH)
set (3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB} "${3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB}}")
else()
set (3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB} "")
endif()
endif()
if (3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB})
list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB}}")
set (3RDPARTY_JEMALLOC_LIBRARY_DIR "${3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB}}" CACHE PATH "The directory containing JEMALLOC libraries" FORCE)
else()
message("Cannot find ${MMGR_LIB} library in jemalloc 3rdparty")
list (APPEND 3RDPARTY_NO_LIBS 3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB})
set (3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB} "")
endif()
set (JEMALLOC_IS_STATIC_LIB FALSE)
if (((${3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB}} MATCHES "\.lib$")) OR ((${3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB}} MATCHES "\.a$")))
get_filename_component(STATIC_LIB_NAME ${3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB}} NAME)
list(APPEND CSF_MMGR "${STATIC_LIB_NAME}")
set (JEMALLOC_IS_STATIC_LIB TRUE)
endif()
# install instructions
if (INSTALL_JEMALLOC AND NOT JEMALLOC_IS_STATIC_LIB)
OCCT_MAKE_OS_WITH_BITNESS()
OCCT_MAKE_COMPILER_SHORT_NAME()
get_filename_component(3RDPARTY_JEMALLOC_LIBRARY ${3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB}} REALPATH)
if (SINGLE_GENERATOR)
install (FILES "${3RDPARTY_JEMALLOC_LIBRARY}"
DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_LIB}")
else()
install (FILES "${3RDPARTY_JEMALLOC_LIBRARY}"
CONFIGURATIONS Debug
DESTINATION "${JEMALLOC_INSTALL_DESTINATION}d")
install (FILES "${3RDPARTY_JEMALLOC_LIBRARY}"
CONFIGURATIONS Release
DESTINATION "${JEMALLOC_INSTALL_DESTINATION}")
install (FILES "${3RDPARTY_JEMALLOC_LIBRARY}"
CONFIGURATIONS RelWithDebInfo
DESTINATION "${JEMALLOC_INSTALL_DESTINATION}i")
endif()
set (USED_3RDPARTY_JEMALLOC_DIR "")
elseif(NOT JEMALLOC_IS_STATIC_LIB)
# the library directory for using by the executable
set (USED_3RDPARTY_JEMALLOC_DIR ${3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB}})
endif()
unset(3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB} CACHE)
unset(3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB} CACHE)
endmacro()
# Reset CSF variable
set (CSF_MMGR "")
# find static jemalloc lib
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".a")
if (WIN32)
JEMALLOC_LIB_SEARCH ("jemalloc" "STATIC")
elseif(NOT WIN32)
JEMALLOC_LIB_SEARCH ("jemalloc_pic" "STATIC")
SET(CMAKE_FIND_LIBRARY_SUFFIXES "" "so")
JEMALLOC_LIB_SEARCH ("jemalloc.so.2" "SHARED")
endif()
# find shared jemalloc lib
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".so")
JEMALLOC_LIB_SEARCH ("jemalloc" "SHARED")
SEARCH_JEMALLOC()