Daniel Dunbar | 10fa2df | 2011-11-04 19:04:35 +0000 | [diff] [blame] | 1 | # This CMake module is responsible for interpreting the user defined LLVM_ |
| 2 | # options and executing the appropriate CMake commands to realize the users' |
| 3 | # selections. |
| 4 | |
Eric Fiselier | ebf091d | 2014-11-15 07:45:31 +0000 | [diff] [blame] | 5 | # This is commonly needed so make sure it's defined before we include anything |
| 6 | # else. |
| 7 | string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) |
| 8 | |
Jordan Rose | 31c5b7b | 2014-02-05 00:02:37 +0000 | [diff] [blame] | 9 | include(HandleLLVMStdlib) |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 10 | include(AddLLVMDefinitions) |
Joe Abbey | 15d9834 | 2012-11-26 02:02:08 +0000 | [diff] [blame] | 11 | include(CheckCCompilerFlag) |
Jordan Rose | 643aa0e | 2013-03-02 01:00:40 +0000 | [diff] [blame] | 12 | include(CheckCXXCompilerFlag) |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 13 | |
Chandler Carruth | 8388597 | 2014-01-13 22:21:34 +0000 | [diff] [blame] | 14 | if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN) |
| 15 | if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
| 16 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) |
| 17 | message(FATAL_ERROR "Host GCC version must be at least 4.7!") |
| 18 | endif() |
| 19 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
| 20 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1) |
| 21 | message(FATAL_ERROR "Host Clang version must be at least 3.1!") |
| 22 | endif() |
Chandler Carruth | f8f0015 | 2014-01-17 09:47:55 +0000 | [diff] [blame] | 23 | |
| 24 | # Also test that we aren't using too old of a version of libstdc++ with the |
| 25 | # Clang compiler. This is tricky as there is no real way to check the |
| 26 | # version of libstdc++ directly. Instead we test for a known bug in |
| 27 | # libstdc++4.6 that is fixed in libstdc++4.7. |
| 28 | if(NOT LLVM_ENABLE_LIBCXX) |
Chandler Carruth | f4144ad | 2014-01-21 18:09:19 +0000 | [diff] [blame] | 29 | set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) |
| 30 | set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) |
Chandler Carruth | f8f0015 | 2014-01-17 09:47:55 +0000 | [diff] [blame] | 31 | set(CMAKE_REQUIRED_FLAGS "-std=c++0x") |
| 32 | check_cxx_source_compiles(" |
| 33 | #include <atomic> |
| 34 | std::atomic<float> x(0.0f); |
| 35 | int main() { return (float)x; }" |
| 36 | LLVM_NO_OLD_LIBSTDCXX) |
| 37 | if(NOT LLVM_NO_OLD_LIBSTDCXX) |
| 38 | message(FATAL_ERROR "Host Clang must be able to find libstdc++4.7 or newer!") |
| 39 | endif() |
Chandler Carruth | f4144ad | 2014-01-21 18:09:19 +0000 | [diff] [blame] | 40 | set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) |
| 41 | set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES}) |
Chandler Carruth | f8f0015 | 2014-01-17 09:47:55 +0000 | [diff] [blame] | 42 | endif() |
Amara Emerson | 5569381a | 2014-01-21 16:41:07 +0000 | [diff] [blame] | 43 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") |
Chandler Carruth | 8388597 | 2014-01-13 22:21:34 +0000 | [diff] [blame] | 44 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.0) |
| 45 | message(FATAL_ERROR "Host Visual Studio must be at least 2012 (MSVC 17.0)") |
| 46 | endif() |
| 47 | endif() |
| 48 | endif() |
| 49 | |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 50 | if( LLVM_ENABLE_ASSERTIONS ) |
| 51 | # MSVC doesn't like _DEBUG on release builds. See PR 4379. |
| 52 | if( NOT MSVC ) |
| 53 | add_definitions( -D_DEBUG ) |
| 54 | endif() |
Duncan Sands | 80f122f | 2013-07-17 09:34:51 +0000 | [diff] [blame] | 55 | # On non-Debug builds cmake automatically defines NDEBUG, so we |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 56 | # explicitly undefine it: |
Duncan Sands | 80f122f | 2013-07-17 09:34:51 +0000 | [diff] [blame] | 57 | if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" ) |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 58 | add_definitions( -UNDEBUG ) |
Reid Kleckner | c1c01d5 | 2013-04-07 01:45:01 +0000 | [diff] [blame] | 59 | # Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines. |
Reid Kleckner | 472e6b4 | 2014-05-19 21:13:41 +0000 | [diff] [blame] | 60 | foreach (flags_var_to_scrub |
| 61 | CMAKE_CXX_FLAGS_RELEASE |
| 62 | CMAKE_CXX_FLAGS_RELWITHDEBINFO |
| 63 | CMAKE_CXX_FLAGS_MINSIZEREL |
| 64 | CMAKE_C_FLAGS_RELEASE |
| 65 | CMAKE_C_FLAGS_RELWITHDEBINFO |
| 66 | CMAKE_C_FLAGS_MINSIZEREL) |
| 67 | string (REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " " |
| 68 | "${flags_var_to_scrub}" "${${flags_var_to_scrub}}") |
| 69 | endforeach() |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 70 | endif() |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 71 | endif() |
| 72 | |
| 73 | if(WIN32) |
Nico Weber | c27118d | 2013-12-28 23:31:44 +0000 | [diff] [blame] | 74 | set(LLVM_HAVE_LINK_VERSION_SCRIPT 0) |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 75 | if(CYGWIN) |
| 76 | set(LLVM_ON_WIN32 0) |
| 77 | set(LLVM_ON_UNIX 1) |
| 78 | else(CYGWIN) |
| 79 | set(LLVM_ON_WIN32 1) |
| 80 | set(LLVM_ON_UNIX 0) |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 81 | endif(CYGWIN) |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 82 | else(WIN32) |
| 83 | if(UNIX) |
| 84 | set(LLVM_ON_WIN32 0) |
| 85 | set(LLVM_ON_UNIX 1) |
| 86 | if(APPLE) |
Nico Weber | c27118d | 2013-12-28 23:31:44 +0000 | [diff] [blame] | 87 | set(LLVM_HAVE_LINK_VERSION_SCRIPT 0) |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 88 | else(APPLE) |
Nico Weber | c27118d | 2013-12-28 23:31:44 +0000 | [diff] [blame] | 89 | set(LLVM_HAVE_LINK_VERSION_SCRIPT 1) |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 90 | endif(APPLE) |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 91 | else(UNIX) |
| 92 | MESSAGE(SEND_ERROR "Unable to determine platform") |
| 93 | endif(UNIX) |
| 94 | endif(WIN32) |
| 95 | |
Alp Toker | c0b7bb5 | 2014-01-08 11:10:24 +0000 | [diff] [blame] | 96 | set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX}) |
| 97 | set(LTDL_SHLIB_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX}) |
NAKAMURA Takumi | 92d6580 | 2014-02-13 11:19:00 +0000 | [diff] [blame] | 98 | |
| 99 | # We use *.dylib rather than *.so on darwin. |
| 100 | set(LLVM_PLUGIN_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX}) |
Alp Toker | c0b7bb5 | 2014-01-08 11:10:24 +0000 | [diff] [blame] | 101 | |
NAKAMURA Takumi | 58f6e74 | 2014-02-13 11:19:11 +0000 | [diff] [blame] | 102 | if(APPLE) |
| 103 | # Darwin-specific linker flags for loadable modules. |
| 104 | set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace -Wl,-undefined -Wl,suppress") |
| 105 | endif() |
| 106 | |
Rafael Espindola | bb5d09f | 2015-01-22 14:06:51 +0000 | [diff] [blame] | 107 | # Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO |
| 108 | # build might work on ELF but fail on MachO/COFF. |
Rafael Espindola | 19b5384 | 2015-01-22 20:57:30 +0000 | [diff] [blame] | 109 | if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR |
| 110 | ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") AND |
| 111 | NOT LLVM_USE_SANITIZER) |
Rafael Espindola | bb5d09f | 2015-01-22 14:06:51 +0000 | [diff] [blame] | 112 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs") |
| 113 | endif() |
| 114 | |
| 115 | |
Duncan Sands | 71de6dc | 2013-03-25 13:25:34 +0000 | [diff] [blame] | 116 | function(append value) |
| 117 | foreach(variable ${ARGN}) |
Alexey Samsonov | 6706578 | 2013-03-13 20:50:23 +0000 | [diff] [blame] | 118 | set(${variable} "${${variable}} ${value}" PARENT_SCOPE) |
Duncan Sands | 71de6dc | 2013-03-25 13:25:34 +0000 | [diff] [blame] | 119 | endforeach(variable) |
| 120 | endfunction() |
| 121 | |
| 122 | function(append_if condition value) |
| 123 | if (${condition}) |
| 124 | foreach(variable ${ARGN}) |
| 125 | set(${variable} "${${variable}} ${value}" PARENT_SCOPE) |
| 126 | endforeach(variable) |
Alexey Samsonov | 6706578 | 2013-03-13 20:50:23 +0000 | [diff] [blame] | 127 | endif() |
| 128 | endfunction() |
| 129 | |
Alp Toker | 0068397 | 2014-07-09 03:38:19 +0000 | [diff] [blame] | 130 | macro(add_flag_if_supported flag name) |
| 131 | check_c_compiler_flag("-Werror ${flag}" "C_SUPPORTS_${name}") |
| 132 | append_if("C_SUPPORTS_${name}" "${flag}" CMAKE_C_FLAGS) |
| 133 | check_cxx_compiler_flag("-Werror ${flag}" "CXX_SUPPORTS_${name}") |
| 134 | append_if("CXX_SUPPORTS_${name}" "${flag}" CMAKE_CXX_FLAGS) |
Alexey Samsonov | 75789a2 | 2013-03-26 07:49:46 +0000 | [diff] [blame] | 135 | endmacro() |
| 136 | |
Alp Toker | 0068397 | 2014-07-09 03:38:19 +0000 | [diff] [blame] | 137 | function(add_flag_or_print_warning flag name) |
| 138 | check_c_compiler_flag("-Werror ${flag}" "C_SUPPORTS_${name}") |
| 139 | check_cxx_compiler_flag("-Werror ${flag}" "CXX_SUPPORTS_${name}") |
Richard Smith | ca9ae10 | 2014-09-26 21:35:48 +0000 | [diff] [blame] | 140 | if (C_SUPPORTS_${name} AND CXX_SUPPORTS_${name}) |
Alp Toker | 0068397 | 2014-07-09 03:38:19 +0000 | [diff] [blame] | 141 | message(STATUS "Building with ${flag}") |
| 142 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE) |
| 143 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE) |
| 144 | else() |
| 145 | message(WARNING "${flag} is not supported.") |
| 146 | endif() |
| 147 | endfunction() |
| 148 | |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 149 | if( LLVM_ENABLE_PIC ) |
| 150 | if( XCODE ) |
| 151 | # Xcode has -mdynamic-no-pic on by default, which overrides -fPIC. I don't |
| 152 | # know how to disable this, so just force ENABLE_PIC off for now. |
| 153 | message(WARNING "-fPIC not supported with Xcode.") |
NAKAMURA Takumi | 1b745d0 | 2011-12-16 06:21:08 +0000 | [diff] [blame] | 154 | elseif( WIN32 OR CYGWIN) |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 155 | # On Windows all code is PIC. MinGW warns if -fPIC is used. |
| 156 | else() |
Alp Toker | 0068397 | 2014-07-09 03:38:19 +0000 | [diff] [blame] | 157 | add_flag_or_print_warning("-fPIC" FPIC) |
Rafael Espindola | 5258ab8 | 2012-01-20 04:07:48 +0000 | [diff] [blame] | 158 | |
Rafael Espindola | 9f404cc | 2012-01-20 13:10:10 +0000 | [diff] [blame] | 159 | if( WIN32 OR CYGWIN) |
| 160 | # MinGW warns if -fvisibility-inlines-hidden is used. |
| 161 | else() |
| 162 | check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG) |
Duncan Sands | 71de6dc | 2013-03-25 13:25:34 +0000 | [diff] [blame] | 163 | append_if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG "-fvisibility-inlines-hidden" CMAKE_CXX_FLAGS) |
Alexey Samsonov | 6706578 | 2013-03-13 20:50:23 +0000 | [diff] [blame] | 164 | endif() |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 165 | endif() |
| 166 | endif() |
| 167 | |
| 168 | if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 ) |
| 169 | # TODO: support other platforms and toolchains. |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 170 | if( LLVM_BUILD_32_BITS ) |
| 171 | message(STATUS "Building 32 bits executables and libraries.") |
| 172 | add_llvm_definitions( -m32 ) |
Tim Northover | f6e29c4 | 2012-05-23 18:42:02 +0000 | [diff] [blame] | 173 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") |
| 174 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32") |
Tobias Grosser | b32ad40 | 2012-06-08 09:41:23 +0000 | [diff] [blame] | 175 | set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -m32") |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 176 | endif( LLVM_BUILD_32_BITS ) |
| 177 | endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 ) |
| 178 | |
Rafael Espindola | ef4edf4 | 2014-11-05 14:03:58 +0000 | [diff] [blame] | 179 | if (LLVM_BUILD_STATIC) |
| 180 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") |
| 181 | endif() |
| 182 | |
Ted Kremenek | 68af845 | 2014-03-13 06:37:28 +0000 | [diff] [blame] | 183 | if( XCODE ) |
| 184 | # For Xcode enable several build settings that correspond to |
| 185 | # many warnings that are on by default in Clang but are |
| 186 | # not enabled for historical reasons. For versions of Xcode |
| 187 | # that do not support these options they will simply |
| 188 | # be ignored. |
| 189 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_RETURN_TYPE "YES") |
| 190 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE "YES") |
| 191 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VALUE "YES") |
| 192 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VARIABLE "YES") |
| 193 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_SIGN_COMPARE "YES") |
| 194 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_FUNCTION "YES") |
| 195 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED "YES") |
| 196 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS "YES") |
| 197 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNINITIALIZED_AUTOS "YES") |
| 198 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_BOOL_CONVERSION "YES") |
| 199 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_EMPTY_BODY "YES") |
| 200 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION "YES") |
| 201 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_INT_CONVERSION "YES") |
| 202 | set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_CONSTANT_CONVERSION "YES") |
| 203 | set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_NON_VIRTUAL_DESTRUCTOR "YES") |
| 204 | endif() |
| 205 | |
NAKAMURA Takumi | a83601d | 2012-04-21 14:50:56 +0000 | [diff] [blame] | 206 | # On Win32 using MS tools, provide an option to set the number of parallel jobs |
| 207 | # to use. |
NAKAMURA Takumi | 75bfe69 | 2012-04-21 14:51:02 +0000 | [diff] [blame] | 208 | if( MSVC_IDE ) |
Oscar Fuentes | 318c3f1 | 2011-03-02 17:47:37 +0000 | [diff] [blame] | 209 | set(LLVM_COMPILER_JOBS "0" CACHE STRING |
| 210 | "Number of parallel compiler jobs. 0 means use all processors. Default is 0.") |
| 211 | if( NOT LLVM_COMPILER_JOBS STREQUAL "1" ) |
| 212 | if( LLVM_COMPILER_JOBS STREQUAL "0" ) |
| 213 | add_llvm_definitions( /MP ) |
| 214 | else() |
Yaron Keren | e485511 | 2014-03-25 09:34:20 +0000 | [diff] [blame] | 215 | message(STATUS "Number of parallel compiler jobs set to " ${LLVM_COMPILER_JOBS}) |
| 216 | add_llvm_definitions( /MP${LLVM_COMPILER_JOBS} ) |
Oscar Fuentes | 318c3f1 | 2011-03-02 17:47:37 +0000 | [diff] [blame] | 217 | endif() |
| 218 | else() |
| 219 | message(STATUS "Parallel compilation disabled") |
| 220 | endif() |
| 221 | endif() |
| 222 | |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 223 | if( MSVC ) |
| 224 | include(ChooseMSVCCRT) |
| 225 | |
Hans Wennborg | bef50ab | 2013-10-17 18:39:47 +0000 | [diff] [blame] | 226 | if( NOT (${CMAKE_VERSION} VERSION_LESS 2.8.11) ) |
| 227 | # set stack reserved size to ~10MB |
| 228 | # CMake previously automatically set this value for MSVC builds, but the |
| 229 | # behavior was changed in CMake 2.8.11 (Issue 12437) to use the MSVC default |
| 230 | # value (1 MB) which is not enough for us in tasks such as parsing recursive |
| 231 | # C++ templates in Clang. |
| 232 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000") |
| 233 | endif() |
Hans Wennborg | fd541f0 | 2013-10-17 17:49:57 +0000 | [diff] [blame] | 234 | |
Yaron Keren | e485511 | 2014-03-25 09:34:20 +0000 | [diff] [blame] | 235 | if( MSVC11 ) |
Michael J. Spencer | 35145f8 | 2012-03-01 22:42:52 +0000 | [diff] [blame] | 236 | add_llvm_definitions(-D_VARIADIC_MAX=10) |
| 237 | endif() |
Aaron Ballman | f5aacd3 | 2013-07-29 13:02:08 +0000 | [diff] [blame] | 238 | |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 239 | # Add definitions that make MSVC much less annoying. |
| 240 | add_llvm_definitions( |
| 241 | # For some reason MS wants to deprecate a bunch of standard functions... |
| 242 | -D_CRT_SECURE_NO_DEPRECATE |
| 243 | -D_CRT_SECURE_NO_WARNINGS |
| 244 | -D_CRT_NONSTDC_NO_DEPRECATE |
| 245 | -D_CRT_NONSTDC_NO_WARNINGS |
| 246 | -D_SCL_SECURE_NO_DEPRECATE |
| 247 | -D_SCL_SECURE_NO_WARNINGS |
| 248 | |
Michael J. Spencer | 6d45d83 | 2012-06-07 21:34:15 +0000 | [diff] [blame] | 249 | # Disabled warnings. |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 250 | -wd4146 # Suppress 'unary minus operator applied to unsigned type, result still unsigned' |
| 251 | -wd4180 # Suppress 'qualifier applied to function type has no meaning; ignored' |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 252 | -wd4244 # Suppress ''argument' : conversion from 'type1' to 'type2', possible loss of data' |
Aaron Ballman | dabe780 | 2014-08-18 14:54:22 +0000 | [diff] [blame] | 253 | -wd4258 # Suppress ''var' : definition from the for loop is ignored; the definition from the enclosing scope is used' |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 254 | -wd4267 # Suppress ''var' : conversion from 'size_t' to 'type', possible loss of data' |
Yaron Keren | 24fdbe5 | 2014-03-25 08:42:49 +0000 | [diff] [blame] | 255 | -wd4291 # Suppress ''declaration' : no matching operator delete found; memory will not be freed if initialization throws an exception' |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 256 | -wd4345 # Suppress 'behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized' |
| 257 | -wd4351 # Suppress 'new behavior: elements of array 'array' will be default initialized' |
| 258 | -wd4355 # Suppress ''this' : used in base member initializer list' |
Reid Kleckner | 19cb171 | 2014-10-31 22:55:57 +0000 | [diff] [blame] | 259 | -wd4456 # Suppress 'declaration of 'var' hides local variable' |
| 260 | -wd4457 # Suppress 'declaration of 'var' hides function parameter' |
| 261 | -wd4458 # Suppress 'declaration of 'var' hides class member' |
| 262 | -wd4459 # Suppress 'declaration of 'var' hides global declaration' |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 263 | -wd4503 # Suppress ''identifier' : decorated name length exceeded, name was truncated' |
| 264 | -wd4624 # Suppress ''derived class' : destructor could not be generated because a base class destructor is inaccessible' |
Yaron Keren | 24fdbe5 | 2014-03-25 08:42:49 +0000 | [diff] [blame] | 265 | -wd4722 # Suppress 'function' : destructor never returns, potential memory leak |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 266 | -wd4800 # Suppress ''type' : forcing value to bool 'true' or 'false' (performance warning)' |
Aaron Ballman | d1594bd | 2013-07-28 18:04:26 +0000 | [diff] [blame] | 267 | |
Michael J. Spencer | 6d45d83 | 2012-06-07 21:34:15 +0000 | [diff] [blame] | 268 | # Promoted warnings. |
| 269 | -w14062 # Promote 'enumerator in switch of enum is not handled' to level 1 warning. |
Michael J. Spencer | aeb59e1 | 2012-06-07 23:33:56 +0000 | [diff] [blame] | 270 | |
| 271 | # Promoted warnings to errors. |
| 272 | -we4238 # Promote 'nonstandard extension used : class rvalue used as lvalue' to error. |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 273 | ) |
| 274 | |
| 275 | # Enable warnings |
| 276 | if (LLVM_ENABLE_WARNINGS) |
Michael J. Spencer | 6d45d83 | 2012-06-07 21:34:15 +0000 | [diff] [blame] | 277 | add_llvm_definitions( /W4 ) |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 278 | if (LLVM_ENABLE_PEDANTIC) |
| 279 | # No MSVC equivalent available |
| 280 | endif (LLVM_ENABLE_PEDANTIC) |
| 281 | endif (LLVM_ENABLE_WARNINGS) |
| 282 | if (LLVM_ENABLE_WERROR) |
| 283 | add_llvm_definitions( /WX ) |
| 284 | endif (LLVM_ENABLE_WERROR) |
Oscar Fuentes | ab84a7b | 2011-05-11 13:53:08 +0000 | [diff] [blame] | 285 | elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE ) |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 286 | if (LLVM_ENABLE_WARNINGS) |
Duncan Sands | 71de6dc | 2013-03-25 13:25:34 +0000 | [diff] [blame] | 287 | append("-Wall -W -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
Roman Divacky | 2d64ef9 | 2014-11-13 19:45:27 +0000 | [diff] [blame] | 288 | append("-Wcast-qual" CMAKE_CXX_FLAGS) |
Edwin Vane | c641084 | 2013-01-31 18:05:54 +0000 | [diff] [blame] | 289 | |
| 290 | # Turn off missing field initializer warnings for gcc to avoid noise from |
| 291 | # false positives with empty {}. Turn them on otherwise (they're off by |
| 292 | # default for clang). |
| 293 | check_cxx_compiler_flag("-Wmissing-field-initializers" CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG) |
| 294 | if (CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG) |
| 295 | if (CMAKE_COMPILER_IS_GNUCXX) |
Duncan Sands | 71de6dc | 2013-03-25 13:25:34 +0000 | [diff] [blame] | 296 | append("-Wno-missing-field-initializers" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
Edwin Vane | c641084 | 2013-01-31 18:05:54 +0000 | [diff] [blame] | 297 | else() |
Duncan Sands | 71de6dc | 2013-03-25 13:25:34 +0000 | [diff] [blame] | 298 | append("-Wmissing-field-initializers" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
Edwin Vane | c641084 | 2013-01-31 18:05:54 +0000 | [diff] [blame] | 299 | endif() |
| 300 | endif() |
| 301 | |
Duncan Sands | 71de6dc | 2013-03-25 13:25:34 +0000 | [diff] [blame] | 302 | append_if(LLVM_ENABLE_PEDANTIC "-pedantic -Wno-long-long" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
Alp Toker | 0068397 | 2014-07-09 03:38:19 +0000 | [diff] [blame] | 303 | add_flag_if_supported("-Wcovered-switch-default" COVERED_SWITCH_DEFAULT_FLAG) |
Duncan Sands | 71de6dc | 2013-03-25 13:25:34 +0000 | [diff] [blame] | 304 | append_if(USE_NO_UNINITIALIZED "-Wno-uninitialized" CMAKE_CXX_FLAGS) |
| 305 | append_if(USE_NO_MAYBE_UNINITIALIZED "-Wno-maybe-uninitialized" CMAKE_CXX_FLAGS) |
Dylan Noblesmith | 367cef6 | 2014-08-23 21:10:56 +0000 | [diff] [blame] | 306 | |
| 307 | # Check if -Wnon-virtual-dtor warns even though the class is marked final. |
| 308 | # If it does, don't add it. So it won't be added on clang 3.4 and older. |
| 309 | # This also catches cases when -Wnon-virtual-dtor isn't supported by |
| 310 | # the compiler at all. |
| 311 | set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) |
| 312 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11 -Werror=non-virtual-dtor") |
| 313 | CHECK_CXX_SOURCE_COMPILES("class base {public: virtual void anchor();protected: ~base();}; |
| 314 | class derived final : public base { public: ~derived();}; |
| 315 | int main() { return 0; }" |
| 316 | CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR) |
| 317 | set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) |
| 318 | append_if(CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR |
| 319 | "-Wnon-virtual-dtor" CMAKE_CXX_FLAGS) |
Evgeniy Stepanov | 1b5fd3e | 2014-05-06 09:46:06 +0000 | [diff] [blame] | 320 | |
| 321 | # Check if -Wcomment is OK with an // comment ending with '\' if the next |
| 322 | # line is also a // comment. |
| 323 | set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) |
Dylan Noblesmith | 63f9b57 | 2014-08-23 21:10:58 +0000 | [diff] [blame] | 324 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror -Wcomment") |
Evgeniy Stepanov | 1b5fd3e | 2014-05-06 09:46:06 +0000 | [diff] [blame] | 325 | CHECK_C_SOURCE_COMPILES("// \\\\\\n//\\nint main() {return 0;}" |
| 326 | C_WCOMMENT_ALLOWS_LINE_WRAP) |
| 327 | set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) |
| 328 | if (NOT C_WCOMMENT_ALLOWS_LINE_WRAP) |
| 329 | append("-Wno-comment" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
| 330 | endif() |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 331 | endif (LLVM_ENABLE_WARNINGS) |
Alexey Samsonov | cd083fe | 2014-03-13 13:08:47 +0000 | [diff] [blame] | 332 | append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
Alp Toker | 7099cd7 | 2014-07-09 03:39:32 +0000 | [diff] [blame] | 333 | if (NOT LLVM_ENABLE_TIMESTAMPS) |
| 334 | add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME) |
| 335 | endif () |
Chandler Carruth | 25eacf7 | 2014-03-01 03:16:07 +0000 | [diff] [blame] | 336 | if (LLVM_ENABLE_CXX1Y) |
| 337 | check_cxx_compiler_flag("-std=c++1y" CXX_SUPPORTS_CXX1Y) |
| 338 | append_if(CXX_SUPPORTS_CXX1Y "-std=c++1y" CMAKE_CXX_FLAGS) |
| 339 | else() |
Arnaud A. de Grandmaison | b697b53 | 2013-11-26 10:33:53 +0000 | [diff] [blame] | 340 | check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11) |
Chandler Carruth | 25eacf7 | 2014-03-01 03:16:07 +0000 | [diff] [blame] | 341 | if (CXX_SUPPORTS_CXX11) |
Rafael Espindola | 8b35074 | 2014-03-12 20:01:15 +0000 | [diff] [blame] | 342 | if (CYGWIN OR MINGW) |
| 343 | # MinGW and Cygwin are a bit stricter and lack things like |
| 344 | # 'strdup', 'stricmp', etc in c++11 mode. |
| 345 | append("-std=gnu++11" CMAKE_CXX_FLAGS) |
| 346 | else() |
| 347 | append("-std=c++11" CMAKE_CXX_FLAGS) |
| 348 | endif() |
Chandler Carruth | 25eacf7 | 2014-03-01 03:16:07 +0000 | [diff] [blame] | 349 | else() |
| 350 | message(FATAL_ERROR "LLVM requires C++11 support but the '-std=c++11' flag isn't supported.") |
| 351 | endif() |
| 352 | endif() |
Richard Smith | 2b91a7f | 2014-09-26 22:40:15 +0000 | [diff] [blame] | 353 | if (LLVM_ENABLE_MODULES) |
| 354 | set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) |
| 355 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fmodules -fcxx-modules") |
| 356 | # Check that we can build code with modules enabled, and that repeatedly |
| 357 | # including <cassert> still manages to respect NDEBUG properly. |
| 358 | CHECK_CXX_SOURCE_COMPILES("#undef NDEBUG |
| 359 | #include <cassert> |
| 360 | #define NDEBUG |
| 361 | #include <cassert> |
| 362 | int main() { assert(this code is not compiled); }" |
| 363 | CXX_SUPPORTS_MODULES) |
| 364 | set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) |
| 365 | if (CXX_SUPPORTS_MODULES) |
| 366 | append_if(CXX_SUPPORTS_MODULES "-fmodules" CMAKE_C_FLAGS) |
| 367 | append_if(CXX_SUPPORTS_MODULES "-fmodules -fcxx-modules" CMAKE_CXX_FLAGS) |
| 368 | else() |
| 369 | message(FATAL_ERROR "LLVM_ENABLE_MODULES is not supported by this compiler") |
| 370 | endif() |
| 371 | endif(LLVM_ENABLE_MODULES) |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 372 | endif( MSVC ) |
| 373 | |
Alexey Samsonov | 75789a2 | 2013-03-26 07:49:46 +0000 | [diff] [blame] | 374 | macro(append_common_sanitizer_flags) |
| 375 | # Append -fno-omit-frame-pointer and turn on debug info to get better |
| 376 | # stack traces. |
Alp Toker | 0068397 | 2014-07-09 03:38:19 +0000 | [diff] [blame] | 377 | add_flag_if_supported("-fno-omit-frame-pointer" FNO_OMIT_FRAME_POINTER) |
Alexey Samsonov | 75789a2 | 2013-03-26 07:49:46 +0000 | [diff] [blame] | 378 | if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND |
| 379 | NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") |
Alp Toker | 0068397 | 2014-07-09 03:38:19 +0000 | [diff] [blame] | 380 | add_flag_if_supported("-gline-tables-only" GLINE_TABLES_ONLY) |
Alexey Samsonov | 75789a2 | 2013-03-26 07:49:46 +0000 | [diff] [blame] | 381 | endif() |
Alexey Samsonov | f9ab351 | 2013-09-02 09:15:01 +0000 | [diff] [blame] | 382 | # Use -O1 even in debug mode, otherwise sanitizers slowdown is too large. |
| 383 | if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") |
Alp Toker | 0068397 | 2014-07-09 03:38:19 +0000 | [diff] [blame] | 384 | add_flag_if_supported("-O1" O1) |
Alexey Samsonov | f9ab351 | 2013-09-02 09:15:01 +0000 | [diff] [blame] | 385 | endif() |
Alexey Samsonov | 75789a2 | 2013-03-26 07:49:46 +0000 | [diff] [blame] | 386 | endmacro() |
| 387 | |
| 388 | # Turn on sanitizers if necessary. |
| 389 | if(LLVM_USE_SANITIZER) |
| 390 | if (LLVM_ON_UNIX) |
| 391 | if (LLVM_USE_SANITIZER STREQUAL "Address") |
| 392 | append_common_sanitizer_flags() |
Alp Toker | 696b4a0 | 2014-07-09 06:27:05 +0000 | [diff] [blame] | 393 | append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
Alexey Samsonov | 75789a2 | 2013-03-26 07:49:46 +0000 | [diff] [blame] | 394 | elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?") |
| 395 | append_common_sanitizer_flags() |
Alp Toker | 696b4a0 | 2014-07-09 06:27:05 +0000 | [diff] [blame] | 396 | append("-fsanitize=memory" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
Alexey Samsonov | 75789a2 | 2013-03-26 07:49:46 +0000 | [diff] [blame] | 397 | if(LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins") |
Alp Toker | 696b4a0 | 2014-07-09 06:27:05 +0000 | [diff] [blame] | 398 | append("-fsanitize-memory-track-origins" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
Alexey Samsonov | 75789a2 | 2013-03-26 07:49:46 +0000 | [diff] [blame] | 399 | endif() |
Alexey Samsonov | 4ee2675 | 2014-08-29 00:50:36 +0000 | [diff] [blame] | 400 | elseif (LLVM_USE_SANITIZER STREQUAL "Undefined") |
| 401 | append_common_sanitizer_flags() |
Alexey Samsonov | ead5b93 | 2014-09-05 01:17:30 +0000 | [diff] [blame] | 402 | append("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover" |
Alexey Samsonov | 4ee2675 | 2014-08-29 00:50:36 +0000 | [diff] [blame] | 403 | CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
Eric Fiselier | be6705d | 2014-11-18 21:23:38 +0000 | [diff] [blame] | 404 | elseif (LLVM_USE_SANITIZER STREQUAL "Thread") |
| 405 | append_common_sanitizer_flags() |
| 406 | append("-fsanitize=thread" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
Alexey Samsonov | 75789a2 | 2013-03-26 07:49:46 +0000 | [diff] [blame] | 407 | else() |
| 408 | message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}") |
| 409 | endif() |
| 410 | else() |
| 411 | message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.") |
| 412 | endif() |
Kostya Serebryany | 869b867 | 2015-01-27 17:59:28 +0000 | [diff] [blame^] | 413 | if (LLVM_USE_SANITIZE_COVERAGE) |
| 414 | append("-fsanitize-coverage=4" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
| 415 | endif() |
Alexey Samsonov | 75789a2 | 2013-03-26 07:49:46 +0000 | [diff] [blame] | 416 | endif() |
| 417 | |
Eric Christopher | 3987806 | 2013-07-30 21:44:10 +0000 | [diff] [blame] | 418 | # Turn on -gsplit-dwarf if requested |
| 419 | if(LLVM_USE_SPLIT_DWARF) |
Peter Collingbourne | a7d1751 | 2014-10-22 19:49:19 +0000 | [diff] [blame] | 420 | add_definitions("-gsplit-dwarf") |
Eric Christopher | 3987806 | 2013-07-30 21:44:10 +0000 | [diff] [blame] | 421 | endif() |
| 422 | |
Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 423 | add_llvm_definitions( -D__STDC_CONSTANT_MACROS ) |
NAKAMURA Takumi | c5554c9 | 2011-10-11 12:51:44 +0000 | [diff] [blame] | 424 | add_llvm_definitions( -D__STDC_FORMAT_MACROS ) |
NAKAMURA Takumi | e63cd19 | 2011-10-11 12:51:36 +0000 | [diff] [blame] | 425 | add_llvm_definitions( -D__STDC_LIMIT_MACROS ) |
Arnaud A. de Grandmaison | 916f3cc | 2013-05-29 20:41:35 +0000 | [diff] [blame] | 426 | |
| 427 | # clang doesn't print colored diagnostics when invoked from Ninja |
Rafael Espindola | 6f2564c | 2013-06-14 19:41:05 +0000 | [diff] [blame] | 428 | if (UNIX AND |
| 429 | CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND |
| 430 | CMAKE_GENERATOR STREQUAL "Ninja") |
| 431 | append("-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
Arnaud A. de Grandmaison | 916f3cc | 2013-05-29 20:41:35 +0000 | [diff] [blame] | 432 | endif() |
NAKAMURA Takumi | bb50bce | 2014-01-28 09:43:55 +0000 | [diff] [blame] | 433 | |
| 434 | # Add flags for add_dead_strip(). |
| 435 | # FIXME: With MSVS, consider compiling with /Gy and linking with /OPT:REF? |
| 436 | # But MinSizeRel seems to add that automatically, so maybe disable these |
| 437 | # flags instead if LLVM_NO_DEAD_STRIP is set. |
| 438 | if(NOT CYGWIN AND NOT WIN32) |
| 439 | if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
Alexey Samsonov | 482beff | 2014-02-04 08:15:46 +0000 | [diff] [blame] | 440 | check_c_compiler_flag("-Werror -fno-function-sections" C_SUPPORTS_FNO_FUNCTION_SECTIONS) |
| 441 | if (C_SUPPORTS_FNO_FUNCTION_SECTIONS) |
| 442 | # Don't add -ffunction-section if it can be disabled with -fno-function-sections. |
| 443 | # Doing so will break sanitizers. |
Alp Toker | 0068397 | 2014-07-09 03:38:19 +0000 | [diff] [blame] | 444 | add_flag_if_supported("-ffunction-sections" FFUNCTION_SECTIONS) |
Evgeniy Stepanov | c7b7e25 | 2014-02-03 13:57:09 +0000 | [diff] [blame] | 445 | endif() |
Alp Toker | 0068397 | 2014-07-09 03:38:19 +0000 | [diff] [blame] | 446 | add_flag_if_supported("-fdata-sections" FDATA_SECTIONS) |
NAKAMURA Takumi | bb50bce | 2014-01-28 09:43:55 +0000 | [diff] [blame] | 447 | endif() |
| 448 | endif() |
NAKAMURA Takumi | a679f43 | 2014-01-28 09:44:06 +0000 | [diff] [blame] | 449 | |
NAKAMURA Takumi | f816123 | 2014-03-16 13:51:24 +0000 | [diff] [blame] | 450 | if(CYGWIN OR MINGW) |
| 451 | # Prune --out-implib from executables. It doesn't make sense even |
| 452 | # with --export-all-symbols. |
| 453 | string(REGEX REPLACE "-Wl,--out-implib,[^ ]+ " " " |
| 454 | CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}") |
| 455 | string(REGEX REPLACE "-Wl,--out-implib,[^ ]+ " " " |
| 456 | CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}") |
| 457 | endif() |
| 458 | |
NAKAMURA Takumi | a679f43 | 2014-01-28 09:44:06 +0000 | [diff] [blame] | 459 | if(MSVC) |
| 460 | # Remove flags here, for exceptions and RTTI. |
NAKAMURA Takumi | ac62464 | 2014-01-31 17:32:36 +0000 | [diff] [blame] | 461 | # Each target property or source property should be responsible to control |
| 462 | # them. |
NAKAMURA Takumi | a679f43 | 2014-01-28 09:44:06 +0000 | [diff] [blame] | 463 | # CL.EXE complains to override flags like "/GR /GR-". |
| 464 | string(REGEX REPLACE "(^| ) */EH[-cs]+ *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") |
| 465 | string(REGEX REPLACE "(^| ) */GR-? *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") |
| 466 | endif() |
NAKAMURA Takumi | 8d7a173 | 2014-07-04 04:45:40 +0000 | [diff] [blame] | 467 | |
Dan Liew | a5bdc84 | 2014-07-22 15:41:18 +0000 | [diff] [blame] | 468 | # Provide public options to globally control RTTI and EH |
| 469 | option(LLVM_ENABLE_EH "Enable Exception handling" OFF) |
| 470 | option(LLVM_ENABLE_RTTI "Enable run time type information" OFF) |
| 471 | if(LLVM_ENABLE_EH AND NOT LLVM_ENABLE_RTTI) |
| 472 | message(FATAL_ERROR "Exception handling requires RTTI. You must set LLVM_ENABLE_RTTI to ON") |
| 473 | endif() |
| 474 | |
NAKAMURA Takumi | 8d7a173 | 2014-07-04 04:45:40 +0000 | [diff] [blame] | 475 | # Plugin support |
| 476 | # FIXME: Make this configurable. |
| 477 | if(WIN32 OR CYGWIN) |
NAKAMURA Takumi | b5bb1e2 | 2014-07-13 13:47:37 +0000 | [diff] [blame] | 478 | if(BUILD_SHARED_LIBS) |
| 479 | set(LLVM_ENABLE_PLUGINS ON) |
| 480 | else() |
| 481 | set(LLVM_ENABLE_PLUGINS OFF) |
| 482 | endif() |
NAKAMURA Takumi | 8d7a173 | 2014-07-04 04:45:40 +0000 | [diff] [blame] | 483 | else() |
| 484 | set(LLVM_ENABLE_PLUGINS ON) |
| 485 | endif() |