Alexey Samsonov | 02dcc63 | 2012-12-19 12:33:39 +0000 | [diff] [blame] | 1 | include(AddLLVM) |
Alexey Samsonov | 2e8e441 | 2014-05-09 22:11:03 +0000 | [diff] [blame] | 2 | include(ExternalProject) |
Alexey Samsonov | 02dcc63 | 2012-12-19 12:33:39 +0000 | [diff] [blame] | 3 | include(LLVMParseArguments) |
Alexey Samsonov | 392c50d | 2013-01-18 16:05:21 +0000 | [diff] [blame] | 4 | include(CompilerRTUtils) |
Alexey Samsonov | 02dcc63 | 2012-12-19 12:33:39 +0000 | [diff] [blame] | 5 | |
Alexey Samsonov | 392c50d | 2013-01-18 16:05:21 +0000 | [diff] [blame] | 6 | # Tries to add "object library" target for a given architecture |
| 7 | # with name "<name>.<arch>" if architecture can be targeted. |
| 8 | # add_compiler_rt_object_library(<name> <arch> |
| 9 | # SOURCES <source files> |
Alexey Samsonov | 05fa380 | 2013-09-16 15:50:53 +0000 | [diff] [blame] | 10 | # CFLAGS <compile flags> |
| 11 | # DEFS <compile definitions>) |
Alexey Samsonov | 392c50d | 2013-01-18 16:05:21 +0000 | [diff] [blame] | 12 | macro(add_compiler_rt_object_library name arch) |
| 13 | if(CAN_TARGET_${arch}) |
Alexey Samsonov | 05fa380 | 2013-09-16 15:50:53 +0000 | [diff] [blame] | 14 | parse_arguments(LIB "SOURCES;CFLAGS;DEFS" "" ${ARGN}) |
Alexey Samsonov | 392c50d | 2013-01-18 16:05:21 +0000 | [diff] [blame] | 15 | add_library(${name}.${arch} OBJECT ${LIB_SOURCES}) |
| 16 | set_target_compile_flags(${name}.${arch} |
Chandler Carruth | e7ad96d | 2014-05-15 15:21:11 +0000 | [diff] [blame] | 17 | ${CMAKE_CXX_FLAGS} ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS}) |
Alexey Samsonov | 05fa380 | 2013-09-16 15:50:53 +0000 | [diff] [blame] | 18 | set_property(TARGET ${name}.${arch} APPEND PROPERTY |
| 19 | COMPILE_DEFINITIONS ${LIB_DEFS}) |
Alexey Samsonov | 392c50d | 2013-01-18 16:05:21 +0000 | [diff] [blame] | 20 | else() |
| 21 | message(FATAL_ERROR "Archtecture ${arch} can't be targeted") |
| 22 | endif() |
| 23 | endmacro() |
| 24 | |
Alexander Potapenko | 4949674 | 2013-11-07 10:08:19 +0000 | [diff] [blame] | 25 | # Same as above, but adds universal osx library for either OSX or iOS simulator |
| 26 | # with name "<name>.<os>" targeting multiple architectures. |
| 27 | # add_compiler_rt_darwin_object_library(<name> <os> ARCH <architectures> |
| 28 | # SOURCES <source files> |
| 29 | # CFLAGS <compile flags> |
| 30 | # DEFS <compile definitions>) |
| 31 | macro(add_compiler_rt_darwin_object_library name os) |
Alexey Samsonov | 05fa380 | 2013-09-16 15:50:53 +0000 | [diff] [blame] | 32 | parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS" "" ${ARGN}) |
Alexander Potapenko | 4949674 | 2013-11-07 10:08:19 +0000 | [diff] [blame] | 33 | set(libname "${name}.${os}") |
Alexey Samsonov | 5162314 | 2013-01-20 14:36:12 +0000 | [diff] [blame] | 34 | add_library(${libname} OBJECT ${LIB_SOURCES}) |
Alexander Potapenko | 4949674 | 2013-11-07 10:08:19 +0000 | [diff] [blame] | 35 | set_target_compile_flags(${libname} ${LIB_CFLAGS} ${DARWIN_${os}_CFLAGS}) |
Alexey Samsonov | 2aad7c1 | 2013-01-21 08:12:20 +0000 | [diff] [blame] | 36 | set_target_properties(${libname} PROPERTIES OSX_ARCHITECTURES "${LIB_ARCH}") |
Alexey Samsonov | 05fa380 | 2013-09-16 15:50:53 +0000 | [diff] [blame] | 37 | set_property(TARGET ${libname} APPEND PROPERTY |
| 38 | COMPILE_DEFINITIONS ${LIB_DEFS}) |
Alexey Samsonov | 5162314 | 2013-01-20 14:36:12 +0000 | [diff] [blame] | 39 | endmacro() |
| 40 | |
Alexey Samsonov | e18b785 | 2014-03-31 13:45:36 +0000 | [diff] [blame] | 41 | # Adds static or shared runtime for a given architecture and puts it in the |
| 42 | # proper directory in the build and install trees. |
| 43 | # add_compiler_rt_runtime(<name> <arch> {STATIC,SHARED} |
| 44 | # SOURCES <source files> |
| 45 | # CFLAGS <compile flags> |
Evgeniy Stepanov | 4401473 | 2014-09-29 13:18:55 +0000 | [diff] [blame] | 46 | # DEFS <compile definitions> |
| 47 | # OUTPUT_NAME <output library name>) |
Alexey Samsonov | e18b785 | 2014-03-31 13:45:36 +0000 | [diff] [blame] | 48 | macro(add_compiler_rt_runtime name arch type) |
Alexey Samsonov | e16af95 | 2013-01-20 13:58:10 +0000 | [diff] [blame] | 49 | if(CAN_TARGET_${arch}) |
Alexey Samsonov | d6535ea | 2014-04-01 13:16:30 +0000 | [diff] [blame] | 50 | parse_arguments(LIB "SOURCES;CFLAGS;DEFS;OUTPUT_NAME" "" ${ARGN}) |
Alexey Samsonov | e18b785 | 2014-03-31 13:45:36 +0000 | [diff] [blame] | 51 | add_library(${name} ${type} ${LIB_SOURCES}) |
Alexey Samsonov | e16af95 | 2013-01-20 13:58:10 +0000 | [diff] [blame] | 52 | # Setup compile flags and definitions. |
| 53 | set_target_compile_flags(${name} |
| 54 | ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS}) |
Aaron Ballman | 208eae3 | 2014-10-29 19:25:20 +0000 | [diff] [blame] | 55 | set_target_link_flags(${name} |
| 56 | ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS}) |
Alexey Samsonov | e16af95 | 2013-01-20 13:58:10 +0000 | [diff] [blame] | 57 | set_property(TARGET ${name} APPEND PROPERTY |
| 58 | COMPILE_DEFINITIONS ${LIB_DEFS}) |
| 59 | # Setup correct output directory in the build tree. |
| 60 | set_target_properties(${name} PROPERTIES |
Alexey Samsonov | e18b785 | 2014-03-31 13:45:36 +0000 | [diff] [blame] | 61 | ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR} |
Hans Wennborg | b89adc4 | 2014-12-04 21:01:49 +0000 | [diff] [blame] | 62 | LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR} |
| 63 | RUNTIME_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}) |
Evgeniy Stepanov | 4401473 | 2014-09-29 13:18:55 +0000 | [diff] [blame] | 64 | if ("${LIB_OUTPUT_NAME}" STREQUAL "") |
| 65 | set_target_properties(${name} PROPERTIES |
| 66 | OUTPUT_NAME ${name}${COMPILER_RT_OS_SUFFIX}) |
| 67 | else() |
Alexey Samsonov | d6535ea | 2014-04-01 13:16:30 +0000 | [diff] [blame] | 68 | set_target_properties(${name} PROPERTIES |
| 69 | OUTPUT_NAME ${LIB_OUTPUT_NAME}) |
| 70 | endif() |
Alexey Samsonov | e16af95 | 2013-01-20 13:58:10 +0000 | [diff] [blame] | 71 | # Add installation command. |
| 72 | install(TARGETS ${name} |
Alexey Samsonov | e18b785 | 2014-03-31 13:45:36 +0000 | [diff] [blame] | 73 | ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR} |
Hans Wennborg | b89adc4 | 2014-12-04 21:01:49 +0000 | [diff] [blame] | 74 | LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR} |
| 75 | RUNTIME DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) |
Alexey Samsonov | e16af95 | 2013-01-20 13:58:10 +0000 | [diff] [blame] | 76 | else() |
| 77 | message(FATAL_ERROR "Archtecture ${arch} can't be targeted") |
| 78 | endif() |
| 79 | endmacro() |
| 80 | |
Alexey Samsonov | e18b785 | 2014-03-31 13:45:36 +0000 | [diff] [blame] | 81 | # Same as add_compiler_rt_runtime(... STATIC), but creates a universal library |
Alexey Samsonov | 2aad7c1 | 2013-01-21 08:12:20 +0000 | [diff] [blame] | 82 | # for several architectures. |
| 83 | # add_compiler_rt_osx_static_runtime(<name> ARCH <architectures> |
| 84 | # SOURCES <source files> |
| 85 | # CFLAGS <compile flags> |
| 86 | # DEFS <compile definitions>) |
| 87 | macro(add_compiler_rt_osx_static_runtime name) |
| 88 | parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS" "" ${ARGN}) |
| 89 | add_library(${name} STATIC ${LIB_SOURCES}) |
| 90 | set_target_compile_flags(${name} ${LIB_CFLAGS}) |
| 91 | set_property(TARGET ${name} APPEND PROPERTY |
| 92 | COMPILE_DEFINITIONS ${LIB_DEFS}) |
| 93 | set_target_properties(${name} PROPERTIES |
| 94 | OSX_ARCHITECTURES "${LIB_ARCH}" |
| 95 | ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}) |
| 96 | install(TARGETS ${name} |
| 97 | ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) |
| 98 | endmacro() |
| 99 | |
Alexander Potapenko | 4949674 | 2013-11-07 10:08:19 +0000 | [diff] [blame] | 100 | # Adds dynamic runtime library on osx/iossim, which supports multiple |
| 101 | # architectures. |
| 102 | # add_compiler_rt_darwin_dynamic_runtime(<name> <os> |
| 103 | # ARCH <architectures> |
| 104 | # SOURCES <source files> |
| 105 | # CFLAGS <compile flags> |
| 106 | # DEFS <compile definitions> |
| 107 | # LINKFLAGS <link flags>) |
| 108 | macro(add_compiler_rt_darwin_dynamic_runtime name os) |
Alexey Samsonov | 2aad7c1 | 2013-01-21 08:12:20 +0000 | [diff] [blame] | 109 | parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS;LINKFLAGS" "" ${ARGN}) |
| 110 | add_library(${name} SHARED ${LIB_SOURCES}) |
Alexander Potapenko | 4949674 | 2013-11-07 10:08:19 +0000 | [diff] [blame] | 111 | set_target_compile_flags(${name} ${LIB_CFLAGS} ${DARWIN_${os}_CFLAGS}) |
| 112 | set_target_link_flags(${name} ${LIB_LINKFLAGS} ${DARWIN_${os}_LINKFLAGS}) |
Alexey Samsonov | 2aad7c1 | 2013-01-21 08:12:20 +0000 | [diff] [blame] | 113 | set_property(TARGET ${name} APPEND PROPERTY |
| 114 | COMPILE_DEFINITIONS ${LIB_DEFS}) |
| 115 | set_target_properties(${name} PROPERTIES |
| 116 | OSX_ARCHITECTURES "${LIB_ARCH}" |
| 117 | LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}) |
| 118 | install(TARGETS ${name} |
| 119 | LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) |
| 120 | endmacro() |
| 121 | |
Timur Iskhodzhanov | a73e9db | 2014-05-30 12:42:57 +0000 | [diff] [blame] | 122 | set(COMPILER_RT_TEST_CFLAGS) |
| 123 | |
Alexey Samsonov | 392c50d | 2013-01-18 16:05:21 +0000 | [diff] [blame] | 124 | # Unittests support. |
Alexey Samsonov | 02dcc63 | 2012-12-19 12:33:39 +0000 | [diff] [blame] | 125 | set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest) |
Chandler Carruth | ace5350 | 2013-11-15 10:21:15 +0000 | [diff] [blame] | 126 | set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/src/gtest-all.cc) |
Alexey Samsonov | 1e5d8be | 2014-03-24 13:29:20 +0000 | [diff] [blame] | 127 | set(COMPILER_RT_GTEST_CFLAGS |
Alexey Samsonov | 02dcc63 | 2012-12-19 12:33:39 +0000 | [diff] [blame] | 128 | -DGTEST_NO_LLVM_RAW_OSTREAM=1 |
Timur Iskhodzhanov | 402bcb5 | 2014-05-28 08:38:13 +0000 | [diff] [blame] | 129 | -DGTEST_HAS_RTTI=0 |
Alexey Samsonov | 02dcc63 | 2012-12-19 12:33:39 +0000 | [diff] [blame] | 130 | -I${COMPILER_RT_GTEST_PATH}/include |
Chandler Carruth | ace5350 | 2013-11-15 10:21:15 +0000 | [diff] [blame] | 131 | -I${COMPILER_RT_GTEST_PATH} |
Alexey Samsonov | 02dcc63 | 2012-12-19 12:33:39 +0000 | [diff] [blame] | 132 | ) |
| 133 | |
Alexey Samsonov | 001d038 | 2015-01-06 20:58:40 +0000 | [diff] [blame^] | 134 | append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 COMPILER_RT_TEST_CFLAGS) |
| 135 | |
Timur Iskhodzhanov | 402bcb5 | 2014-05-28 08:38:13 +0000 | [diff] [blame] | 136 | if(MSVC) |
Timur Iskhodzhanov | a73e9db | 2014-05-30 12:42:57 +0000 | [diff] [blame] | 137 | # clang doesn't support exceptions on Windows yet. |
Alexey Samsonov | 001d038 | 2015-01-06 20:58:40 +0000 | [diff] [blame^] | 138 | list(APPEND COMPILER_RT_TEST_CFLAGS -D_HAS_EXCEPTIONS=0) |
Timur Iskhodzhanov | a73e9db | 2014-05-30 12:42:57 +0000 | [diff] [blame] | 139 | |
| 140 | # We should teach clang to understand "#pragma intrinsic", see PR19898. |
| 141 | list(APPEND COMPILER_RT_TEST_CFLAGS -Wno-undefined-inline) |
| 142 | |
Timur Iskhodzhanov | 402bcb5 | 2014-05-28 08:38:13 +0000 | [diff] [blame] | 143 | # Clang doesn't support SEH on Windows yet. |
| 144 | list(APPEND COMPILER_RT_GTEST_CFLAGS -DGTEST_HAS_SEH=0) |
Timur Iskhodzhanov | a73e9db | 2014-05-30 12:42:57 +0000 | [diff] [blame] | 145 | |
| 146 | # gtest use a lot of stuff marked as deprecated on Windows. |
| 147 | list(APPEND COMPILER_RT_GTEST_CFLAGS -Wno-deprecated-declarations) |
Ehsan Akhgari | 1c4db80 | 2014-09-15 11:33:50 +0000 | [diff] [blame] | 148 | |
| 149 | # Visual Studio 2012 only supports up to 8 template parameters in |
| 150 | # std::tr1::tuple by default, but gtest requires 10 |
| 151 | if(MSVC_VERSION EQUAL 1700) |
Ehsan Akhgari | 494410f | 2014-09-25 20:42:49 +0000 | [diff] [blame] | 152 | list(APPEND COMPILER_RT_GTEST_CFLAGS -D_VARIADIC_MAX=10) |
Ehsan Akhgari | 1c4db80 | 2014-09-15 11:33:50 +0000 | [diff] [blame] | 153 | endif() |
Timur Iskhodzhanov | 402bcb5 | 2014-05-28 08:38:13 +0000 | [diff] [blame] | 154 | endif() |
| 155 | |
Alexey Samsonov | 17cf7c5 | 2014-02-19 13:01:03 +0000 | [diff] [blame] | 156 | # Link objects into a single executable with COMPILER_RT_TEST_COMPILER, |
| 157 | # using specified link flags. Make executable a part of provided |
Alexey Samsonov | 02dcc63 | 2012-12-19 12:33:39 +0000 | [diff] [blame] | 158 | # test_suite. |
| 159 | # add_compiler_rt_test(<test_suite> <test_name> |
Alexey Samsonov | 431f94d | 2014-12-17 23:14:01 +0000 | [diff] [blame] | 160 | # SUBDIR <subdirectory for binary> |
Alexey Samsonov | 02dcc63 | 2012-12-19 12:33:39 +0000 | [diff] [blame] | 161 | # OBJECTS <object files> |
| 162 | # DEPS <deps (e.g. runtime libs)> |
| 163 | # LINK_FLAGS <link flags>) |
| 164 | macro(add_compiler_rt_test test_suite test_name) |
Alexey Samsonov | 431f94d | 2014-12-17 23:14:01 +0000 | [diff] [blame] | 165 | parse_arguments(TEST "SUBDIR;OBJECTS;DEPS;LINK_FLAGS" "" ${ARGN}) |
| 166 | if(TEST_SUBDIR) |
| 167 | set(output_bin "${CMAKE_CURRENT_BINARY_DIR}/${TEST_SUBDIR}/${test_name}") |
| 168 | else() |
| 169 | set(output_bin "${CMAKE_CURRENT_BINARY_DIR}/${test_name}") |
| 170 | endif() |
Alexey Samsonov | 17cf7c5 | 2014-02-19 13:01:03 +0000 | [diff] [blame] | 171 | # Use host compiler in a standalone build, and just-built Clang otherwise. |
| 172 | if(NOT COMPILER_RT_STANDALONE_BUILD) |
| 173 | list(APPEND TEST_DEPS clang) |
| 174 | endif() |
Chandler Carruth | 272eef9 | 2014-05-15 16:33:58 +0000 | [diff] [blame] | 175 | # If we're not on MSVC, include the linker flags from CMAKE but override them |
| 176 | # with the provided link flags. This ensures that flags which are required to |
| 177 | # link programs at all are included, but the changes needed for the test |
| 178 | # trump. With MSVC we can't do that because CMake is set up to run link.exe |
| 179 | # when linking, not the compiler. Here, we hack it to use the compiler |
| 180 | # because we want to use -fsanitize flags. |
| 181 | if(NOT MSVC) |
| 182 | set(TEST_LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${TEST_LINK_FLAGS}") |
| 183 | separate_arguments(TEST_LINK_FLAGS) |
| 184 | endif() |
Alexey Samsonov | a74424e | 2013-01-28 09:07:30 +0000 | [diff] [blame] | 185 | add_custom_target(${test_name} |
Timur Iskhodzhanov | 7c70734 | 2014-05-12 08:55:20 +0000 | [diff] [blame] | 186 | COMMAND ${COMPILER_RT_TEST_COMPILER} ${TEST_OBJECTS} |
Timur Iskhodzhanov | 402bcb5 | 2014-05-28 08:38:13 +0000 | [diff] [blame] | 187 | -o "${output_bin}" |
Alexey Samsonov | 02dcc63 | 2012-12-19 12:33:39 +0000 | [diff] [blame] | 188 | ${TEST_LINK_FLAGS} |
Alexey Samsonov | 17cf7c5 | 2014-02-19 13:01:03 +0000 | [diff] [blame] | 189 | DEPENDS ${TEST_DEPS}) |
Alexey Samsonov | 02dcc63 | 2012-12-19 12:33:39 +0000 | [diff] [blame] | 190 | # Make the test suite depend on the binary. |
| 191 | add_dependencies(${test_suite} ${test_name}) |
| 192 | endmacro() |
Alexey Samsonov | c1caace | 2013-05-21 13:48:27 +0000 | [diff] [blame] | 193 | |
| 194 | macro(add_compiler_rt_resource_file target_name file_name) |
| 195 | set(src_file "${CMAKE_CURRENT_SOURCE_DIR}/${file_name}") |
Alexey Samsonov | a52e2dc | 2014-02-18 14:28:53 +0000 | [diff] [blame] | 196 | set(dst_file "${COMPILER_RT_OUTPUT_DIR}/${file_name}") |
Alexey Samsonov | 41bf0bc | 2014-02-27 07:22:59 +0000 | [diff] [blame] | 197 | add_custom_command(OUTPUT ${dst_file} |
| 198 | DEPENDS ${src_file} |
Alexey Samsonov | c1caace | 2013-05-21 13:48:27 +0000 | [diff] [blame] | 199 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src_file} ${dst_file} |
Alexey Samsonov | 41bf0bc | 2014-02-27 07:22:59 +0000 | [diff] [blame] | 200 | COMMENT "Copying ${file_name}...") |
| 201 | add_custom_target(${target_name} DEPENDS ${dst_file}) |
Alexey Samsonov | c1caace | 2013-05-21 13:48:27 +0000 | [diff] [blame] | 202 | # Install in Clang resource directory. |
Alexey Samsonov | a52e2dc | 2014-02-18 14:28:53 +0000 | [diff] [blame] | 203 | install(FILES ${file_name} DESTINATION ${COMPILER_RT_INSTALL_PATH}) |
Alexey Samsonov | c1caace | 2013-05-21 13:48:27 +0000 | [diff] [blame] | 204 | endmacro() |
Evgeniy Stepanov | 9514ed1 | 2014-02-27 08:41:40 +0000 | [diff] [blame] | 205 | |
| 206 | macro(add_compiler_rt_script name) |
| 207 | set(dst ${COMPILER_RT_EXEC_OUTPUT_DIR}/${name}) |
| 208 | set(src ${CMAKE_CURRENT_SOURCE_DIR}/${name}) |
| 209 | add_custom_command(OUTPUT ${dst} |
| 210 | DEPENDS ${src} |
| 211 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} |
| 212 | COMMENT "Copying ${name}...") |
| 213 | add_custom_target(${name} DEPENDS ${dst}) |
| 214 | install(FILES ${dst} |
| 215 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE |
| 216 | DESTINATION ${COMPILER_RT_INSTALL_PATH}/bin) |
| 217 | endmacro(add_compiler_rt_script src name) |
Alexey Samsonov | 2e8e441 | 2014-05-09 22:11:03 +0000 | [diff] [blame] | 218 | |
| 219 | # Builds custom version of libc++ and installs it in <prefix>. |
| 220 | # Can be used to build sanitized versions of libc++ for running unit tests. |
| 221 | # add_custom_libcxx(<name> <prefix> |
| 222 | # DEPS <list of build deps> |
| 223 | # CFLAGS <list of compile flags>) |
| 224 | macro(add_custom_libcxx name prefix) |
| 225 | if(NOT COMPILER_RT_HAS_LIBCXX_SOURCES) |
| 226 | message(FATAL_ERROR "libcxx not found!") |
| 227 | endif() |
| 228 | |
| 229 | parse_arguments(LIBCXX "DEPS;CFLAGS" "" ${ARGN}) |
| 230 | foreach(flag ${LIBCXX_CFLAGS}) |
| 231 | set(flagstr "${flagstr} ${flag}") |
| 232 | endforeach() |
| 233 | set(LIBCXX_CFLAGS ${flagstr}) |
| 234 | |
| 235 | if(NOT COMPILER_RT_STANDALONE_BUILD) |
| 236 | list(APPEND LIBCXX_DEPS clang) |
| 237 | endif() |
| 238 | |
| 239 | ExternalProject_Add(${name} |
| 240 | PREFIX ${prefix} |
| 241 | SOURCE_DIR ${COMPILER_RT_LIBCXX_PATH} |
| 242 | CMAKE_ARGS -DCMAKE_C_COMPILER=${COMPILER_RT_TEST_COMPILER} |
| 243 | -DCMAKE_CXX_COMPILER=${COMPILER_RT_TEST_COMPILER} |
| 244 | -DCMAKE_C_FLAGS=${LIBCXX_CFLAGS} |
| 245 | -DCMAKE_CXX_FLAGS=${LIBCXX_CFLAGS} |
| 246 | -DCMAKE_BUILD_TYPE=Release |
| 247 | -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> |
Alexey Samsonov | 19de1ba | 2014-05-12 21:07:28 +0000 | [diff] [blame] | 248 | LOG_BUILD 1 |
| 249 | LOG_CONFIGURE 1 |
| 250 | LOG_INSTALL 1 |
Alexey Samsonov | 2e8e441 | 2014-05-09 22:11:03 +0000 | [diff] [blame] | 251 | ) |
| 252 | |
| 253 | ExternalProject_Add_Step(${name} force-reconfigure |
| 254 | DEPENDERS configure |
| 255 | ALWAYS 1 |
| 256 | ) |
| 257 | |
| 258 | ExternalProject_Add_Step(${name} clobber |
| 259 | COMMAND ${CMAKE_COMMAND} -E remove_directory <BINARY_DIR> |
| 260 | COMMAND ${CMAKE_COMMAND} -E make_directory <BINARY_DIR> |
| 261 | COMMENT "Clobberring ${name} build directory..." |
| 262 | DEPENDERS configure |
| 263 | DEPENDS ${LIBCXX_DEPS} |
| 264 | ) |
| 265 | endmacro() |