@@ -2,6 +2,24 @@ include(LLVMParseArguments)
2
2
include (LLVMProcessSources )
3
3
include (LLVM-Config )
4
4
5
+ function (llvm_update_compile_flags name )
6
+ get_property (target_compile_flags TARGET ${name} PROPERTY COMPILE_FLAGS )
7
+ if (NOT "${LLVM_COMPILE_FLAGS} " STREQUAL "" )
8
+ set (target_compile_flags "${target_compile_flags} ${LLVM_COMPILE_FLAGS} " )
9
+ endif ()
10
+ if (LLVM_NO_RTTI )
11
+ list (APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_RTTI=0 )
12
+ if (LLVM_COMPILER_IS_GCC_COMPATIBLE )
13
+ set (target_compile_flags "${target_compile_flags} -fno-rtti" )
14
+ elseif (MSVC )
15
+ llvm_replace_compiler_option (target_compile_flags "/GR" "/GR-" )
16
+ endif ()
17
+ endif ()
18
+
19
+ set_property (TARGET ${name} PROPERTY COMPILE_FLAGS "${target_compile_flags} " )
20
+ set_property (TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS ${LLVM_COMPILE_DEFINITIONS} )
21
+ endfunction ()
22
+
5
23
function (add_llvm_symbol_exports target_name export_file )
6
24
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
7
25
set (native_export_file "${target_name} .exports" )
@@ -343,6 +361,23 @@ function(add_unittest test_suite test_name)
343
361
set (EXCLUDE_FROM_ALL ON )
344
362
endif ()
345
363
364
+ # Visual Studio 2012 only supports up to 8 template parameters in
365
+ # std::tr1::tuple by default, but gtest requires 10
366
+ if (MSVC AND MSVC_VERSION EQUAL 1700 )
367
+ list (APPEND LLVM_COMPILE_DEFINITIONS _VARIADIC_MAX=10 )
368
+ endif ()
369
+
370
+ include_directories (${LLVM_MAIN_SRC_DIR} /utils/unittest/googletest/include )
371
+ if (NOT LLVM_ENABLE_THREADS )
372
+ list (APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_PTHREAD=0 )
373
+ endif ()
374
+
375
+ if (SUPPORTS_NO_VARIADIC_MACROS_FLAG )
376
+ set (LLVM_COMPILE_FLAGS "-Wno-variadic-macros" )
377
+ endif ()
378
+
379
+ set (LLVM_NO_RTTI ON )
380
+
346
381
add_llvm_executable (${test_name} ${ARGN} )
347
382
set (outdir ${CMAKE_CURRENT_BINARY_DIR} /${CMAKE_CFG_INTDIR} )
348
383
set_output_directory (${test_name} ${outdir} ${outdir} )
@@ -357,30 +392,7 @@ function(add_unittest test_suite test_name)
357
392
if (NOT ${test_suite_folder} STREQUAL "NOTFOUND" )
358
393
set_property (TARGET ${test_name} PROPERTY FOLDER "${test_suite_folder} " )
359
394
endif ()
360
-
361
- # Visual Studio 2012 only supports up to 8 template parameters in
362
- # std::tr1::tuple by default, but gtest requires 10
363
- if (MSVC AND MSVC_VERSION EQUAL 1700 )
364
- set_property (TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS _VARIADIC_MAX=10 )
365
- endif ()
366
-
367
- include_directories (${LLVM_MAIN_SRC_DIR} /utils/unittest/googletest/include )
368
- set_property (TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS GTEST_HAS_RTTI=0 )
369
- if (NOT LLVM_ENABLE_THREADS )
370
- set_property (TARGET ${test_name} APPEND PROPERTY COMPILE_DEFINITIONS GTEST_HAS_PTHREAD=0 )
371
- endif ()
372
-
373
- get_property (target_compile_flags TARGET ${test_name} PROPERTY COMPILE_FLAGS )
374
- if (LLVM_COMPILER_IS_GCC_COMPATIBLE )
375
- set (target_compile_flags "${target_compile_flags} -fno-rtti" )
376
- elseif (MSVC )
377
- llvm_replace_compiler_option (target_compile_flags "/GR" "/GR-" )
378
- endif ()
379
-
380
- if (SUPPORTS_NO_VARIADIC_MACROS_FLAG )
381
- set (target_compile_flags "${target_compile_flags} -Wno-variadic-macros" )
382
- endif ()
383
- set_property (TARGET ${test_name} PROPERTY COMPILE_FLAGS "${target_compile_flags} " )
395
+ llvm_update_compile_flags (${test_name} )
384
396
endfunction ()
385
397
386
398
# This function provides an automatic way to 'configure'-like generate a file
0 commit comments