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
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
index 77f59cd..52cbe35 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 "<name>.<arch>" for non-Darwin platforms if
# architecture can be targeted, and "<name>.<os>" for Darwin platforms.
# add_compiler_rt_object_libraries(<name>
-# OS <os>
-# ARCH <arch>
+# OS <os names>
+# ARCHS <architectures>
# SOURCES <source files>
# CFLAGS <compile flags>
# DEFS <compile definitions>)
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 @@
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 @@
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 @@
# OUTPUT_NAME <output library 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 @@
# Same as add_compiler_rt_runtime(... STATIC), but creates a universal library
# for several architectures.
-# add_compiler_rt_osx_static_runtime(<name> ARCH <architectures>
+# add_compiler_rt_osx_static_runtime(<name> ARCHS <architectures>
# SOURCES <source files>
# CFLAGS <compile flags>
# DEFS <compile definitions>)
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 @@
# Adds dynamic runtime library on osx/iossim, which supports multiple
# architectures.
# add_compiler_rt_darwin_dynamic_runtime(<name> <os>
-# ARCH <architectures>
+# ARCHS <architectures>
# SOURCES <source files>
# CFLAGS <compile flags>
# DEFS <compile definitions>
# LINKFLAGS <link flags>)
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 @@
# DEPS <deps (e.g. runtime libs)>
# LINK_FLAGS <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 @@
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()