From eb961a307573efc14fff3d18f17add06e443cb54 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Mon, 10 Feb 2014 09:05:28 +0000 Subject: [PATCH] [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 --- clang/CMakeLists.txt | 50 +++++++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index e6fd46f..cfe32a0 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -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) - 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_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} ) + if(srcs OR ARG_ADDITIONAL_HEADERS) + set(srcs + ADDITIONAL_HEADERS + ${srcs} + ${ARG_ADDITIONAL_HEADERS} # It may contain unparsed unknown args. + ) endif() + llvm_add_library(${name} ${ARG_UNPARSED_ARGUMENTS} ${srcs}) - if (ARG_MODULE) - set_property(TARGET ${name} PROPERTY SUFFIX ${LLVM_PLUGIN_EXT}) - endif () + target_link_libraries( ${name} ${LLVM_COMMON_LIBS} ) if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang") install(TARGETS ${name} -- 2.7.4