[CMake] add_clang_library(): Use llvm_add_library.

CMAKE_MODULE_LINKER_FLAGS can be removed since llvm_add_library(MODULE) adds same flags to MODULE.

llvm-svn: 201073
This commit is contained in:
NAKAMURA Takumi 2014-02-10 09:05:28 +00:00
parent e7038dfeaa
commit eb961a3075
1 changed files with 16 additions and 32 deletions

View File

@ -236,10 +236,6 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
endif()
endif ()
if (APPLE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
endif ()
configure_file(
${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
${CLANG_BINARY_DIR}/include/clang/Config/config.h)
@ -276,8 +272,12 @@ function(clang_tablegen)
endfunction(clang_tablegen)
macro(add_clang_library name)
cmake_parse_arguments(ARG "MODULE;SHARED;STATIC" "" "" ${ARGN})
llvm_process_sources(srcs ${ARG_UNPARSED_ARGUMENTS})
cmake_parse_arguments(ARG
""
""
"ADDITIONAL_HEADERS"
${ARGN})
set(srcs)
if(MSVC_IDE OR XCODE)
# Add public headers
file(RELATIVE_PATH lib_path
@ -297,37 +297,21 @@ macro(add_clang_library name)
source_group("TableGen descriptions" FILES ${tds})
set_source_files_properties(${tds}} PROPERTIES HEADER_FILE_ONLY ON)
set(srcs ${srcs} ${headers} ${tds})
if(headers OR tds)
set(srcs ${headers} ${tds})
endif()
endif()
endif(MSVC_IDE OR XCODE)
if (ARG_MODULE)
set(libkind MODULE)
elseif (ARG_SHARED)
set(libkind SHARED)
elseif(ARG_STATIC)
set(libkind STATIC)
else()
set(libkind)
if(srcs OR ARG_ADDITIONAL_HEADERS)
set(srcs
ADDITIONAL_HEADERS
${srcs}
${ARG_ADDITIONAL_HEADERS} # It may contain unparsed unknown args.
)
endif()
add_library( ${name} ${libkind} ${srcs} )
llvm_update_compile_flags(${name} ${ALL_FILES})
add_dead_strip( ${name} )
set_output_directory(${name} ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
if( LLVM_COMMON_DEPENDS )
add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
endif( LLVM_COMMON_DEPENDS )
llvm_add_library(${name} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
llvm_config( ${name} ${LLVM_LINK_COMPONENTS} )
target_link_libraries( ${name} ${LLVM_COMMON_LIBS} )
link_system_libs( ${name} )
if ((ARG_SHARED OR ARG_MODULE) AND LLVM_EXPORTED_SYMBOL_FILE)
add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
endif()
if (ARG_MODULE)
set_property(TARGET ${name} PROPERTY SUFFIX ${LLVM_PLUGIN_EXT})
endif ()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang")
install(TARGETS ${name}