aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-03-14 10:51:38 +0000
committerAlexander Kornienko <alexfh@google.com>2013-03-14 10:51:38 +0000
commit647735c781c5b37061ee03d6e9e6c7dda92218e2 (patch)
tree5a5e56606d41060263048b5a5586b3d2380898ba /cmake
parent6aed25d93d1cfcde5809a73ffa7dc1b0d6396f66 (diff)
parentf635ef401786c84df32090251a8cf45981ecca33 (diff)
Updating branches/google/stable to r176857
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/google/stable@177040 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rwxr-xr-xcmake/config-ix.cmake31
-rwxr-xr-xcmake/modules/AddLLVM.cmake34
-rw-r--r--cmake/modules/HandleLLVMOptions.cmake45
-rwxr-xr-xcmake/modules/LLVM-Config.cmake7
4 files changed, 80 insertions, 37 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index fcd5dd5566..7496622542 100755
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -54,6 +54,7 @@ check_include_file(ndir.h HAVE_NDIR_H)
if( NOT PURE_WINDOWS )
check_include_file(pthread.h HAVE_PTHREAD_H)
endif()
+check_include_file(sanitizer/msan_interface.h HAVE_SANITIZER_MSAN_INTERFACE_H)
check_include_file(setjmp.h HAVE_SETJMP_H)
check_include_file(signal.h HAVE_SIGNAL_H)
check_include_file(stdint.h HAVE_STDINT_H)
@@ -99,6 +100,7 @@ if( NOT PURE_WINDOWS )
endif()
endif()
check_library_exists(dl dlopen "" HAVE_LIBDL)
+ check_library_exists(rt clock_gettime "" HAVE_LIBRT)
endif()
# function checks
@@ -117,6 +119,12 @@ check_symbol_exists(isnan math.h HAVE_ISNAN_IN_MATH_H)
check_symbol_exists(ceilf math.h HAVE_CEILF)
check_symbol_exists(floorf math.h HAVE_FLOORF)
check_symbol_exists(fmodf math.h HAVE_FMODF)
+check_symbol_exists(log math.h HAVE_LOG)
+check_symbol_exists(log2 math.h HAVE_LOG2)
+check_symbol_exists(log10 math.h HAVE_LOG10)
+check_symbol_exists(exp math.h HAVE_EXP)
+check_symbol_exists(exp2 math.h HAVE_EXP2)
+check_symbol_exists(exp10 math.h HAVE_EXP10)
if( HAVE_SETJMP_H )
check_symbol_exists(longjmp setjmp.h HAVE_LONGJMP)
check_symbol_exists(setjmp setjmp.h HAVE_SETJMP)
@@ -294,10 +302,33 @@ else()
set(ENABLE_PIC 0)
endif()
+find_package(LibXml2)
+if (LIBXML2_FOUND)
+ set(CLANG_HAVE_LIBXML 1)
+endif ()
+
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Wno-variadic-macros" SUPPORTS_NO_VARIADIC_MACROS_FLAG)
+set(USE_NO_MAYBE_UNINITIALIZED 0)
+set(USE_NO_UNINITIALIZED 0)
+
+# Disable gcc's potentially uninitialized use analysis as it presents lots of
+# false positives.
+if (CMAKE_COMPILER_IS_GNUCXX)
+ check_cxx_compiler_flag("-Wmaybe-uninitialized" HAS_MAYBE_UNINITIALIZED)
+ if (HAS_MAYBE_UNINITIALIZED)
+ set(USE_NO_MAYBE_UNINITIALIZED 1)
+ else()
+ # Only recent versions of gcc make the distinction between -Wuninitialized
+ # and -Wmaybe-uninitialized. If -Wmaybe-uninitialized isn't supported, just
+ # turn off all uninitialized use warnings.
+ check_cxx_compiler_flag("-Wuninitialized" HAS_UNINITIALIZED)
+ set(USE_NO_UNINITIALIZED ${HAS_UNINITIALIZED})
+ endif()
+endif()
+
include(GetHostTriple)
get_host_triple(LLVM_HOST_TRIPLE)
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 43ee9a08b2..f0b31ce653 100755
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -157,12 +157,7 @@ endmacro(add_llvm_external_project)
# Generic support for adding a unittest.
function(add_unittest test_suite test_name)
- if (CMAKE_BUILD_TYPE)
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
- ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
- else()
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
- endif()
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if( NOT LLVM_BUILD_TESTS )
set(EXCLUDE_FROM_ALL ON)
endif()
@@ -239,8 +234,8 @@ function(configure_lit_site_cfg input output)
set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR})
set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR})
- set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
- set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib/%(build_config)s")
+ set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_mode)s")
+ set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib/%(build_mode)s")
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
set(ENABLE_SHARED ${LLVM_SHARED_LIBS_ENABLED})
set(SHLIBPATH_VAR ${SHLIBPATH_VAR})
@@ -251,8 +246,8 @@ function(configure_lit_site_cfg input output)
set(ENABLE_ASSERTIONS "0")
endif()
- set(HOST_OS ${CMAKE_HOST_SYSTEM_NAME})
- set(HOST_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})
+ set(HOST_OS ${CMAKE_SYSTEM_NAME})
+ set(HOST_ARCH ${CMAKE_SYSTEM_PROCESSOR})
configure_file(${input} ${output} @ONLY)
endfunction()
@@ -266,18 +261,23 @@ function(add_lit_target target comment)
set(LIT_COMMAND
${PYTHON_EXECUTABLE}
${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py
- --param build_config=${CMAKE_CFG_INTDIR}
- --param build_mode=${RUNTIME_BUILD_MODE}
+ --param build_mode=${CMAKE_CFG_INTDIR}
${LIT_ARGS}
)
foreach(param ${ARG_PARAMS})
list(APPEND LIT_COMMAND --param ${param})
endforeach()
- add_custom_target(${target}
- COMMAND ${LIT_COMMAND} ${ARG_DEFAULT_ARGS}
- COMMENT "${comment}"
- )
- add_dependencies(${target} ${ARG_DEPENDS})
+ if( ARG_DEPENDS )
+ add_custom_target(${target}
+ COMMAND ${LIT_COMMAND} ${ARG_DEFAULT_ARGS}
+ COMMENT "${comment}"
+ )
+ add_dependencies(${target} ${ARG_DEPENDS})
+ else()
+ add_custom_target(${target}
+ COMMAND cmake -E echo "${target} does nothing, no tools built.")
+ message(STATUS "${target} does nothing.")
+ endif()
endfunction()
# A function to add a set of lit test suites to be driven through 'check-*' targets.
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
index ca07c5c361..a83be41b22 100644
--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -4,6 +4,7 @@
include(AddLLVMDefinitions)
include(CheckCCompilerFlag)
+include(CheckCXXCompilerFlag)
if( CMAKE_COMPILER_IS_GNUCXX )
set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
@@ -11,20 +12,6 @@ elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
endif()
-# Run-time build mode; It is used for unittests.
-if(MSVC_IDE)
- # Expect "$(Configuration)", "$(OutDir)", etc.
- # It is expanded by msbuild or similar.
- set(RUNTIME_BUILD_MODE "${CMAKE_CFG_INTDIR}")
-elseif(NOT CMAKE_BUILD_TYPE STREQUAL "")
- # Expect "Release" "Debug", etc.
- # Or unittests could not run.
- set(RUNTIME_BUILD_MODE ${CMAKE_BUILD_TYPE})
-else()
- # It might be "."
- set(RUNTIME_BUILD_MODE "${CMAKE_CFG_INTDIR}")
-endif()
-
if( LLVM_ENABLE_ASSERTIONS )
# MSVC doesn't like _DEBUG on release builds. See PR 4379.
if( NOT MSVC )
@@ -80,7 +67,6 @@ if( LLVM_ENABLE_PIC )
elseif( WIN32 OR CYGWIN)
# On Windows all code is PIC. MinGW warns if -fPIC is used.
else()
- include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-fPIC" SUPPORTS_FPIC_FLAG)
if( SUPPORTS_FPIC_FLAG )
message(STATUS "Building with -fPIC")
@@ -169,6 +155,7 @@ if( MSVC )
-wd4551 # Suppress 'function call missing argument list'
-wd4624 # Suppress ''derived class' : destructor could not be generated because a base class destructor is inaccessible'
-wd4715 # Suppress ''function' : not all control paths return a value'
+ -wd4722 # Suppress ''function' : destructor never returns, potential memory leak'
-wd4800 # Suppress ''type' : forcing value to bool 'true' or 'false' (performance warning)'
# Promoted warnings.
@@ -176,7 +163,6 @@ if( MSVC )
# Promoted warnings to errors.
-we4238 # Promote 'nonstandard extension used : class rvalue used as lvalue' to error.
- -we4239 # Promote 'nonstandard extension used : 'token' : conversion from 'type' to 'type'' to error.
)
# Enable warnings
@@ -192,16 +178,39 @@ if( MSVC )
elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
if (LLVM_ENABLE_WARNINGS)
add_llvm_definitions( -Wall -W -Wno-unused-parameter -Wwrite-strings )
+
+ # Turn off missing field initializer warnings for gcc to avoid noise from
+ # false positives with empty {}. Turn them on otherwise (they're off by
+ # default for clang).
+ check_cxx_compiler_flag("-Wmissing-field-initializers" CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG)
+ if (CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG)
+ if (CMAKE_COMPILER_IS_GNUCXX)
+ add_llvm_definitions( -Wno-missing-field-initializers )
+ else()
+ add_llvm_definitions( -Wmissing-field-initializers )
+ endif()
+ endif()
+
if (LLVM_ENABLE_PEDANTIC)
add_llvm_definitions( -pedantic -Wno-long-long )
+ check_cxx_compiler_flag("-Werror -Wnested-anon-types" CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
+ if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG )
+ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
+ endif()
endif (LLVM_ENABLE_PEDANTIC)
check_cxx_compiler_flag("-Werror -Wcovered-switch-default" CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG)
if( CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG )
- set( CMAKE_CXX_FlAGS "${CMAKE_CXX_FLAGS} -Wcovered-switch-default" )
+ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcovered-switch-default" )
endif()
check_c_compiler_flag("-Werror -Wcovered-switch-default" C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG)
if( C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG )
- set( CMAKE_C_FlAGS "${CMAKE_C_FLAGS} -Wcovered-switch-default" )
+ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcovered-switch-default" )
+ endif()
+ if (USE_NO_UNINITIALIZED)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-uninitialized")
+ endif()
+ if (USE_NO_MAYBE_UNINITIALIZED)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
endif()
endif (LLVM_ENABLE_WARNINGS)
if (LLVM_ENABLE_WERROR)
diff --git a/cmake/modules/LLVM-Config.cmake b/cmake/modules/LLVM-Config.cmake
index 574335c49d..163401c857 100755
--- a/cmake/modules/LLVM-Config.cmake
+++ b/cmake/modules/LLVM-Config.cmake
@@ -4,11 +4,14 @@ function(get_system_libs return_var)
if( MINGW )
set(system_libs ${system_libs} imagehlp psapi)
elseif( CMAKE_HOST_UNIX )
+ if( HAVE_LIBRT )
+ set(system_libs ${system_libs} rt)
+ endif()
if( HAVE_LIBDL )
- set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
+ set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
endif()
if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
- set(system_libs ${system_libs} pthread)
+ set(system_libs ${system_libs} pthread)
endif()
endif( MINGW )
endif( NOT MSVC )