1 include(LLVMProcessSources)
3 macro(target_name_of_partially_linked_object lib var)
9 endmacro(target_name_of_partially_linked_object lib var)
12 macro(add_partially_linked_object lib)
14 add_llvm_library( ${lib} ${ARGN})
16 set(pll ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${lib}.o)
17 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib)
18 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib)
19 llvm_process_sources( ALL_FILES ${ARGN} )
20 if( BUILD_SHARED_LIBS AND SUPPORTS_FPIC_FLAG )
21 add_definitions(-fPIC)
23 add_library( ${lib} STATIC ${ALL_FILES})
24 if( LLVM_COMMON_DEPENDS )
25 add_dependencies( ${lib} ${LLVM_COMMON_DEPENDS} )
26 endif( LLVM_COMMON_DEPENDS )
27 add_custom_command(OUTPUT ${pll}
28 COMMENT "Building ${lib}.o..."
30 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib/${CMAKE_CFG_INTDIR}
31 COMMAND ar x ${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}
32 COMMAND ${CMAKE_LINKER} "${LLVM_PLO_FLAGS}" -r "*${CMAKE_CXX_OUTPUT_EXTENSION}" -o ${pll}
33 COMMAND ${CMAKE_COMMAND} -E remove -f *${CMAKE_CXX_OUTPUT_EXTENSION}
35 target_name_of_partially_linked_object(${lib} tnplo)
36 add_custom_target(${tnplo} ALL DEPENDS ${pll})
37 set( llvm_libs ${llvm_libs} ${pll} PARENT_SCOPE)
38 set( llvm_lib_targets ${llvm_lib_targets} ${tnplo} PARENT_SCOPE )
42 endmacro(add_partially_linked_object lib)