[llvm-commits] [llvm] r129247 - in /llvm/trunk: cmake/modules/CMakeLists.txt cmake/modules/LLVM.cmake cmake/modules/LLVMConfig.cmake.in cmake/modules/LLVMConfigVersion.cmake.in docs/CMake.html
Oscar Fuentes
ofv at wanadoo.es
Sun Apr 10 09:17:49 PDT 2011
Author: ofv
Date: Sun Apr 10 11:17:49 2011
New Revision: 129247
URL: http://llvm.org/viewvc/llvm-project?rev=129247&view=rev
Log:
CMake: support for using LLVM from client projects with find_package.
Patch by arrowdodger!
Added:
llvm/trunk/cmake/modules/LLVMConfig.cmake.in
- copied, changed from r129237, llvm/trunk/cmake/modules/LLVM.cmake
llvm/trunk/cmake/modules/LLVMConfigVersion.cmake.in
Removed:
llvm/trunk/cmake/modules/LLVM.cmake
Modified:
llvm/trunk/cmake/modules/CMakeLists.txt
llvm/trunk/docs/CMake.html
Modified: llvm/trunk/cmake/modules/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/CMakeLists.txt?rev=129247&r1=129246&r2=129247&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/CMakeLists.txt (original)
+++ llvm/trunk/cmake/modules/CMakeLists.txt Sun Apr 10 11:17:49 2011
@@ -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 @@
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 @@
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)
Removed: llvm/trunk/cmake/modules/LLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVM.cmake?rev=129246&view=auto
==============================================================================
--- llvm/trunk/cmake/modules/LLVM.cmake (original)
+++ llvm/trunk/cmake/modules/LLVM.cmake (removed)
@@ -1,40 +0,0 @@
-# This file provides information and services to the final user.
-
-set(LLVM_PACKAGE_VERSION @PACKAGE_VERSION@)
-
-set(LLVM_COMMON_DEPENDS @LLVM_COMMON_DEPENDS@)
-
-set_property( GLOBAL PROPERTY LLVM_LIBS "@llvm_libs@")
-
-set(LLVM_ALL_TARGETS @LLVM_ALL_TARGETS@)
-
-set(LLVM_TARGETS_TO_BUILD @LLVM_TARGETS_TO_BUILD@)
-
-set(TARGET_TRIPLE "@TARGET_TRIPLE@")
-
-set(LLVM_TOOLS_BINARY_DIR @LLVM_TOOLS_BINARY_DIR@)
-
-set(LLVM_ENABLE_THREADS @LLVM_ENABLE_THREADS@)
-
-set(LLVM_NATIVE_ARCH @LLVM_NATIVE_ARCH@)
-
-set(LLVM_ENABLE_PIC @LLVM_ENABLE_PIC@)
-
-set(HAVE_LIBDL @HAVE_LIBDL@)
-set(HAVE_LIBPTHREAD @HAVE_LIBPTHREAD@)
-set(LLVM_ON_UNIX @LLVM_ON_UNIX@)
-set(LLVM_ON_WIN32 @LLVM_ON_WIN32@)
-
-# 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:
-include( LLVM-Config OPTIONAL RESULT_VARIABLE LLVMCONFIG_INCLUDED )
-
-# If failed, we assume that this is an un-installed build:
-if( NOT LLVMCONFIG_INCLUDED )
- set(CMAKE_MODULE_PATH
- ${CMAKE_MODULE_PATH}
- "@LLVM_SOURCE_DIR@/cmake/modules")
- include( LLVM-Config )
-endif()
-
Copied: llvm/trunk/cmake/modules/LLVMConfig.cmake.in (from r129237, llvm/trunk/cmake/modules/LLVM.cmake)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMConfig.cmake.in?p2=llvm/trunk/cmake/modules/LLVMConfig.cmake.in&p1=llvm/trunk/cmake/modules/LLVM.cmake&r1=129237&r2=129247&rev=129247&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/LLVM.cmake (original)
+++ llvm/trunk/cmake/modules/LLVMConfig.cmake.in Sun Apr 10 11:17:49 2011
@@ -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(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:
Added: llvm/trunk/cmake/modules/LLVMConfigVersion.cmake.in
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMConfigVersion.cmake.in?rev=129247&view=auto
==============================================================================
--- llvm/trunk/cmake/modules/LLVMConfigVersion.cmake.in (added)
+++ llvm/trunk/cmake/modules/LLVMConfigVersion.cmake.in Sun Apr 10 11:17:49 2011
@@ -0,0 +1 @@
+set(PACKAGE_VERSION "@PACKAGE_VERSION@")
\ No newline at end of file
Modified: llvm/trunk/docs/CMake.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CMake.html?rev=129247&r1=129246&r2=129247&view=diff
==============================================================================
--- llvm/trunk/docs/CMake.html (original)
+++ llvm/trunk/docs/CMake.html Sun Apr 10 11:17:49 2011
@@ -436,6 +436,26 @@
headers on the LLVM source directory (if we are building
out-of-source.)</p>
+ <p>Alternativaly, you can utilize CMake's <i>find_package</i>
+ functionality. Here is an equivalent variant of snippet shown above:</p>
+
+ <div class="doc_code">
+ <pre>
+ 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})
+ </pre>
+ </div>
+
</div>
<!-- *********************************************************************** -->
More information about the llvm-commits
mailing list