2008-11-14 22:06:14 +00:00
|
|
|
include(LLVMProcessSources)
|
2008-09-22 01:08:49 +00:00
|
|
|
|
2008-09-22 18:21:51 +00:00
|
|
|
macro(target_name_of_partially_linked_object lib var)
|
|
|
|
if( MSVC )
|
|
|
|
set(${var} ${lib})
|
|
|
|
else( MSVC )
|
|
|
|
set(${var} ${lib}_pll)
|
|
|
|
endif( MSVC )
|
|
|
|
endmacro(target_name_of_partially_linked_object lib var)
|
|
|
|
|
|
|
|
|
2008-09-22 01:08:49 +00:00
|
|
|
macro(add_partially_linked_object lib)
|
|
|
|
if( MSVC )
|
|
|
|
add_llvm_library( ${lib} ${ARGN})
|
|
|
|
else( MSVC )
|
|
|
|
set(pll ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${lib}.o)
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib)
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib)
|
2008-11-15 02:08:08 +00:00
|
|
|
llvm_process_sources( ALL_FILES ${ARGN} )
|
2008-11-20 03:10:17 +00:00
|
|
|
if( BUILD_SHARED_LIBS AND SUPPORTS_FPIC_FLAG )
|
|
|
|
add_definitions(-fPIC)
|
|
|
|
endif()
|
2008-11-15 02:08:08 +00:00
|
|
|
add_library( ${lib} STATIC ${ALL_FILES})
|
2008-09-22 18:21:51 +00:00
|
|
|
if( LLVM_COMMON_DEPENDS )
|
|
|
|
add_dependencies( ${lib} ${LLVM_COMMON_DEPENDS} )
|
|
|
|
endif( LLVM_COMMON_DEPENDS )
|
2008-09-22 01:08:49 +00:00
|
|
|
add_custom_command(OUTPUT ${pll}
|
2008-09-22 02:33:43 +00:00
|
|
|
COMMENT "Building ${lib}.o..."
|
2008-09-22 01:08:49 +00:00
|
|
|
DEPENDS ${lib}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib
|
|
|
|
COMMAND ar x ${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
2008-11-09 18:53:19 +00:00
|
|
|
COMMAND ${CMAKE_LINKER} "${LLVM_PLO_FLAGS}" -r "*${CMAKE_CXX_OUTPUT_EXTENSION}" -o ${pll}
|
2009-01-07 19:24:44 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove -f *${CMAKE_CXX_OUTPUT_EXTENSION}
|
2008-09-22 01:08:49 +00:00
|
|
|
)
|
2008-09-22 18:21:51 +00:00
|
|
|
target_name_of_partially_linked_object(${lib} tnplo)
|
|
|
|
add_custom_target(${tnplo} ALL DEPENDS ${pll})
|
2008-09-22 01:08:49 +00:00
|
|
|
set( llvm_libs ${llvm_libs} ${pll} PARENT_SCOPE)
|
2008-09-22 18:21:51 +00:00
|
|
|
set( llvm_lib_targets ${llvm_lib_targets} ${tnplo} PARENT_SCOPE )
|
2008-09-22 01:08:49 +00:00
|
|
|
endif( MSVC )
|
2008-10-22 02:56:07 +00:00
|
|
|
install(FILES ${pll}
|
|
|
|
DESTINATION lib)
|
2008-09-22 01:08:49 +00:00
|
|
|
endmacro(add_partially_linked_object lib)
|