diff options
Diffstat (limited to 'cmake/modules')
-rwxr-xr-x | cmake/modules/AddLLVM.cmake | 17 | ||||
-rw-r--r-- | cmake/modules/CMakeLists.txt | 6 | ||||
-rw-r--r-- | cmake/modules/ChooseMSVCCRT.cmake | 4 | ||||
-rw-r--r-- | cmake/modules/GetHostTriple.cmake (renamed from cmake/modules/GetTargetTriple.cmake) | 4 | ||||
-rw-r--r-- | cmake/modules/HandleLLVMOptions.cmake | 36 | ||||
-rwxr-xr-x | cmake/modules/LLVM-Config.cmake | 2 | ||||
-rw-r--r-- | cmake/modules/LLVMConfig.cmake.in | 2 | ||||
-rw-r--r-- | cmake/modules/TableGen.cmake | 5 | ||||
-rw-r--r-- | cmake/modules/VersionFromVCS.cmake | 40 |
9 files changed, 76 insertions, 40 deletions
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index b486fe4..388208b 100755 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -25,16 +25,15 @@ macro(add_llvm_library name) ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) endif() set_target_properties(${name} PROPERTIES FOLDER "Libraries") -endmacro(add_llvm_library name) - -macro(add_llvm_library_dependencies name) - # Save the dependencies of the LLVM library in a variable so that we can - # query it when resolve llvm-config-style component -> library mappings. - set_property(GLOBAL PROPERTY LLVM_LIB_DEPS_${name} ${ARGN}) - # Then add the actual dependencies to the library target. - target_link_libraries(${name} ${ARGN}) -endmacro(add_llvm_library_dependencies name) + # Add the explicit dependency information for this library. + # + # It would be nice to verify that we have the dependencies for this library + # name, but using get_property(... SET) doesn't suffice to determine if a + # property has been set to an empty value. + get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name}) + target_link_libraries(${name} ${lib_deps}) +endmacro(add_llvm_library name) macro(add_llvm_loadable_module name) if( NOT LLVM_ON_UNIX OR CYGWIN ) diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index 2dcfa14..f51e9af 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -4,9 +4,9 @@ set(LLVM_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS) foreach(lib ${llvm_libs}) - get_property(llvm_lib_deps GLOBAL PROPERTY LLVM_LIB_DEPS_${lib}) + get_property(llvm_lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib}) set(all_llvm_lib_deps - "${all_llvm_lib_deps}\nset_property(GLOBAL PROPERTY LLVM_LIB_DEPS_${lib} ${llvm_lib_deps})") + "${all_llvm_lib_deps}\nset_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib} ${llvm_lib_deps})") endforeach(lib) configure_file( @@ -32,6 +32,6 @@ install(DIRECTORY . PATTERN LLVMConfig.cmake EXCLUDE PATTERN LLVMConfigVersion.cmake EXCLUDE PATTERN LLVM-Config.cmake EXCLUDE - PATTERN GetTargetTriple.cmake EXCLUDE + PATTERN GetHostTriple.cmake EXCLUDE PATTERN VersionFromVCS.cmake EXCLUDE PATTERN CheckAtomic.cmake EXCLUDE) diff --git a/cmake/modules/ChooseMSVCCRT.cmake b/cmake/modules/ChooseMSVCCRT.cmake index eb78f45..6a2f426 100644 --- a/cmake/modules/ChooseMSVCCRT.cmake +++ b/cmake/modules/ChooseMSVCCRT.cmake @@ -60,7 +60,7 @@ variables (LLVM_USE_CRT_DEBUG, etc) instead.") make_crt_regex(MSVC_CRT_REGEX ${MSVC_CRT}) - foreach(build_type ${CMAKE_CONFIGURATION_TYPES}) + foreach(build_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE}) string(TOUPPER "${build_type}" build) if (NOT LLVM_USE_CRT_${build}) get_current_crt(LLVM_USE_CRT_${build} @@ -75,7 +75,7 @@ variables (LLVM_USE_CRT_DEBUG, etc) instead.") endif(NOT LLVM_USE_CRT_${build}) endforeach(build_type) - foreach(build_type ${CMAKE_CONFIGURATION_TYPES}) + foreach(build_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE}) string(TOUPPER "${build_type}" build) if ("${LLVM_USE_CRT_${build}}" STREQUAL "") set(flag_string " ") diff --git a/cmake/modules/GetTargetTriple.cmake b/cmake/modules/GetHostTriple.cmake index f4321c9..671a8ce 100644 --- a/cmake/modules/GetTargetTriple.cmake +++ b/cmake/modules/GetHostTriple.cmake @@ -1,7 +1,7 @@ # Returns the host triple. # Invokes config.guess -function( get_target_triple var ) +function( get_host_triple var ) if( MSVC ) if( CMAKE_CL_64 ) set( value "x86_64-pc-win32" ) @@ -27,4 +27,4 @@ function( get_target_triple var ) endif( MSVC ) set( ${var} ${value} PARENT_SCOPE ) message(STATUS "Target triple: ${value}") -endfunction( get_target_triple var ) +endfunction( get_host_triple var ) diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index 9dc1624..3a10a86 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -1,3 +1,7 @@ +# This CMake module is responsible for interpreting the user defined LLVM_ +# options and executing the appropriate CMake commands to realize the users' +# selections. + include(AddLLVMDefinitions) if( CMAKE_COMPILER_IS_GNUCXX ) @@ -20,13 +24,6 @@ else() set(RUNTIME_BUILD_MODE "${CMAKE_CFG_INTDIR}") endif() -set(LIT_ARGS_DEFAULT "-sv") -if (MSVC OR XCODE) - set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") -endif() -set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" - CACHE STRING "Default options for lit") - if( LLVM_ENABLE_ASSERTIONS ) # MSVC doesn't like _DEBUG on release builds. See PR 4379. if( NOT MSVC ) @@ -52,9 +49,6 @@ if(WIN32) else(CYGWIN) set(LLVM_ON_WIN32 1) set(LLVM_ON_UNIX 0) - - # This is effective only on Win32 hosts to use gnuwin32 tools. - set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools") endif(CYGWIN) set(LTDL_SHLIB_EXT ".dll") set(EXEEXT ".exe") @@ -82,7 +76,7 @@ if( LLVM_ENABLE_PIC ) # Xcode has -mdynamic-no-pic on by default, which overrides -fPIC. I don't # know how to disable this, so just force ENABLE_PIC off for now. message(WARNING "-fPIC not supported with Xcode.") - elseif( WIN32 ) + elseif( WIN32 OR CYGWIN) # On Windows all code is PIC. MinGW warns if -fPIC is used. else() include(CheckCXXCompilerFlag) @@ -94,12 +88,20 @@ if( LLVM_ENABLE_PIC ) else( SUPPORTS_FPIC_FLAG ) message(WARNING "-fPIC not supported.") endif() + + if( WIN32 OR CYGWIN) + # MinGW warns if -fvisibility-inlines-hidden is used. + else() + check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG) + if( SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden") + endif() + endif() endif() endif() if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 ) # TODO: support other platforms and toolchains. - option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF) if( LLVM_BUILD_32_BITS ) message(STATUS "Building 32 bits executables and libraries.") add_llvm_definitions( -m32 ) @@ -134,6 +136,10 @@ endif() if( MSVC ) include(ChooseMSVCCRT) + if( MSVC11 ) + add_llvm_definitions(-D_VARIADIC_MAX=10) + endif() + # Add definitions that make MSVC much less annoying. add_llvm_definitions( # For some reason MS wants to deprecate a bunch of standard functions... @@ -180,6 +186,10 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE ) if (LLVM_ENABLE_PEDANTIC) add_llvm_definitions( -pedantic -Wno-long-long ) endif (LLVM_ENABLE_PEDANTIC) + check_cxx_compiler_flag("-Werror -Wcovered-switch-default" SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG) + if( SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG ) + add_llvm_definitions( -Wcovered-switch-default ) + endif() endif (LLVM_ENABLE_WARNINGS) if (LLVM_ENABLE_WERROR) add_llvm_definitions( -Werror ) @@ -189,5 +199,3 @@ endif( MSVC ) add_llvm_definitions( -D__STDC_CONSTANT_MACROS ) add_llvm_definitions( -D__STDC_FORMAT_MACROS ) add_llvm_definitions( -D__STDC_LIMIT_MACROS ) - -option(LLVM_INCLUDE_TESTS "Generate build targets for the LLVM unit tests." ON) diff --git a/cmake/modules/LLVM-Config.cmake b/cmake/modules/LLVM-Config.cmake index b5f262a..574335c 100755 --- a/cmake/modules/LLVM-Config.cmake +++ b/cmake/modules/LLVM-Config.cmake @@ -152,7 +152,7 @@ function(explicit_map_components_to_libraries out_libs) set(processed) while( cursor LESS lst_size ) list(GET expanded_components ${cursor} lib) - get_property(lib_deps GLOBAL PROPERTY LLVM_LIB_DEPS_${lib}) + get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib}) list(APPEND expanded_components ${lib_deps}) # Remove duplicates at the front: list(REVERSE expanded_components) diff --git a/cmake/modules/LLVMConfig.cmake.in b/cmake/modules/LLVMConfig.cmake.in index 6b202b2..443ec41 100644 --- a/cmake/modules/LLVMConfig.cmake.in +++ b/cmake/modules/LLVMConfig.cmake.in @@ -1,5 +1,7 @@ # This file provides information and services to the final user. +set(LLVM_VERSION_MAJOR @LLVM_VERSION_MAJOR@) +set(LLVM_VERSION_MINOR @LLVM_VERSION_MINOR@) set(LLVM_PACKAGE_VERSION @PACKAGE_VERSION@) set(LLVM_COMMON_DEPENDS @LLVM_COMMON_DEPENDS@) diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake index 3dc820b..1b1b172 100644 --- a/cmake/modules/TableGen.cmake +++ b/cmake/modules/TableGen.cmake @@ -51,6 +51,7 @@ function(add_public_tablegen_target target) add_custom_target(${target} DEPENDS ${TABLEGEN_OUTPUT}) add_dependencies(${target} ${LLVM_COMMON_DEPENDS}) + set_target_properties(${target} PROPERTIES FOLDER "Tablegenning") endif( TABLEGEN_OUTPUT ) endfunction() @@ -76,7 +77,10 @@ endif() macro(add_tablegen target project) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR}) + set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS}) + set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen) add_llvm_utility(${target} ${ARGN}) + set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS}) set(${project}_TABLEGEN "${target}" CACHE STRING "Native TableGen executable. Saves building one when cross-compiling.") @@ -110,7 +114,6 @@ macro(add_tablegen target project) endif() endif() - target_link_libraries(${target} LLVMSupport LLVMTableGen) if( MINGW ) target_link_libraries(${target} imagehlp psapi) if(CMAKE_SIZEOF_VOID_P MATCHES "8") diff --git a/cmake/modules/VersionFromVCS.cmake b/cmake/modules/VersionFromVCS.cmake index 81739be..d6a2ae5 100644 --- a/cmake/modules/VersionFromVCS.cmake +++ b/cmake/modules/VersionFromVCS.cmake @@ -3,7 +3,7 @@ # existence of certain subdirectories under CMAKE_CURRENT_SOURCE_DIR. function(add_version_info_from_vcs VERS) - set(result ${${VERS}}) + string(REPLACE "svn" "" result "${${VERS}}") if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.svn" ) set(result "${result}svn") # FindSubversion does not work with symlinks. See PR 8437 @@ -13,6 +13,7 @@ function(add_version_info_from_vcs VERS) if( Subversion_FOUND ) subversion_wc_info( ${CMAKE_CURRENT_SOURCE_DIR} Project ) if( Project_WC_REVISION ) + set(SVN_REVISION ${Project_WC_REVISION} PARENT_SCOPE) set(result "${result}-r${Project_WC_REVISION}") endif() endif() @@ -21,24 +22,47 @@ function(add_version_info_from_vcs VERS) # Try to get a ref-id find_program(git_executable NAMES git git.exe git.cmd) if( git_executable ) - execute_process(COMMAND ${git_executable} show-ref HEAD + set(is_git_svn_rev_exact false) + execute_process(COMMAND ${git_executable} svn log --limit=1 --oneline WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} TIMEOUT 5 RESULT_VARIABLE git_result OUTPUT_VARIABLE git_output) if( git_result EQUAL 0 ) - string(SUBSTRING ${git_output} 0 7 git_ref_id) - set(result "${result}-${git_ref_id}") - else() - execute_process(COMMAND ${git_executable} svn log --limit=1 --oneline + string(REGEX MATCH r[0-9]+ git_svn_rev ${git_output}) + string(LENGTH "${git_svn_rev}" rev_length) + math(EXPR rev_length "${rev_length}-1") + string(SUBSTRING "${git_svn_rev}" 1 ${rev_length} git_svn_rev_number) + set(SVN_REVISION ${git_svn_rev_number} PARENT_SCOPE) + set(git_svn_rev "-svn-${git_svn_rev}") + + # Determine if the HEAD points directly at a subversion revision. + execute_process(COMMAND ${git_executable} svn find-rev HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} TIMEOUT 5 RESULT_VARIABLE git_result OUTPUT_VARIABLE git_output) if( git_result EQUAL 0 ) - string(REGEX MATCH r[0-9]+ git_svn_rev ${git_output}) - set(result "${result}-svn-${git_svn_rev}") + string(STRIP "${git_output}" git_head_svn_rev_number) + if( git_head_svn_rev_number EQUAL git_svn_rev_number ) + set(is_git_svn_rev_exact true) + endif() endif() + else() + set(git_svn_rev "") + endif() + execute_process(COMMAND + ${git_executable} rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + TIMEOUT 5 + RESULT_VARIABLE git_result + OUTPUT_VARIABLE git_output) + if( git_result EQUAL 0 AND NOT is_git_svn_rev_exact ) + string(STRIP "${git_output}" git_ref_id) + set(GIT_COMMIT ${git_ref_id} PARENT_SCOPE) + set(result "${result}${git_svn_rev}-${git_ref_id}") + else() + set(result "${result}${git_svn_rev}") endif() endif() endif() |