summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2015-03-23 12:10:34 -0700
committerStephen Hines <srhines@google.com>2015-03-23 12:10:34 -0700
commitebe69fe11e48d322045d5949c83283927a0d790b (patch)
treec92f1907a6b8006628a4b01615f38264d29834ea /cmake
parentb7d2e72b02a4cb8034f32f8247a2558d2434e121 (diff)
downloadexternal_llvm-ebe69fe11e48d322045d5949c83283927a0d790b.zip
external_llvm-ebe69fe11e48d322045d5949c83283927a0d790b.tar.gz
external_llvm-ebe69fe11e48d322045d5949c83283927a0d790b.tar.bz2
Update aosp/master LLVM for rebase to r230699.
Change-Id: I2b5be30509658cb8266be782de0ab24f9099f9b9
Diffstat (limited to 'cmake')
-rwxr-xr-xcmake/config-ix.cmake58
-rw-r--r--cmake/modules/AddLLVM.cmake101
-rw-r--r--cmake/modules/AddOCaml.cmake201
-rw-r--r--cmake/modules/CMakeLists.txt2
-rw-r--r--cmake/modules/CheckAtomic.cmake10
-rw-r--r--cmake/modules/FindOCaml.cmake103
-rw-r--r--cmake/modules/GetSVN.cmake80
-rw-r--r--cmake/modules/HandleLLVMOptions.cmake43
-rw-r--r--cmake/modules/LLVM-Config.cmake50
-rw-r--r--cmake/modules/LLVMConfig.cmake.in2
-rw-r--r--cmake/modules/LLVMProcessSources.cmake33
-rw-r--r--cmake/modules/Makefile3
-rw-r--r--cmake/platforms/iOS.cmake26
13 files changed, 639 insertions, 73 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index 5204f6c..d646498 100755
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -79,6 +79,7 @@ check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT)
check_include_file(mach/mach.h HAVE_MACH_MACH_H)
check_include_file(mach-o/dyld.h HAVE_MACH_O_DYLD_H)
+check_include_file(histedit.h HAVE_HISTEDIT_H)
# size_t must be defined before including cxxabi.h on FreeBSD 10.0.
check_cxx_source_compiles("
@@ -110,7 +111,9 @@ if( NOT PURE_WINDOWS )
else()
set(HAVE_LIBZ 0)
endif()
- check_library_exists(edit el_init "" HAVE_LIBEDIT)
+ if (HAVE_HISTEDIT_H)
+ check_library_exists(edit el_init "" HAVE_LIBEDIT)
+ endif()
if(LLVM_ENABLE_TERMINFO)
set(HAVE_TERMINFO 0)
foreach(library tinfo terminfo curses ncurses ncursesw)
@@ -160,6 +163,7 @@ if( HAVE_SYS_UIO_H )
check_symbol_exists(writev sys/uio.h HAVE_WRITEV)
endif()
check_symbol_exists(nearbyintf math.h HAVE_NEARBYINTF)
+check_symbol_exists(mallctl malloc_np.h HAVE_MALLCTL)
check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO)
check_symbol_exists(malloc_zone_statistics malloc/malloc.h
HAVE_MALLOC_ZONE_STATISTICS)
@@ -198,7 +202,9 @@ if( PURE_WINDOWS )
check_function_exists(_alloca HAVE__ALLOCA)
check_function_exists(__alloca HAVE___ALLOCA)
check_function_exists(__chkstk HAVE___CHKSTK)
+ check_function_exists(__chkstk_ms HAVE___CHKSTK_MS)
check_function_exists(___chkstk HAVE____CHKSTK)
+ check_function_exists(___chkstk_ms HAVE____CHKSTK_MS)
check_function_exists(__ashldi3 HAVE___ASHLDI3)
check_function_exists(__ashrdi3 HAVE___ASHRDI3)
@@ -424,6 +430,24 @@ if( MSVC )
set(SHLIBEXT ".lib")
set(stricmp "_stricmp")
set(strdup "_strdup")
+
+ # See if the DIA SDK is available and usable.
+ set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK")
+
+ # Due to a bug in MSVC 2013's installation software, it is possible
+ # for MSVC 2013 to write the DIA SDK into the Visual Studio 2012
+ # install directory. If this happens, the installation is corrupt
+ # and there's nothing we can do. It happens with enough frequency
+ # though that we should handle it. We do so by simply checking that
+ # the DIA SDK folder exists. Should this happen you will need to
+ # uninstall VS 2012 and then re-install VS 2013.
+ if (IS_DIRECTORY ${MSVC_DIA_SDK_DIR})
+ set(HAVE_DIA_SDK 1)
+ else()
+ set(HAVE_DIA_SDK 0)
+ endif()
+else()
+ set(HAVE_DIA_SDK 0)
endif( MSVC )
if( PURE_WINDOWS )
@@ -516,3 +540,35 @@ else()
endif()
endif()
endif()
+
+find_program(GOLD_EXECUTABLE NAMES ld.gold ld DOC "The gold linker")
+if(GOLD_EXECUTABLE)
+ set(LLVM_BINUTILS_INCDIR "" CACHE PATH
+ "PATH to binutils/include containing plugin-api.h for gold plugin.")
+endif()
+
+include(FindOCaml)
+include(AddOCaml)
+if(WIN32)
+ message(STATUS "OCaml bindings disabled.")
+else()
+ find_package(OCaml)
+ if( NOT OCAML_FOUND )
+ message(STATUS "OCaml bindings disabled.")
+ else()
+ if( OCAML_VERSION VERSION_LESS "4.00.0" )
+ message(STATUS "OCaml bindings disabled, need OCaml >=4.00.0.")
+ else()
+ find_ocamlfind_package(ctypes VERSION 0.3 OPTIONAL)
+ if( HAVE_OCAML_CTYPES )
+ message(STATUS "OCaml bindings enabled.")
+ find_ocamlfind_package(oUnit VERSION 2 OPTIONAL)
+ set(LLVM_BINDINGS "${LLVM_BINDINGS} ocaml")
+ else()
+ message(STATUS "OCaml bindings disabled, need ctypes >=0.3.")
+ endif()
+ endif()
+ endif()
+endif()
+
+string(REPLACE " " ";" LLVM_BINDINGS_LIST "${LLVM_BINDINGS}")
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index bc26f06..7f63644 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -10,7 +10,7 @@ function(llvm_update_compile_flags name)
# LLVM_REQUIRES_EH is an internal flag that individual
# targets can use to force EH
- if(LLVM_REQUIRES_EH OR LLVM_ENABLE_EH)
+ if((LLVM_REQUIRES_EH OR LLVM_ENABLE_EH) AND NOT CLANG_CL)
if(NOT (LLVM_REQUIRES_RTTI OR LLVM_ENABLE_RTTI))
message(AUTHOR_WARNING "Exception handling requires RTTI. Enabling RTTI for ${name}")
set(LLVM_REQUIRES_RTTI ON)
@@ -22,6 +22,10 @@ function(llvm_update_compile_flags name)
list(APPEND LLVM_COMPILE_DEFINITIONS _HAS_EXCEPTIONS=0)
list(APPEND LLVM_COMPILE_FLAGS "/EHs-c-")
endif()
+ if (CLANG_CL)
+ # FIXME: Remove this once clang-cl supports SEH
+ list(APPEND LLVM_COMPILE_DEFINITIONS "GTEST_HAS_SEH=0")
+ endif()
endif()
# LLVM_REQUIRES_RTTI is an internal flag that individual
@@ -142,6 +146,17 @@ function(add_llvm_symbol_exports target_name export_file)
set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} PARENT_SCOPE)
endfunction(add_llvm_symbol_exports)
+if(NOT WIN32 AND NOT APPLE)
+ execute_process(
+ COMMAND ${CMAKE_C_COMPILER} -Wl,--version
+ OUTPUT_VARIABLE stdout
+ ERROR_QUIET
+ )
+ if("${stdout}" MATCHES "GNU gold")
+ set(LLVM_LINKER_IS_GOLD ON)
+ endif()
+endif()
+
function(add_link_opts target_name)
# Pass -O3 to the linker. This enabled different optimizations on different
# linkers.
@@ -150,12 +165,20 @@ function(add_link_opts target_name)
LINK_FLAGS " -Wl,-O3")
endif()
+ if(LLVM_LINKER_IS_GOLD)
+ # With gold gc-sections is always safe.
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,--gc-sections")
+ # Note that there is a bug with -Wl,--icf=safe so it is not safe
+ # to enable. See https://sourceware.org/bugzilla/show_bug.cgi?id=17704.
+ endif()
+
if(NOT LLVM_NO_DEAD_STRIP)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# ld64's implementation of -dead_strip breaks tools that use plugins.
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-dead_strip")
- elseif(NOT WIN32)
+ elseif(NOT WIN32 AND NOT LLVM_LINKER_IS_GOLD)
# Object files are compiled with -ffunction-data-sections.
# Versions of bfd ld < 2.23.1 have a bug in --gc-sections that breaks
# tools that use plugins. Always pass --gc-sections once we require
@@ -315,11 +338,11 @@ function(llvm_add_library name)
PREFIX ""
)
endif()
- if (MSVC)
- set_target_properties(${name}
- PROPERTIES
- IMPORT_SUFFIX ".imp")
- endif ()
+
+ set_target_properties(${name}
+ PROPERTIES
+ SOVERSION ${LLVM_VERSION_MAJOR}
+ VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX})
endif()
if(ARG_MODULE OR ARG_SHARED)
@@ -394,7 +417,16 @@ macro(add_llvm_library name)
EXPORT LLVMExports
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+ ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+ COMPONENT ${name})
+
+ if (NOT CMAKE_CONFIGURATION_TYPES)
+ add_custom_target(install-${name}
+ DEPENDS ${name}
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=${name}
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+ endif()
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
endif()
@@ -475,7 +507,16 @@ macro(add_llvm_tool name)
if( LLVM_BUILD_TOOLS )
install(TARGETS ${name}
EXPORT LLVMExports
- RUNTIME DESTINATION bin)
+ RUNTIME DESTINATION bin
+ COMPONENT ${name})
+
+ if (NOT CMAKE_CONFIGURATION_TYPES)
+ add_custom_target(install-${name}
+ DEPENDS ${name}
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=${name}
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+ endif()
endif()
endif()
if( LLVM_BUILD_TOOLS )
@@ -570,12 +611,6 @@ function(add_unittest test_suite test_name)
set(EXCLUDE_FROM_ALL ON)
endif()
- # Visual Studio 2012 only supports up to 8 template parameters in
- # std::tr1::tuple by default, but gtest requires 10
- if (MSVC AND MSVC_VERSION EQUAL 1700)
- list(APPEND LLVM_COMPILE_DEFINITIONS _VARIADIC_MAX=10)
- endif ()
-
include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
if (NOT LLVM_ENABLE_THREADS)
list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_PTHREAD=0)
@@ -603,6 +638,36 @@ function(add_unittest test_suite test_name)
endif ()
endfunction()
+function(llvm_add_go_executable binary pkgpath)
+ cmake_parse_arguments(ARG "ALL" "" "DEPENDS;GOFLAGS" ${ARGN})
+
+ if(LLVM_BINDINGS MATCHES "go")
+ # FIXME: This should depend only on the libraries Go needs.
+ get_property(llvmlibs GLOBAL PROPERTY LLVM_LIBS)
+ set(binpath ${CMAKE_BINARY_DIR}/bin/${binary}${CMAKE_EXECUTABLE_SUFFIX})
+ set(cc "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}")
+ set(cxx "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}")
+ set(cppflags "")
+ get_property(include_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
+ foreach(d ${include_dirs})
+ set(cppflags "${cppflags} -I${d}")
+ endforeach(d)
+ set(ldflags "${CMAKE_EXE_LINKER_FLAGS}")
+ add_custom_command(OUTPUT ${binpath}
+ COMMAND ${CMAKE_BINARY_DIR}/bin/llvm-go "cc=${cc}" "cxx=${cxx}" "cppflags=${cppflags}" "ldflags=${ldflags}"
+ ${ARG_GOFLAGS} build -o ${binpath} ${pkgpath}
+ DEPENDS llvm-config ${CMAKE_BINARY_DIR}/bin/llvm-go${CMAKE_EXECUTABLE_SUFFIX}
+ ${llvmlibs} ${ARG_DEPENDS}
+ COMMENT "Building Go executable ${binary}"
+ VERBATIM)
+ if (ARG_ALL)
+ add_custom_target(${binary} ALL DEPENDS ${binpath})
+ else()
+ add_custom_target(${binary} DEPENDS ${binpath})
+ endif()
+ endif()
+endfunction()
+
# This function provides an automatic way to 'configure'-like generate a file
# based on a set of common and custom variables, specifically targeting the
# variables needed for the 'lit.site.cfg' files. This function bundles the
@@ -675,18 +740,20 @@ function(add_lit_target target comment)
foreach(param ${ARG_PARAMS})
list(APPEND LIT_COMMAND --param ${param})
endforeach()
- if( ARG_DEPENDS )
+ if (ARG_DEFAULT_ARGS)
add_custom_target(${target}
COMMAND ${LIT_COMMAND} ${ARG_DEFAULT_ARGS}
COMMENT "${comment}"
${cmake_3_2_USES_TERMINAL}
)
- add_dependencies(${target} ${ARG_DEPENDS})
else()
add_custom_target(${target}
COMMAND ${CMAKE_COMMAND} -E echo "${target} does nothing, no tools built.")
message(STATUS "${target} does nothing.")
endif()
+ if (ARG_DEPENDS)
+ add_dependencies(${target} ${ARG_DEPENDS})
+ endif()
# Tests should be excluded from "Build Solution".
set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON)
diff --git a/cmake/modules/AddOCaml.cmake b/cmake/modules/AddOCaml.cmake
new file mode 100644
index 0000000..c58ac9c
--- /dev/null
+++ b/cmake/modules/AddOCaml.cmake
@@ -0,0 +1,201 @@
+# CMake build rules for the OCaml language.
+# Assumes FindOCaml is used.
+# http://ocaml.org/
+#
+# Example usage:
+#
+# add_ocaml_library(pkg_a OCAML mod_a OCAMLDEP pkg_b C mod_a_stubs PKG ctypes LLVM core)
+#
+# Unnamed parameters:
+#
+# * Library name.
+#
+# Named parameters:
+#
+# OCAML OCaml module names. Imply presence of a corresponding .ml and .mli files.
+# OCAMLDEP Names of libraries this library depends on.
+# C C stub sources. Imply presence of a corresponding .c file.
+# CFLAGS Additional arguments passed when compiling C stubs.
+# PKG Names of ocamlfind packages this library depends on.
+# LLVM Names of LLVM libraries this library depends on.
+# NOCOPY Do not automatically copy sources (.c, .ml, .mli) from the source directory,
+# e.g. if they are generated.
+#
+
+function(add_ocaml_library name)
+ CMAKE_PARSE_ARGUMENTS(ARG "NOCOPY" "" "OCAML;OCAMLDEP;C;CFLAGS;PKG;LLVM" ${ARGN})
+
+ set(src ${CMAKE_CURRENT_SOURCE_DIR})
+ set(bin ${CMAKE_CURRENT_BINARY_DIR})
+
+ set(ocaml_pkgs)
+ foreach( ocaml_pkg ${ARG_PKG} )
+ list(APPEND ocaml_pkgs "-package" "${ocaml_pkg}")
+ endforeach()
+
+ set(sources)
+
+ set(ocaml_inputs)
+
+ set(ocaml_outputs "${bin}/${name}.cma")
+ if( ARG_C )
+ list(APPEND ocaml_outputs
+ "${bin}/lib${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
+ if ( BUILD_SHARED_LIBS )
+ list(APPEND ocaml_outputs
+ "${bin}/dll${name}${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ endif()
+ endif()
+ if( HAVE_OCAMLOPT )
+ list(APPEND ocaml_outputs
+ "${bin}/${name}.cmxa"
+ "${bin}/${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
+ endif()
+
+ set(ocaml_flags "-lstdc++" "-ldopt" "-L${LLVM_LIBRARY_DIR}"
+ "-ccopt" "-L\\$CAMLORIGIN/.."
+ "-ccopt" "-Wl,-rpath,\\$CAMLORIGIN/.."
+ ${ocaml_pkgs})
+
+ foreach( ocaml_dep ${ARG_OCAMLDEP} )
+ get_target_property(dep_ocaml_flags "ocaml_${ocaml_dep}" OCAML_FLAGS)
+ list(APPEND ocaml_flags ${dep_ocaml_flags})
+ endforeach()
+
+ if( NOT BUILD_SHARED_LIBS )
+ list(APPEND ocaml_flags "-custom")
+ endif()
+
+ explicit_map_components_to_libraries(llvm_libs ${ARG_LLVM})
+ foreach( llvm_lib ${llvm_libs} )
+ list(APPEND ocaml_flags "-l${llvm_lib}" )
+ endforeach()
+
+ get_property(system_libs TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
+ foreach(system_lib ${system_libs})
+ list(APPEND ocaml_flags "-l${system_lib}" )
+ endforeach()
+
+ string(REPLACE ";" " " ARG_CFLAGS "${ARG_CFLAGS}")
+ set(c_flags "${ARG_CFLAGS} ${LLVM_DEFINITIONS}")
+ foreach( include_dir ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR} )
+ set(c_flags "${c_flags} -I${include_dir}")
+ endforeach()
+
+ foreach( ocaml_file ${ARG_OCAML} )
+ list(APPEND sources "${ocaml_file}.mli" "${ocaml_file}.ml")
+
+ list(APPEND ocaml_inputs "${bin}/${ocaml_file}.mli" "${bin}/${ocaml_file}.ml")
+
+ list(APPEND ocaml_outputs "${bin}/${ocaml_file}.cmi" "${bin}/${ocaml_file}.cmo")
+ if( HAVE_OCAMLOPT )
+ list(APPEND ocaml_outputs
+ "${bin}/${ocaml_file}.cmx"
+ "${bin}/${ocaml_file}${CMAKE_C_OUTPUT_EXTENSION}")
+ endif()
+ endforeach()
+
+ foreach( c_file ${ARG_C} )
+ list(APPEND sources "${c_file}.c")
+
+ list(APPEND c_inputs "${bin}/${c_file}.c")
+ list(APPEND c_outputs "${bin}/${c_file}${CMAKE_C_OUTPUT_EXTENSION}")
+ endforeach()
+
+ if( NOT ARG_NOCOPY )
+ foreach( source ${sources} )
+ add_custom_command(
+ OUTPUT "${bin}/${source}"
+ COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${src}/${source}" "${bin}"
+ DEPENDS "${src}/${source}"
+ COMMENT "Copying ${source} to build area")
+ endforeach()
+ endif()
+
+ foreach( c_input ${c_inputs} )
+ get_filename_component(basename "${c_input}" NAME_WE)
+ add_custom_command(
+ OUTPUT "${basename}${CMAKE_C_OUTPUT_EXTENSION}"
+ COMMAND "${OCAMLFIND}" "ocamlc" "-c" "${c_input}" -ccopt ${c_flags}
+ DEPENDS "${c_input}"
+ COMMENT "Building OCaml stub object file ${basename}${CMAKE_C_OUTPUT_EXTENSION}"
+ VERBATIM)
+ endforeach()
+
+ set(ocaml_params)
+ foreach( ocaml_input ${ocaml_inputs} ${c_outputs})
+ get_filename_component(filename "${ocaml_input}" NAME)
+ list(APPEND ocaml_params "${filename}")
+ endforeach()
+
+ if( APPLE )
+ set(ocaml_rpath "@executable_path/../../lib")
+ elseif( UNIX )
+ set(ocaml_rpath "\\$ORIGIN/../../lib")
+ endif()
+ list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}")
+
+ add_custom_command(
+ OUTPUT ${ocaml_outputs}
+ COMMAND "${OCAMLFIND}" "ocamlmklib" "-o" "${name}" ${ocaml_flags} ${ocaml_params}
+ DEPENDS ${ocaml_inputs} ${c_outputs}
+ COMMENT "Building OCaml library ${name}"
+ VERBATIM)
+
+ add_custom_command(
+ OUTPUT "${bin}/${name}.odoc"
+ COMMAND "${OCAMLFIND}" "ocamldoc"
+ "-I" "${bin}"
+ "-I" "${LLVM_LIBRARY_DIR}/ocaml/"
+ "-dump" "${bin}/${name}.odoc"
+ ${ocaml_pkgs} ${ocaml_inputs}
+ DEPENDS ${ocaml_inputs}
+ COMMENT "Building OCaml documentation for ${name}"
+ VERBATIM)
+
+ add_custom_target("ocaml_${name}" ALL DEPENDS ${ocaml_outputs} "${bin}/${name}.odoc")
+
+ set_target_properties("ocaml_${name}" PROPERTIES
+ OCAML_FLAGS "-I;${bin}")
+ set_target_properties("ocaml_${name}" PROPERTIES
+ OCAML_ODOC "${bin}/${name}.odoc")
+
+ foreach( ocaml_dep ${ARG_OCAMLDEP} )
+ add_dependencies("ocaml_${name}" "ocaml_${ocaml_dep}")
+ endforeach()
+
+ foreach( llvm_lib ${llvm_libs} )
+ add_dependencies("ocaml_${name}" "${llvm_lib}")
+ endforeach()
+
+ set(install_files)
+ set(install_shlibs)
+ foreach( ocaml_output ${ocaml_outputs} )
+ get_filename_component(ext "${ocaml_output}" EXT)
+
+ if( NOT (ext STREQUAL ".cmo" OR
+ ext STREQUAL CMAKE_C_OUTPUT_EXTENSION OR
+ ext STREQUAL CMAKE_SHARED_LIBRARY_SUFFIX) )
+ list(APPEND install_files "${ocaml_output}")
+ elseif( ext STREQUAL CMAKE_SHARED_LIBRARY_SUFFIX)
+ list(APPEND install_shlibs "${ocaml_output}")
+ endif()
+ endforeach()
+
+ install(FILES ${install_files}
+ DESTINATION lib/ocaml)
+ install(FILES ${install_shlibs}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE
+ DESTINATION lib/ocaml)
+
+ foreach( install_file ${install_files} ${install_shlibs} )
+ get_filename_component(filename "${install_file}" NAME)
+ add_custom_command(TARGET "ocaml_${name}" POST_BUILD
+ COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${install_file}"
+ "${LLVM_LIBRARY_DIR}/ocaml/"
+ COMMENT "Copying OCaml library component ${filename} to intermediate area"
+ VERBATIM)
+ endforeach()
+endfunction()
diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
index c87193d..5f3f255 100644
--- a/cmake/modules/CMakeLists.txt
+++ b/cmake/modules/CMakeLists.txt
@@ -58,7 +58,7 @@ foreach(p ${_count})
get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
endforeach(p)
set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
-set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib")
+set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}")
set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin")
set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake")
diff --git a/cmake/modules/CheckAtomic.cmake b/cmake/modules/CheckAtomic.cmake
index 2ed4819..30a5e31 100644
--- a/cmake/modules/CheckAtomic.cmake
+++ b/cmake/modules/CheckAtomic.cmake
@@ -2,9 +2,13 @@
INCLUDE(CheckCXXSourceCompiles)
-check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC)
-if (HAVE_LIBATOMIC)
- list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
+check_function_exists(__atomic_fetch_add_4 HAVE___ATOMIC_FETCH_ADD_4)
+if( NOT HAVE___ATOMIC_FETCH_ADD_4 )
+ check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC)
+ set(HAVE_LIBATOMIC False)
+ if( HAVE_LIBATOMIC )
+ list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
+ endif()
endif()
CHECK_CXX_SOURCE_COMPILES("
diff --git a/cmake/modules/FindOCaml.cmake b/cmake/modules/FindOCaml.cmake
new file mode 100644
index 0000000..8eba212
--- /dev/null
+++ b/cmake/modules/FindOCaml.cmake
@@ -0,0 +1,103 @@
+# CMake find_package() module for the OCaml language.
+# Assumes ocamlfind will be used for compilation.
+# http://ocaml.org/
+#
+# Example usage:
+#
+# find_package(OCaml)
+#
+# If successful, the following variables will be defined:
+# OCAMLFIND
+# OCAML_VERSION
+# OCAML_STDLIB_PATH
+# HAVE_OCAMLOPT
+#
+# Also provides find_ocamlfind_package() macro.
+#
+# Example usage:
+#
+# find_ocamlfind_package(ctypes)
+#
+# In any case, the following variables are defined:
+#
+# HAVE_OCAML_${pkg}
+#
+# If successful, the following variables will be defined:
+#
+# OCAML_${pkg}_VERSION
+
+include( FindPackageHandleStandardArgs )
+
+find_program(OCAMLFIND
+ NAMES ocamlfind)
+
+if( OCAMLFIND )
+ execute_process(
+ COMMAND ${OCAMLFIND} ocamlc -version
+ OUTPUT_VARIABLE OCAML_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ execute_process(
+ COMMAND ${OCAMLFIND} ocamlc -where
+ OUTPUT_VARIABLE OCAML_STDLIB_PATH
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ execute_process(
+ COMMAND ${OCAMLFIND} ocamlc -version
+ OUTPUT_QUIET
+ RESULT_VARIABLE find_ocaml_result)
+ if( find_ocaml_result EQUAL 0 )
+ set(HAVE_OCAMLOPT TRUE)
+ else()
+ set(HAVE_OCAMLOPT FALSE)
+ endif()
+endif()
+
+find_package_handle_standard_args( OCaml DEFAULT_MSG
+ OCAMLFIND
+ OCAML_VERSION
+ OCAML_STDLIB_PATH)
+
+mark_as_advanced(
+ OCAMLFIND)
+
+function(find_ocamlfind_package pkg)
+ CMAKE_PARSE_ARGUMENTS(ARG "OPTIONAL" "VERSION" "" ${ARGN})
+
+ execute_process(
+ COMMAND "${OCAMLFIND}" "query" "${pkg}" "-format" "%v"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE version
+ ERROR_VARIABLE error
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE)
+
+ if( NOT result EQUAL 0 AND NOT ARG_OPTIONAL )
+ message(FATAL_ERROR ${error})
+ endif()
+
+ if( result EQUAL 0 )
+ set(found TRUE)
+ else()
+ set(found FALSE)
+ endif()
+
+ if( found AND ARG_VERSION )
+ if( version VERSION_LESS ARG_VERSION AND ARG_OPTIONAL )
+ # If it's optional and the constraint is not satisfied, pretend
+ # it wasn't found.
+ set(found FALSE)
+ elseif( version VERSION_LESS ARG_VERSION )
+ message(FATAL_ERROR
+ "ocamlfind package ${pkg} should have version ${ARG_VERSION} or newer")
+ endif()
+ endif()
+
+ string(TOUPPER ${pkg} pkg)
+
+ set(HAVE_OCAML_${pkg} ${found}
+ PARENT_SCOPE)
+
+ set(OCAML_${pkg}_VERSION ${version}
+ PARENT_SCOPE)
+endfunction()
diff --git a/cmake/modules/GetSVN.cmake b/cmake/modules/GetSVN.cmake
index 4e32c09..d512bd2 100644
--- a/cmake/modules/GetSVN.cmake
+++ b/cmake/modules/GetSVN.cmake
@@ -19,13 +19,83 @@ get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
# Handle strange terminals
set(ENV{TERM} "dumb")
+macro(get_source_info_svn path revision repository)
+ # If svn is a bat file, find_program(Subversion) doesn't find it.
+ # Explicitly search for that here; Subversion_SVN_EXECUTABLE will override
+ # the find_program call in FindSubversion.cmake.
+ find_program(Subversion_SVN_EXECUTABLE NAMES svn svn.bat)
+
+ # FindSubversion does not work with symlinks. See PR 8437
+ if (NOT IS_SYMLINK "${path}")
+ find_package(Subversion)
+ endif()
+ if (Subversion_FOUND)
+ subversion_wc_info( ${path} Project )
+ if (Project_WC_REVISION)
+ set(${revision} ${Project_WC_REVISION} PARENT_SCOPE)
+ endif()
+ if (Project_WC_URL)
+ set(${repository} ${Project_WC_URL} PARENT_SCOPE)
+ endif()
+ endif()
+endmacro()
+
+macro(get_source_info_git_svn path revision repository)
+ find_program(git_executable NAMES git git.exe git.cmd)
+ if (git_executable)
+ execute_process(COMMAND ${git_executable} svn info
+ WORKING_DIRECTORY ${path}
+ TIMEOUT 5
+ RESULT_VARIABLE git_result
+ OUTPUT_VARIABLE git_output)
+ if (git_result EQUAL 0)
+ string(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*"
+ "\\2" git_svn_rev "${git_output}")
+ set(${revision} ${git_svn_rev} PARENT_SCOPE)
+ string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*"
+ "\\2" git_url "${git_output}")
+ set(${repository} ${git_url} PARENT_SCOPE)
+ endif()
+ endif()
+endmacro()
+
+macro(get_source_info_git path revision repository)
+ find_program(git_executable NAMES git git.exe git.cmd)
+ if (git_executable)
+ execute_process(COMMAND ${git_executable} log -1 --pretty=format:%H
+ WORKING_DIRECTORY ${path}
+ TIMEOUT 5
+ RESULT_VARIABLE git_result
+ OUTPUT_VARIABLE git_output)
+ if (git_result EQUAL 0)
+ set(${revision} ${git_output} PARENT_SCOPE)
+ endif()
+ execute_process(COMMAND ${git_executable} remote -v
+ WORKING_DIRECTORY ${path}
+ TIMEOUT 5
+ RESULT_VARIABLE git_result
+ OUTPUT_VARIABLE git_output)
+ if (git_result EQUAL 0)
+ string(REGEX REPLACE "^(.*\n)?[^ \t]+[ \t]+([^ \t\n]+)[ \t]+\\(fetch\\).*"
+ "\\2" git_url "${git_output}")
+ set(${repository} "${git_url}" PARENT_SCOPE)
+ endif()
+ endif()
+endmacro()
+
+function(get_source_info path revision repository)
+ if (EXISTS "${path}/.svn")
+ get_source_info_svn("${path}" revision repository)
+ elseif (EXISTS "${path}/.git/svn")
+ get_source_info_git_svn("${path}" revision repository)
+ elseif (EXISTS "${path}/.git")
+ get_source_info_git("${path}" revision repository)
+ endif()
+endfunction()
+
function(append_info name path)
- execute_process(COMMAND "${LLVM_DIR}/utils/GetSourceVersion" "${path}"
- OUTPUT_VARIABLE revision)
+ get_source_info("${path}" revision repository)
string(STRIP "${revision}" revision)
- execute_process(COMMAND "${LLVM_DIR}/utils/GetRepositoryPath" "${path}"
- OUTPUT_VARIABLE repository
- OUTPUT_STRIP_TRAILING_WHITESPACE)
string(STRIP "${repository}" repository)
file(APPEND "${HEADER_FILE}.txt"
"#define ${name}_REVISION \"${revision}\"\n")
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
index 6cc6d65..fdc4ea0 100644
--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -21,11 +21,16 @@ if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
message(FATAL_ERROR "Host Clang version must be at least 3.1!")
endif()
- # Also test that we aren't using too old of a version of libstdc++ with the
- # Clang compiler. This is tricky as there is no real way to check the
- # version of libstdc++ directly. Instead we test for a known bug in
- # libstdc++4.6 that is fixed in libstdc++4.7.
- if(NOT LLVM_ENABLE_LIBCXX)
+ if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
+ if (CMAKE_CXX_SIMULATE_VERSION VERSION_LESS 18.0)
+ message(FATAL_ERROR "Host Clang must have at least -fms-compatibility-version=18.0")
+ endif()
+ set(CLANG_CL 1)
+ elseif(NOT LLVM_ENABLE_LIBCXX)
+ # Otherwise, test that we aren't using too old of a version of libstdc++
+ # with the Clang compiler. This is tricky as there is no real way to
+ # check the version of libstdc++ directly. Instead we test for a known
+ # bug in libstdc++4.6 that is fixed in libstdc++4.7.
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
@@ -41,8 +46,11 @@ int main() { return (float)x; }"
set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
- if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.0)
- message(FATAL_ERROR "Host Visual Studio must be at least 2012 (MSVC 17.0)")
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0)
+ message(FATAL_ERROR "Host Visual Studio must be at least 2013")
+ elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.31101)
+ message(WARNING "Host Visual Studio should at least be 2013 Update 4 (MSVC 18.0.31101)"
+ " due to miscompiles from earlier versions")
endif()
endif()
endif()
@@ -79,8 +87,6 @@ if(WIN32)
set(LLVM_ON_WIN32 1)
set(LLVM_ON_UNIX 0)
endif(CYGWIN)
- # Maximum path length is 160 for non-unicode paths
- set(MAXPATHLEN 160)
else(WIN32)
if(UNIX)
set(LLVM_ON_WIN32 0)
@@ -90,8 +96,6 @@ else(WIN32)
else(APPLE)
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
endif(APPLE)
- # FIXME: Maximum path length is currently set to 'safe' fixed value
- set(MAXPATHLEN 2024)
else(UNIX)
MESSAGE(SEND_ERROR "Unable to determine platform")
endif(UNIX)
@@ -108,6 +112,15 @@ if(APPLE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
endif()
+# Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
+# build might work on ELF but fail on MachO/COFF.
+if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR
+ ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") AND
+ NOT LLVM_USE_SANITIZER)
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
+endif()
+
+
function(append value)
foreach(variable ${ARGN})
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
@@ -399,12 +412,20 @@ if(LLVM_USE_SANITIZER)
elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
append_common_sanitizer_flags()
append("-fsanitize=thread" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ elseif (LLVM_USE_SANITIZER STREQUAL "Address;Undefined" OR
+ LLVM_USE_SANITIZER STREQUAL "Undefined;Address")
+ append_common_sanitizer_flags()
+ append("-fsanitize=address,undefined -fno-sanitize=vptr,function -fno-sanitize-recover"
+ CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
else()
message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
endif()
else()
message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.")
endif()
+ if (LLVM_USE_SANITIZE_COVERAGE)
+ append("-fsanitize-coverage=4" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ endif()
endif()
# Turn on -gsplit-dwarf if requested
diff --git a/cmake/modules/LLVM-Config.cmake b/cmake/modules/LLVM-Config.cmake
index e8c42fc..b24c129 100644
--- a/cmake/modules/LLVM-Config.cmake
+++ b/cmake/modules/LLVM-Config.cmake
@@ -152,29 +152,39 @@ function(llvm_map_components_to_libnames out_libs)
set(${out_libs} ${expanded_components} PARENT_SCOPE)
endfunction()
+# Perform a post-order traversal of the dependency graph.
+# This duplicates the algorithm used by llvm-config, originally
+# in tools/llvm-config/llvm-config.cpp, function ComputeLibsForComponents.
+function(expand_topologically name required_libs visited_libs)
+ list(FIND visited_libs ${name} found)
+ if( found LESS 0 )
+ list(APPEND visited_libs ${name})
+ set(visited_libs ${visited_libs} PARENT_SCOPE)
+
+ get_property(lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${name})
+ foreach( lib_dep ${lib_deps} )
+ expand_topologically(${lib_dep} "${required_libs}" "${visited_libs}")
+ set(required_libs ${required_libs} PARENT_SCOPE)
+ set(visited_libs ${visited_libs} PARENT_SCOPE)
+ endforeach()
+
+ list(APPEND required_libs ${name})
+ set(required_libs ${required_libs} PARENT_SCOPE)
+ endif()
+endfunction()
+
# Expand dependencies while topologically sorting the list of libraries:
function(llvm_expand_dependencies out_libs)
set(expanded_components ${ARGN})
- list(LENGTH expanded_components lst_size)
- set(cursor 0)
- set(processed)
- while( cursor LESS lst_size )
- list(GET expanded_components ${cursor} 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)
- list(REMOVE_DUPLICATES expanded_components)
- list(REVERSE expanded_components)
- list(APPEND processed ${lib})
- # Find the maximum index that doesn't have to be re-processed:
- while(NOT "${expanded_components}" MATCHES "^${processed}.*" )
- list(REMOVE_AT processed -1)
- endwhile()
- list(LENGTH processed cursor)
- list(LENGTH expanded_components lst_size)
- endwhile( cursor LESS lst_size )
- set(${out_libs} ${expanded_components} PARENT_SCOPE)
+
+ set(required_libs)
+ set(visited_libs)
+ foreach( lib ${expanded_components} )
+ expand_topologically(${lib} "${required_libs}" "${visited_libs}")
+ endforeach()
+
+ list(REVERSE required_libs)
+ set(${out_libs} ${required_libs} PARENT_SCOPE)
endfunction()
function(explicit_map_components_to_libraries out_libs)
diff --git a/cmake/modules/LLVMConfig.cmake.in b/cmake/modules/LLVMConfig.cmake.in
index 780a608..9a9cd85 100644
--- a/cmake/modules/LLVMConfig.cmake.in
+++ b/cmake/modules/LLVMConfig.cmake.in
@@ -40,6 +40,8 @@ set(LLVM_ENABLE_PIC @LLVM_ENABLE_PIC@)
set(LLVM_ON_UNIX @LLVM_ON_UNIX@)
set(LLVM_ON_WIN32 @LLVM_ON_WIN32@)
+set(LLVM_LIBDIR_SUFFIX @LLVM_LIBDIR_SUFFIX@)
+
set(LLVM_INCLUDE_DIRS "@LLVM_CONFIG_INCLUDE_DIRS@")
set(LLVM_LIBRARY_DIRS "@LLVM_CONFIG_LIBRARY_DIRS@")
set(LLVM_DEFINITIONS "-D__STDC_LIMIT_MACROS" "-D__STDC_CONSTANT_MACROS")
diff --git a/cmake/modules/LLVMProcessSources.cmake b/cmake/modules/LLVMProcessSources.cmake
index 64ebce8..ae1921b 100644
--- a/cmake/modules/LLVMProcessSources.cmake
+++ b/cmake/modules/LLVMProcessSources.cmake
@@ -28,26 +28,39 @@ macro(add_td_sources srcs)
endif()
endmacro(add_td_sources)
+function(add_header_files_for_glob hdrs_out glob)
+ file(GLOB hds ${glob})
+ set(${hdrs_out} ${hds} PARENT_SCOPE)
+endfunction(add_header_files_for_glob)
-macro(add_header_files srcs)
- file(GLOB hds *.h)
- if( hds )
- set_source_files_properties(${hds} PROPERTIES HEADER_FILE_ONLY ON)
- list(APPEND ${srcs} ${hds})
- endif()
-endmacro(add_header_files)
+function(find_all_header_files hdrs_out additional_headerdirs)
+ add_header_files_for_glob(hds *.h)
+ list(APPEND all_headers ${hds})
+
+ foreach(additional_dir ${additional_headerdirs})
+ add_header_files_for_glob(hds "${additional_dir}/*.h")
+ list(APPEND all_headers ${hds})
+ add_header_files_for_glob(hds "${additional_dir}/*.inc")
+ list(APPEND all_headers ${hds})
+ endforeach(additional_dir)
+
+ set( ${hdrs_out} ${all_headers} PARENT_SCOPE )
+endfunction(find_all_header_files)
function(llvm_process_sources OUT_VAR)
- cmake_parse_arguments(ARG "" "" "ADDITIONAL_HEADERS" ${ARGN})
+ cmake_parse_arguments(ARG "" "" "ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" ${ARGN})
set(sources ${ARG_UNPARSED_ARGUMENTS})
llvm_check_source_file_list( ${sources} )
if( MSVC_IDE OR XCODE )
# This adds .td and .h files to the Visual Studio solution:
add_td_sources(sources)
- add_header_files(sources)
+ find_all_header_files(hdrs "${ARG_ADDITIONAL_HEADER_DIRS}")
+ if (hdrs)
+ set_source_files_properties(${hdrs} PROPERTIES HEADER_FILE_ONLY ON)
+ endif()
set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES HEADER_FILE_ONLY ON)
- list(APPEND sources ${ARG_ADDITIONAL_HEADERS})
+ list(APPEND sources ${ARG_ADDITIONAL_HEADERS} ${hdrs})
endif()
set( ${OUT_VAR} ${sources} PARENT_SCOPE )
diff --git a/cmake/modules/Makefile b/cmake/modules/Makefile
index dd31aa7..e38f5a6 100644
--- a/cmake/modules/Makefile
+++ b/cmake/modules/Makefile
@@ -48,7 +48,7 @@ endif
OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake
-$(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag)
+$(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in Makefile $(LLVMBuildCMakeFrag)
$(Echo) 'Generating LLVM CMake package config file'
$(Verb) ( \
cat $< | sed \
@@ -73,6 +73,7 @@ $(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag)
-e 's/@LLVM_ENABLE_PIC@/'"$(ENABLE_PIC)"'/' \
-e 's/@LLVM_ON_UNIX@/'"$(LLVM_ON_UNIX)"'/' \
-e 's/@LLVM_ON_WIN32@/'"$(LLVM_ON_WIN32)"'/' \
+ -e 's/@LLVM_LIBDIR_SUFFIX@//' \
-e 's/@LLVM_CONFIG_INCLUDE_DIRS@/'"$(subst /,\/,$(PROJ_includedir))"'/' \
-e 's/@LLVM_CONFIG_LIBRARY_DIRS@/'"$(subst /,\/,$(PROJ_libdir))"'/' \
-e 's/@LLVM_CONFIG_CMAKE_DIR@/'"$(subst /,\/,$(PROJ_cmake))"'/' \
diff --git a/cmake/platforms/iOS.cmake b/cmake/platforms/iOS.cmake
index 4973643..e18ca6b 100644
--- a/cmake/platforms/iOS.cmake
+++ b/cmake/platforms/iOS.cmake
@@ -18,8 +18,17 @@ IF(NOT DEFINED ENV{SDKROOT})
MESSAGE(FATAL_ERROR "SDKROOT env var must be set: " $ENV{SDKROOT})
ENDIF()
+IF(EXISTS $ENV{SDKROOT})
+ SET(SDKROOT $ENV{SDKROOT})
+ELSE()
+ execute_process(COMMAND xcodebuild -version -sdk $ENV{SDKROOT} Path
+ OUTPUT_VARIABLE SDKROOT
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ENDIF()
+
IF(NOT CMAKE_C_COMPILER)
- execute_process(COMMAND xcrun -sdk iphoneos -find clang
+ execute_process(COMMAND xcrun -sdk $ENV{SDKROOT} -find clang
OUTPUT_VARIABLE CMAKE_C_COMPILER
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
@@ -27,21 +36,30 @@ IF(NOT CMAKE_C_COMPILER)
ENDIF()
IF(NOT CMAKE_CXX_COMPILER)
- execute_process(COMMAND xcrun -sdk iphoneos -find clang++
+ execute_process(COMMAND xcrun -sdk $ENV{SDKROOT} -find clang++
OUTPUT_VARIABLE CMAKE_CXX_COMPILER
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using c compiler ${CMAKE_CXX_COMPILER}")
ENDIF()
+IF(NOT CMAKE_AR)
+ execute_process(COMMAND xcrun -sdk $ENV{SDKROOT} -find ar
+ OUTPUT_VARIABLE CMAKE_AR_val
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ SET(CMAKE_AR ${CMAKE_AR_val} CACHE FILEPATH "Archiver")
+ message(STATUS "Using ar ${CMAKE_AR}")
+ENDIF()
+
IF (NOT DEFINED IOS_MIN_TARGET)
-execute_process(COMMAND xcodebuild -sdk iphoneos -version SDKVersion
+execute_process(COMMAND xcodebuild -sdk $ENV{SDKROOT} -version SDKVersion
OUTPUT_VARIABLE IOS_MIN_TARGET
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF()
-SET(IOS_COMMON_FLAGS "-isysroot $ENV{SDKROOT} -mios-version-min=${IOS_MIN_TARGET}")
+SET(IOS_COMMON_FLAGS "-mios-version-min=${IOS_MIN_TARGET}")
SET(CMAKE_C_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_cflags" FORCE)
SET(CMAKE_CXX_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_cxxflags" FORCE)
SET(CMAKE_LINK_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_linkflags" FORCE)