diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index 036ee05cfb3..cb6e7e75c0f 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -1,14 +1,21 @@ set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/share/llvm/cmake") +set(LLVM_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS) configure_file( - LLVM.cmake - ${llvm_cmake_builddir}/LLVM.cmake + LLVMConfig.cmake.in + ${llvm_cmake_builddir}/LLVMConfig.cmake + @ONLY) + +configure_file( + LLVMConfigVersion.cmake.in + ${llvm_cmake_builddir}/LLVMConfigVersion.cmake @ONLY) install(FILES - ${llvm_cmake_builddir}/LLVM.cmake + ${llvm_cmake_builddir}/LLVMConfig.cmake + ${llvm_cmake_builddir}/LLVMConfigVersion.cmake LLVM-Config.cmake LLVMLibDeps.cmake DESTINATION share/llvm/cmake) @@ -17,7 +24,8 @@ install(DIRECTORY . DESTINATION share/llvm/cmake FILES_MATCHING PATTERN *.cmake PATTERN .svn EXCLUDE - PATTERN LLVM.cmake EXCLUDE + PATTERN LLVMConfig.cmake EXCLUDE + PATTERN LLVMConfigVersion.cmake EXCLUDE PATTERN LLVM-Config.cmake EXCLUDE PATTERN LLVMLibDeps.cmake EXCLUDE PATTERN FindBison.cmake EXCLUDE @@ -25,8 +33,10 @@ install(DIRECTORY . PATTERN VersionFromVCS.cmake EXCLUDE PATTERN CheckAtomic.cmake EXCLUDE) +#remove this? install(FILES - ${llvm_cmake_builddir}/LLVM.cmake + ${llvm_cmake_builddir}/LLVMConfig.cmake + ${llvm_cmake_builddir}/LLVMConfigVersion.cmake LLVM-Config.cmake LLVMLibDeps.cmake DESTINATION share/llvm/cmake) diff --git a/cmake/modules/LLVM.cmake b/cmake/modules/LLVMConfig.cmake.in similarity index 79% rename from cmake/modules/LLVM.cmake rename to cmake/modules/LLVMConfig.cmake.in index 04abb9d2c2b..0d2f97c1c03 100644 --- a/cmake/modules/LLVM.cmake +++ b/cmake/modules/LLVMConfig.cmake.in @@ -1,6 +1,6 @@ # This file provides information and services to the final user. -set(LLVM_PACKAGE_VERSION @PACKAGE_VERSION@) +set(LLVM_PACKAGE_VERSION @PACKAGE_VERSION@) #remove this? set(LLVM_COMMON_DEPENDS @LLVM_COMMON_DEPENDS@) @@ -25,6 +25,11 @@ set(HAVE_LIBPTHREAD @HAVE_LIBPTHREAD@) set(LLVM_ON_UNIX @LLVM_ON_UNIX@) set(LLVM_ON_WIN32 @LLVM_ON_WIN32@) +set(LLVM_INSTALL_PREFIX @LLVM_INSTALL_PREFIX@) +set(LLVM_INCLUDE_DIRS ${LLVM_INSTALL_PREFIX}/include) +set(LLVM_LIBRARY_DIRS ${LLVM_INSTALL_PREFIX}/lib) +set(LLVM_DEFINITIONS "-D__STDC_LIMIT_MACROS" "-D__STDC_CONSTANT_MACROS") + # We try to include using the current setting of CMAKE_MODULE_PATH, # which suppossedly was filled by the user with the directory where # this file was installed: diff --git a/cmake/modules/LLVMConfigVersion.cmake.in b/cmake/modules/LLVMConfigVersion.cmake.in new file mode 100644 index 00000000000..add5aa9a1cb --- /dev/null +++ b/cmake/modules/LLVMConfigVersion.cmake.in @@ -0,0 +1 @@ +set(PACKAGE_VERSION "@PACKAGE_VERSION@") \ No newline at end of file diff --git a/docs/CMake.html b/docs/CMake.html index fcf2972a728..6778d6b7315 100644 --- a/docs/CMake.html +++ b/docs/CMake.html @@ -436,6 +436,26 @@ headers on the LLVM source directory (if we are building out-of-source.)

+

Alternativaly, you can utilize CMake's find_package + functionality. Here is an equivalent variant of snippet shown above:

+ +
+
+    find_package(LLVM)
+
+    if( NOT LLVM_FOUND )
+      message(FATAL_ERROR "LLVM package can't be found. Set CMAKE_PREFIX_PATH variable to LLVM's installation prefix.")
+    endif()
+
+    include_directories( ${LLVM_INCLUDE_DIRS} )
+    link_directories( ${LLVM_LIBRARY_DIRS} )
+
+    llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES jit native)
+
+    target_link_libraries(mycompiler ${REQ_LLVM_LIBRARIES})
+    
+
+