forked from OSchip/llvm-project
CMake: when building shared libraries, use -fPIC for compiling
partially linked objects. llvm-svn: 59699
This commit is contained in:
parent
3f656dfa03
commit
4d69fd4f1c
|
@ -52,6 +52,9 @@ check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO)
|
|||
check_symbol_exists(pthread_mutex_lock pthread.h HAVE_PTHREAD_MUTEX_LOCK)
|
||||
check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag("-fPIC" SUPPORTS_FPIC_FLAG)
|
||||
|
||||
include(GetTargetTriple)
|
||||
get_target_triple(LLVM_HOSTTRIPLE)
|
||||
message(STATUS "LLVM_HOSTTRIPLE: ${LLVM_HOSTTRIPLE}")
|
||||
|
|
|
@ -17,6 +17,9 @@ macro(add_partially_linked_object lib)
|
|||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/temp_lib)
|
||||
llvm_process_sources( ALL_FILES ${ARGN} )
|
||||
if( BUILD_SHARED_LIBS AND SUPPORTS_FPIC_FLAG )
|
||||
add_definitions(-fPIC)
|
||||
endif()
|
||||
add_library( ${lib} STATIC ${ALL_FILES})
|
||||
if( LLVM_COMMON_DEPENDS )
|
||||
add_dependencies( ${lib} ${LLVM_COMMON_DEPENDS} )
|
||||
|
|
Loading…
Reference in New Issue