diff options
author | Serge Pavlov <sepavloff@gmail.com> | 2017-03-21 04:03:24 +0000 |
---|---|---|
committer | Serge Pavlov <sepavloff@gmail.com> | 2017-03-21 04:03:24 +0000 |
commit | bbcc0db379f0d3db38fd8ea1a168805807df6a39 (patch) | |
tree | 27318f81a703c0db90714ce5eda988853ea3c9cd /cmake | |
parent | 9fe7c740276213df8a0a2eb419b227bf3a7f3227 (diff) |
Fix evaluation of LLVM_DEFINITIONS
CMake variable LLVM_DEFINITIONS collects preprocessor definitions provided
for host compiler that builds llvm components. A function
add_llvm_definitions was introduced in AddLLVMDefinitions.cmake to keep
track of these definitions and was intended to be a replacement for CMake
command add_definitions. Actually in many cases add_definitions is still
used and the content of LLVM_DEFINITIONS is not actual now. On the other
hand the current version of CMake allows getting set of definitions in a
more convenient way. This fix implements evaluation of the variable by
reading corresponding cmake property.
Differential Revision: https://reviews.llvm.org/D31125
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298336 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rwxr-xr-x | cmake/config-ix.cmake | 2 | ||||
-rw-r--r-- | cmake/modules/HandleLLVMOptions.cmake | 32 |
2 files changed, 23 insertions, 11 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 34c81fa2973d..e5050018046a 100755 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -244,7 +244,7 @@ endif() check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC) if( LLVM_USING_GLIBC ) - add_llvm_definitions( -D_GNU_SOURCE ) + add_definitions( -D_GNU_SOURCE ) endif() # This check requires _GNU_SOURCE if(HAVE_LIBPTHREAD) diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index 26c0216df0f9..dd44476bc996 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -8,7 +8,6 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) include(CheckCompilerVersion) include(HandleLLVMStdlib) -include(AddLLVMDefinitions) include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) @@ -253,10 +252,10 @@ if( MSVC_IDE ) "Number of parallel compiler jobs. 0 means use all processors. Default is 0.") if( NOT LLVM_COMPILER_JOBS STREQUAL "1" ) if( LLVM_COMPILER_JOBS STREQUAL "0" ) - add_llvm_definitions( /MP ) + add_definitions( /MP ) else() message(STATUS "Number of parallel compiler jobs set to " ${LLVM_COMPILER_JOBS}) - add_llvm_definitions( /MP${LLVM_COMPILER_JOBS} ) + add_definitions( /MP${LLVM_COMPILER_JOBS} ) endif() else() message(STATUS "Parallel compilation disabled") @@ -285,17 +284,17 @@ if( MSVC ) if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0 ) # For MSVC 2013, disable iterator null pointer checking in debug mode, # especially so std::equal(nullptr, nullptr, nullptr) will not assert. - add_llvm_definitions("-D_DEBUG_POINTER_IMPL=") + add_definitions("-D_DEBUG_POINTER_IMPL=") endif() include(ChooseMSVCCRT) if( MSVC11 ) - add_llvm_definitions(-D_VARIADIC_MAX=10) + add_definitions(-D_VARIADIC_MAX=10) endif() # Add definitions that make MSVC much less annoying. - add_llvm_definitions( + add_definitions( # For some reason MS wants to deprecate a bunch of standard functions... -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS @@ -306,7 +305,7 @@ if( MSVC ) ) # Tell MSVC to use the Unicode version of the Win32 APIs instead of ANSI. - add_llvm_definitions( + add_definitions( -DUNICODE -D_UNICODE ) @@ -646,9 +645,9 @@ if(LLVM_USE_SPLIT_DWARF) add_definitions("-gsplit-dwarf") endif() -add_llvm_definitions( -D__STDC_CONSTANT_MACROS ) -add_llvm_definitions( -D__STDC_FORMAT_MACROS ) -add_llvm_definitions( -D__STDC_LIMIT_MACROS ) +add_definitions( -D__STDC_CONSTANT_MACROS ) +add_definitions( -D__STDC_FORMAT_MACROS ) +add_definitions( -D__STDC_LIMIT_MACROS ) # clang doesn't print colored diagnostics when invoked from Ninja if (UNIX AND @@ -774,3 +773,16 @@ if(WIN32 OR CYGWIN) else() set(LLVM_ENABLE_PLUGINS ON) endif() + +function(get_compile_definitions) + get_directory_property(top_dir_definitions DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS) + foreach(definition ${top_dir_definitions}) + if(DEFINED result) + string(APPEND result " -D${definition}") + else() + set(result "-D${definition}") + endif() + endforeach() + set(LLVM_DEFINITIONS "${result}" PARENT_SCOPE) +endfunction() +get_compile_definitions() |