Commit 031610e5 authored by Leif Walsh's avatar Leif Walsh

added optimization for normal static libraries Tokutek/mongo#983

parent b5fd90a3
...@@ -40,23 +40,38 @@ FOREACH(LIB ${STATIC_LIBS}) ...@@ -40,23 +40,38 @@ FOREACH(LIB ${STATIC_LIBS})
) )
STRING(REGEX REPLACE "\n" ";" LIB_OBJ_LIST "${LIB_OBJS}") STRING(REGEX REPLACE "\n" ";" LIB_OBJ_LIST "${LIB_OBJS}")
STRING(REGEX REPLACE ";$" "" LIB_OBJ_LIST "${LIB_OBJ_LIST}") STRING(REGEX REPLACE ";$" "" LIB_OBJ_LIST "${LIB_OBJ_LIST}")
LIST(SORT LIB_OBJ_LIST)
SET(SAME_OBJ_COUNT 1) LIST(LENGTH LIB_OBJ_LIST LENGTH_WITH_DUPS)
SET(LAST_OBJ_NAME) SET(LIB_OBJ_LIST_NO_DUPS ${LIB_OBJ_LIST})
FOREACH(OBJ ${LIB_OBJ_LIST}) LIST(REMOVE_DUPLICATES LIB_OBJ_LIST_NO_DUPS)
IF(OBJ STREQUAL LAST_OBJ_NAME) LIST(LENGTH LIB_OBJ_LIST_NO_DUPS LENGTH_WITHOUT_DUPS)
GET_FILENAME_COMPONENT(OBJ_NO_EXT ${OBJ} NAME_WE)
FILE(RENAME "${TEMP_SUBDIR}/${OBJ}" "${TEMP_SUBDIR}/${OBJ_NO_EXT}.${SAME_OBJ_COUNT}.o") IF(LENGTH_WITH_DUPS EQUAL LENGTH_WITHOUT_DUPS)
MATH(EXPR SAME_OBJ_COUNT "${SAME_OBJ_COUNT}+1") # Optimization for when lib doesn't actually have duplicate object
ELSE() # names, we can just extract everything.
SET(SAME_OBJ_COUNT 1)
ENDIF()
SET(LAST_OBJ_NAME "${OBJ}")
EXECUTE_PROCESS( EXECUTE_PROCESS(
COMMAND ${CMAKE_AR} -xN ${SAME_OBJ_COUNT} ${LIB} ${OBJ} COMMAND ${CMAKE_AR} -x ${LIB}
WORKING_DIRECTORY ${TEMP_SUBDIR} WORKING_DIRECTORY ${TEMP_SUBDIR}
) )
ENDFOREACH() ELSE()
LIST(SORT LIB_OBJ_LIST)
SET(SAME_OBJ_COUNT 1)
SET(LAST_OBJ_NAME)
FOREACH(OBJ ${LIB_OBJ_LIST})
IF(OBJ STREQUAL LAST_OBJ_NAME)
GET_FILENAME_COMPONENT(OBJ_NO_EXT ${OBJ} NAME_WE)
FILE(RENAME "${TEMP_SUBDIR}/${OBJ}" "${TEMP_SUBDIR}/${OBJ_NO_EXT}.${SAME_OBJ_COUNT}.o")
MATH(EXPR SAME_OBJ_COUNT "${SAME_OBJ_COUNT}+1")
ELSE()
SET(SAME_OBJ_COUNT 1)
ENDIF()
SET(LAST_OBJ_NAME "${OBJ}")
EXECUTE_PROCESS(
COMMAND ${CMAKE_AR} -xN ${SAME_OBJ_COUNT} ${LIB} ${OBJ}
WORKING_DIRECTORY ${TEMP_SUBDIR}
)
ENDFOREACH()
ENDIF()
FILE(GLOB_RECURSE LIB_OBJECTS "${TEMP_SUBDIR}/*.o") FILE(GLOB_RECURSE LIB_OBJECTS "${TEMP_SUBDIR}/*.o")
SET(OBJECTS ${OBJECTS} ${LIB_OBJECTS}) SET(OBJECTS ${OBJECTS} ${LIB_OBJECTS})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment