summaryrefslogtreecommitdiff
path: root/cmake/modules/AddLLVM.cmake
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-06-28 06:36:24 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-06-28 06:36:24 +0000
commitc502ed657a74fbbc910c07922ed4ed7e531002a2 (patch)
treed014077a87e9b82745041a1b959ca573c0b41238 /cmake/modules/AddLLVM.cmake
parent282969ed3641ffa426e0440d3824dd219152b2d8 (diff)
downloadllvm-c502ed657a74fbbc910c07922ed4ed7e531002a2.tar.gz
llvm-c502ed657a74fbbc910c07922ed4ed7e531002a2.tar.bz2
llvm-c502ed657a74fbbc910c07922ed4ed7e531002a2.tar.xz
Move the setup for variables that are expanded in the lit.site.cfg into
a dedicated helper function. This will enable re-using the same logic for Clang's lit setup, etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159333 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/modules/AddLLVM.cmake')
-rwxr-xr-xcmake/modules/AddLLVM.cmake51
1 files changed, 51 insertions, 0 deletions
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 0236746b28..40ff5eda5d 100755
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -197,3 +197,54 @@ function(add_unittest test_suite test_name)
endif ()
set_property(TARGET ${test_name} PROPERTY COMPILE_FLAGS "${target_compile_flags}")
endfunction()
+
+# This function provides an automatic way to 'configure'-like generate a file
+# based on a set of common and custom variables, specifically targetting the
+# variables needed for the 'lit.site.cfg' files. This function bundles the
+# common variables that any Lit instance is likely to need, and custom
+# variables can be passed in.
+function(configure_lit_site_cfg input output)
+ foreach(c ${LLVM_TARGETS_TO_BUILD})
+ set(TARGETS_BUILT "${TARGETS_BUILT} ${c}")
+ endforeach(c)
+ set(TARGETS_TO_BUILD ${TARGETS_BUILT})
+
+ set(SHLIBEXT "${LTDL_SHLIB_EXT}")
+ set(SHLIBDIR "${LLVM_BINARY_DIR}/lib/${CMAKE_CFG_INTDIR}")
+
+ if(BUILD_SHARED_LIBS)
+ set(LLVM_SHARED_LIBS_ENABLED "1")
+ else()
+ set(LLVM_SHARED_LIBS_ENABLED "0")
+ endif(BUILD_SHARED_LIBS)
+
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ set(SHLIBPATH_VAR "DYLD_LIBRARY_PATH")
+ else() # Default for all other unix like systems.
+ # CMake hardcodes the library locaction using rpath.
+ # Therefore LD_LIBRARY_PATH is not required to run binaries in the
+ # build dir. We pass it anyways.
+ set(SHLIBPATH_VAR "LD_LIBRARY_PATH")
+ endif()
+
+ # Configuration-time: See Unit/lit.site.cfg.in
+ set(LLVM_BUILD_MODE "%(build_mode)s")
+
+ set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR})
+ set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR})
+ set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
+ set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
+ set(ENABLE_SHARED ${LLVM_SHARED_LIBS_ENABLED})
+ set(SHLIBPATH_VAR ${SHLIBPATH_VAR})
+
+ if(LLVM_ENABLE_ASSERTIONS AND NOT MSVC_IDE)
+ set(ENABLE_ASSERTIONS "1")
+ else()
+ set(ENABLE_ASSERTIONS "0")
+ endif()
+
+ set(HOST_OS ${CMAKE_HOST_SYSTEM_NAME})
+ set(HOST_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})
+
+ configure_file(${input} ${output} @ONLY)
+endfunction()