CMake: Support for building 32 bit mode libs and binaries on

Linux/x86-64.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58677 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Oscar Fuentes 2008-11-04 03:27:24 +00:00
parent 5c42fd8af1
commit b0c56992ce
2 changed files with 16 additions and 1 deletions

View File

@ -73,6 +73,21 @@ set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
add_definitions( -D__STDC_LIMIT_MACROS )
add_definitions( -D__STDC_CONSTANT_MACROS )
set(LLVM_PLO_FLAGS "" CACHE
STRING "Flags for creating partially linked objects.")
if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
# TODO: support other platforms and toolchains.
option(BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
if( BUILD_32_BITS )
message(STATUS "Building 32 bits executables and libraries.")
add_definitions( -m32 )
set( CMAKE_EXE_LINKER_FLAGS "-m32 ${CMAKE_EXE_LINKER_FLAGS}" )
set( CMAKE_LINK_LIBRARY_FLAG "-m32 ${CMAKE_LINK_LIBRARY_FLAG}" )
set( LLVM_PLO_FLAGS -melf_i386 ${LLVM_PLO_FLAGS} )
endif( BUILD_32_BITS )
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
if( MSVC )
add_definitions( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS )
add_definitions( -D_SCL_SECURE_NO_WARNINGS -DCRT_NONSTDC_NO_WARNINGS )

View File

@ -24,7 +24,7 @@ macro(add_partially_linked_object lib)
DEPENDS ${lib}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib
COMMAND ar x ${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}
COMMAND ld -r *${CMAKE_CXX_OUTPUT_EXTENSION} -o ${pll}
COMMAND ld "${LLVM_PLO_FLAGS}" -r "*${CMAKE_CXX_OUTPUT_EXTENSION}" -o ${pll}
COMMAND rm -f *${CMAKE_CXX_OUTPUT_EXTENSION}
)
target_name_of_partially_linked_object(${lib} tnplo)