[CMake] add_llvm_symbol_exports: Use ${native_export_file} instead of equivalent constant "symbol.*', since it is defined.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198163 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
NAKAMURA Takumi 2013-12-29 16:15:18 +00:00
parent 0809dc5b35
commit d9c7484430

View File

@ -5,28 +5,28 @@ include(LLVM-Config)
function(add_llvm_symbol_exports target_name export_file) function(add_llvm_symbol_exports target_name export_file)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(native_export_file "symbol.exports") set(native_export_file "symbol.exports")
add_custom_command(OUTPUT symbol.exports add_custom_command(OUTPUT ${native_export_file}
COMMAND sed -e "s/^/_/" < ${export_file} > symbol.exports COMMAND sed -e "s/^/_/" < ${export_file} > ${native_export_file}
DEPENDS ${export_file} DEPENDS ${export_file}
VERBATIM VERBATIM
COMMENT "Creating export file for ${target_name}") COMMENT "Creating export file for ${target_name}")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/symbol.exports") LINK_FLAGS " -Wl,-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
elseif(LLVM_HAVE_LINK_VERSION_SCRIPT) elseif(LLVM_HAVE_LINK_VERSION_SCRIPT)
# Gold and BFD ld require a version script rather than a plain list. # Gold and BFD ld require a version script rather than a plain list.
set(native_export_file "symbol.exports") set(native_export_file "symbol.exports")
# FIXME: Don't write the "local:" line on OpenBSD. # FIXME: Don't write the "local:" line on OpenBSD.
add_custom_command(OUTPUT symbol.exports add_custom_command(OUTPUT ${native_export_file}
COMMAND echo "{" > symbol.exports COMMAND echo "{" > ${native_export_file}
COMMAND grep -q "[[:alnum:]]" ${export_file} && echo " global:" >> symbol.exports || : COMMAND grep -q "[[:alnum:]]" ${export_file} && echo " global:" >> ${native_export_file} || :
COMMAND sed -e "s/$/;/" -e "s/^/ /" < ${export_file} >> symbol.exports COMMAND sed -e "s/$/;/" -e "s/^/ /" < ${export_file} >> ${native_export_file}
COMMAND echo " local: *;" >> symbol.exports COMMAND echo " local: *;" >> ${native_export_file}
COMMAND echo "};" >> symbol.exports COMMAND echo "};" >> ${native_export_file}
DEPENDS ${export_file} DEPENDS ${export_file}
VERBATIM VERBATIM
COMMENT "Creating export file for ${target_name}") COMMENT "Creating export file for ${target_name}")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/symbol.exports") LINK_FLAGS " -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
else() else()
set(native_export_file "symbol.def") set(native_export_file "symbol.def")
@ -38,19 +38,18 @@ function(add_llvm_symbol_exports target_name export_file)
# Using ${export_file} in add_custom_command directly confuses cmd.exe. # Using ${export_file} in add_custom_command directly confuses cmd.exe.
file(TO_NATIVE_PATH ${export_file} export_file_backslashes) file(TO_NATIVE_PATH ${export_file} export_file_backslashes)
add_custom_command(OUTPUT symbol.def add_custom_command(OUTPUT ${native_export_file}
COMMAND ${CMAKE_COMMAND} -E echo "EXPORTS" > symbol.def COMMAND ${CMAKE_COMMAND} -E echo "EXPORTS" > ${native_export_file}
COMMAND ${CAT} ${export_file_backslashes} >> symbol.def COMMAND ${CAT} ${export_file_backslashes} >> ${native_export_file}
DEPENDS ${export_file} DEPENDS ${export_file}
VERBATIM VERBATIM
COMMENT "Creating export file for ${target_name}") COMMENT "Creating export file for ${target_name}")
if(CYGWIN OR MINGW) if(CYGWIN OR MINGW)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS "${CMAKE_CURRENT_BINARY_DIR}/symbol.def") LINK_FLAGS "${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
else() else()
set_property(TARGET ${target_name} APPEND_STRING PROPERTY set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/symbol.def") LINK_FLAGS " ${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
endif()
endif() endif()
add_custom_target(${target_name}_exports DEPENDS ${native_export_file}) add_custom_target(${target_name}_exports DEPENDS ${native_export_file})