From c309de7c43088f55035694a13d4fa65e437a932a Mon Sep 17 00:00:00 2001 From: Filipe Cabecinhas Date: Fri, 19 Jun 2015 03:39:24 +0000 Subject: CMake: Stop using LLVM's custom parse_arguments. NFC Summary: Use CMake's cmake_parse_arguments() instead. It's called in a slightly different way, but supports all our use cases. It's in CMake 2.8.8, which is our minimum supported version. CMake 3.0 doc (roughly the same. No direct link to 2.8.8 doc): http://www.cmake.org/cmake/help/v3.0/module/CMakeParseArguments.html?highlight=cmake_parse_arguments Since I was already changing these calls, I changed ARCH and LIB into ARCHS and LIBS to make it more clear that they're lists of arguments. Reviewers: eugenis, samsonov, beanz Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10529 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240120 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/Modules/AddCompilerRT.cmake | 29 ++++++++++++++--------------- cmake/Modules/CompilerRTCompile.cmake | 4 +--- cmake/Modules/CompilerRTLink.cmake | 4 +--- cmake/Modules/SanitizerUtils.cmake | 8 +++----- 4 files changed, 19 insertions(+), 26 deletions(-) (limited to 'cmake') diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake index 77f59cdce..52cbe35dd 100644 --- a/cmake/Modules/AddCompilerRT.cmake +++ b/cmake/Modules/AddCompilerRT.cmake @@ -1,19 +1,18 @@ include(AddLLVM) include(ExternalProject) -include(LLVMParseArguments) include(CompilerRTUtils) # Tries to add an "object library" target for a given list of OSs and/or # architectures with name "." for non-Darwin platforms if # architecture can be targeted, and "." for Darwin platforms. # add_compiler_rt_object_libraries( -# OS -# ARCH +# OS +# ARCHS # SOURCES # CFLAGS # DEFS ) function(add_compiler_rt_object_libraries name) - parse_arguments(LIB "OS;ARCH;SOURCES;CFLAGS;DEFS" "" ${ARGN}) + cmake_parse_arguments(LIB "" "" "OS;ARCHS;SOURCES;CFLAGS;DEFS" ${ARGN}) set(libnames) if(APPLE) foreach(os ${LIB_OS}) @@ -22,7 +21,7 @@ function(add_compiler_rt_object_libraries name) set(extra_cflags_${libname} ${DARWIN_${os}_CFLAGS}) endforeach() else() - foreach(arch ${LIB_ARCH}) + foreach(arch ${LIB_ARCHS}) set(libname "${name}.${arch}") set(libnames ${libnames} ${libname}) set(extra_cflags_${libname} ${TARGET_${arch}_CFLAGS}) @@ -40,7 +39,7 @@ function(add_compiler_rt_object_libraries name) set_property(TARGET ${libname} APPEND PROPERTY COMPILE_DEFINITIONS ${LIB_DEFS}) if(APPLE) - set_target_properties(${libname} PROPERTIES OSX_ARCHITECTURES "${LIB_ARCH}") + set_target_properties(${libname} PROPERTIES OSX_ARCHITECTURES "${LIB_ARCHS}") endif() endforeach() endfunction() @@ -54,7 +53,7 @@ endfunction() # OUTPUT_NAME ) macro(add_compiler_rt_runtime name arch type) if(CAN_TARGET_${arch}) - parse_arguments(LIB "SOURCES;CFLAGS;LINKFLAGS;DEFS;OUTPUT_NAME" "" ${ARGN}) + cmake_parse_arguments(LIB "" "OUTPUT_NAME" "SOURCES;CFLAGS;LINKFLAGS;DEFS" ${ARGN}) add_library(${name} ${type} ${LIB_SOURCES}) # Setup compile flags and definitions. set_target_compile_flags(${name} @@ -87,18 +86,18 @@ endmacro() # Same as add_compiler_rt_runtime(... STATIC), but creates a universal library # for several architectures. -# add_compiler_rt_osx_static_runtime( ARCH +# add_compiler_rt_osx_static_runtime( ARCHS # SOURCES # CFLAGS # DEFS ) macro(add_compiler_rt_osx_static_runtime name) - parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS" "" ${ARGN}) + cmake_parse_arguments(LIB "" "" "ARCHS;SOURCES;CFLAGS;DEFS" ${ARGN}) add_library(${name} STATIC ${LIB_SOURCES}) set_target_compile_flags(${name} ${LIB_CFLAGS}) set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS ${LIB_DEFS}) set_target_properties(${name} PROPERTIES - OSX_ARCHITECTURES "${LIB_ARCH}" + OSX_ARCHITECTURES "${LIB_ARCHS}" ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}) install(TARGETS ${name} ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) @@ -107,20 +106,20 @@ endmacro() # Adds dynamic runtime library on osx/iossim, which supports multiple # architectures. # add_compiler_rt_darwin_dynamic_runtime( -# ARCH +# ARCHS # SOURCES # CFLAGS # DEFS # LINKFLAGS ) macro(add_compiler_rt_darwin_dynamic_runtime name os) - parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS;LINKFLAGS" "" ${ARGN}) + cmake_parse_arguments(LIB "" "" "ARCHS;SOURCES;CFLAGS;DEFS;LINKFLAGS" ${ARGN}) add_library(${name} SHARED ${LIB_SOURCES}) set_target_compile_flags(${name} ${LIB_CFLAGS} ${DARWIN_${os}_CFLAGS}) set_target_link_flags(${name} ${LIB_LINKFLAGS} ${DARWIN_${os}_LINKFLAGS}) set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS ${LIB_DEFS}) set_target_properties(${name} PROPERTIES - OSX_ARCHITECTURES "${LIB_ARCH}" + OSX_ARCHITECTURES "${LIB_ARCHS}" LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}) install(TARGETS ${name} LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) @@ -169,7 +168,7 @@ endif() # DEPS # LINK_FLAGS ) macro(add_compiler_rt_test test_suite test_name) - parse_arguments(TEST "SUBDIR;OBJECTS;DEPS;LINK_FLAGS" "" ${ARGN}) + cmake_parse_arguments(TEST "" "SUBDIR" "OBJECTS;DEPS;LINK_FLAGS" "" ${ARGN}) if(TEST_SUBDIR) set(output_bin "${CMAKE_CURRENT_BINARY_DIR}/${TEST_SUBDIR}/${test_name}") else() @@ -236,7 +235,7 @@ macro(add_custom_libcxx name prefix) message(FATAL_ERROR "libcxx not found!") endif() - parse_arguments(LIBCXX "DEPS;CFLAGS" "" ${ARGN}) + cmake_parse_arguments(LIBCXX "" "" "DEPS;CFLAGS" ${ARGN}) foreach(flag ${LIBCXX_CFLAGS}) set(flagstr "${flagstr} ${flag}") endforeach() diff --git a/cmake/Modules/CompilerRTCompile.cmake b/cmake/Modules/CompilerRTCompile.cmake index c883e43aa..b2e62dd0b 100644 --- a/cmake/Modules/CompilerRTCompile.cmake +++ b/cmake/Modules/CompilerRTCompile.cmake @@ -1,5 +1,3 @@ -include(LLVMParseArguments) - # On Windows, CMAKE_*_FLAGS are built for MSVC but we use the GCC clang.exe, # which uses completely different flags. Translate some common flag types, and # drop the rest. @@ -32,7 +30,7 @@ endfunction() # CFLAGS # DEPS ) macro(clang_compile object_file source) - parse_arguments(SOURCE "CFLAGS;DEPS" "" ${ARGN}) + cmake_parse_arguments(SOURCE "" "" "CFLAGS;DEPS" ${ARGN}) get_filename_component(source_rpath ${source} REALPATH) if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND SOURCE_DEPS clang compiler-rt-headers) diff --git a/cmake/Modules/CompilerRTLink.cmake b/cmake/Modules/CompilerRTLink.cmake index 0f0e53a3b..bb9686984 100644 --- a/cmake/Modules/CompilerRTLink.cmake +++ b/cmake/Modules/CompilerRTLink.cmake @@ -1,12 +1,10 @@ -include(LLVMParseArguments) - # Link a shared library with COMPILER_RT_TEST_COMPILER. # clang_link_shared( # OBJECTS # LINKFLAGS # DEPS ) macro(clang_link_shared so_file) - parse_arguments(SOURCE "OBJECTS;LINKFLAGS;DEPS" "" ${ARGN}) + cmake_parse_arguments(SOURCE "" "" "OBJECTS;LINKFLAGS;DEPS" ${ARGN}) if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND SOURCE_DEPS clang) endif() diff --git a/cmake/Modules/SanitizerUtils.cmake b/cmake/Modules/SanitizerUtils.cmake index 1e8e89daa..c040b4212 100644 --- a/cmake/Modules/SanitizerUtils.cmake +++ b/cmake/Modules/SanitizerUtils.cmake @@ -1,5 +1,3 @@ -include(LLVMParseArguments) - set(SANITIZER_GEN_DYNAMIC_LIST ${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/scripts/gen_dynamic_list.py) @@ -50,19 +48,19 @@ endmacro() macro(add_sanitizer_rt_version_list name) set(vers ${CMAKE_CURRENT_BINARY_DIR}/${name}.vers) - parse_arguments(ARG "LIB;EXTRA" "" ${ARGN}) + cmake_parse_arguments(ARG "" "" "LIBS;EXTRA" ${ARGN}) set(args) foreach(arg ${ARG_EXTRA}) list(APPEND args "--extra" ${arg}) endforeach() - foreach(arg ${ARG_LIB}) + foreach(arg ${ARG_LIBS}) list(APPEND args "$") endforeach() add_custom_command(OUTPUT ${vers} COMMAND ${PYTHON_EXECUTABLE} ${SANITIZER_GEN_DYNAMIC_LIST} --version-list ${args} > ${vers} - DEPENDS ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA} ${ARG_LIB} + DEPENDS ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA} ${ARG_LIBS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Generating version list for ${name}" VERBATIM) -- cgit v1.2.3