endfunction(add_link_opts)
# Set each output directory according to ${CMAKE_CONFIGURATION_TYPES}.
-# Note: Don't set variables CMAKE_*_OUTPUT_DIRECTORY any more,
-# or a certain builder, for eaxample, msbuild.exe, would be confused.
function(set_output_directory target)
cmake_parse_arguments(ARG "" "BINARY_DIR;LIBRARY_DIR" "" ${ARGN})
# it forces Xcode to properly link the static library.
list(APPEND ALL_FILES "${LLVM_MAIN_SRC_DIR}/cmake/dummy.cpp")
endif()
-
+
if( EXCLUDE_FROM_ALL )
add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES})
else()
# 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)
+function(configure_lit_site_cfg site_in site_out)
+ cmake_parse_arguments(ARG "" "" "MAIN_CONFIG;OUTPUT_MAPPING" ${ARGN})
+
+ if ("${ARG_MAIN_CONFIG}" STREQUAL "")
+ get_filename_component(INPUT_DIR ${site_in} DIRECTORY)
+ set(ARG_MAIN_CONFIG "${INPUT_DIR}/lit.cfg")
+ endif()
+ if ("${ARG_OUTPUT_MAPPING}" STREQUAL "")
+ set(ARG_OUTPUT_MAPPING "${site_out}")
+ endif()
+
foreach(c ${LLVM_TARGETS_TO_BUILD})
set(TARGETS_BUILT "${TARGETS_BUILT} ${c}")
endforeach(c)
# They below might not be the build tree but provided binary tree.
set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR})
set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR})
- string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_TOOLS_DIR ${LLVM_TOOLS_BINARY_DIR})
- string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_LIBS_DIR ${LLVM_LIBRARY_DIR})
+ string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}")
+ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_LIBS_DIR "${LLVM_LIBRARY_DIR}")
# SHLIBDIR points the build tree.
- string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}")
+ string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}")
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
# FIXME: "ENABLE_SHARED" doesn't make sense, since it is used just for
set(HOST_CXX "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}")
set(HOST_LDFLAGS "${CMAKE_EXE_LINKER_FLAGS}")
- set(LIT_SITE_CFG_IN_HEADER "## Autogenerated from ${input}\n## Do not edit!")
+ set(LIT_SITE_CFG_IN_HEADER "## Autogenerated from ${site_in}\n## Do not edit!")
# Override config_target_triple (and the env)
if(LLVM_TARGET_TRIPLE_ENV)
set(TARGET_TRIPLE "\"+config.target_triple+\"")
endif()
- configure_file(${input} ${output} @ONLY)
- get_filename_component(INPUT_DIR ${input} DIRECTORY)
- if (EXISTS "${INPUT_DIR}/lit.cfg")
- set(PYTHON_STATEMENT "map_config('${INPUT_DIR}/lit.cfg', '${output}')")
+ string(CONCAT LIT_SITE_CFG_IN_FOOTER
+ "import lit.llvm\n"
+ "lit.llvm.initialize(lit_config, config)\n")
+
+ configure_file(${site_in} ${site_out} @ONLY)
+ if (EXISTS "${ARG_MAIN_CONFIG}")
+ set(PYTHON_STATEMENT "map_config('${ARG_MAIN_CONFIG}', '${site_out}')")
get_property(LLVM_LIT_CONFIG_MAP GLOBAL PROPERTY LLVM_LIT_CONFIG_MAP)
set(LLVM_LIT_CONFIG_MAP "${LLVM_LIT_CONFIG_MAP}\n${PYTHON_STATEMENT}")
set_property(GLOBAL PROPERTY LLVM_LIT_CONFIG_MAP ${LLVM_LIT_CONFIG_MAP})
endif()
endfunction()
+function(dump_all_cmake_variables)
+ get_cmake_property(_variableNames VARIABLES)
+ foreach (_variableName ${_variableNames})
+ message(STATUS "${_variableName}=${${_variableName}}")
+ endforeach()
+endfunction()
+
+function(get_llvm_lit_path base_dir file_name)
+ cmake_parse_arguments(ARG "ALLOW_EXTERNAL" "" "" ${ARGN})
+
+ if (ARG_ALLOW_EXTERNAL)
+ set(LLVM_DEFAULT_EXTERNAL_LIT "${LLVM_EXTERNAL_LIT}")
+ set (LLVM_EXTERNAL_LIT "" CACHE STRING "Command used to spawn lit")
+ if ("${LLVM_EXTERNAL_LIT}" STREQUAL "")
+ set(LLVM_EXTERNAL_LIT "${LLVM_DEFAULT_EXTERNAL_LIT}")
+ endif()
+
+ if (NOT "${LLVM_EXTERNAL_LIT}" STREQUAL "")
+ if (EXISTS ${LLVM_EXTERNAL_LIT})
+ get_filename_component(LIT_FILE_NAME ${LLVM_EXTERNAL_LIT} NAME)
+ get_filename_component(LIT_BASE_DIR ${LLVM_EXTERNAL_LIT} DIRECTORY)
+ set(${file_name} ${LIT_FILE_NAME} PARENT_SCOPE)
+ set(${base_dir} ${LIT_BASE_DIR} PARENT_SCOPE)
+ return()
+ else()
+ message(WARN "LLVM_EXTERNAL_LIT set to ${LLVM_EXTERNAL_LIT}, but the path does not exist.")
+ endif()
+ endif()
+ endif()
+
+ set(lit_file_name "llvm-lit")
+ if (WIN32 AND NOT CYGWIN)
+ # llvm-lit needs suffix.py for multiprocess to find a main module.
+ set(lit_file_name "${lit_file_name}.py")
+ endif ()
+ set(${file_name} ${lit_file_name} PARENT_SCOPE)
+
+ get_property(LLVM_LIT_BASE_DIR GLOBAL PROPERTY LLVM_LIT_BASE_DIR)
+ if (NOT "${LLVM_LIT_BASE_DIR}" STREQUAL "")
+ set(${base_dir} ${LLVM_LIT_BASE_DIR} PARENT_SCOPE)
+ endif()
+
+ # Allow individual projects to provide an override
+ if (NOT "${LLVM_LIT_OUTPUT_DIR}" STREQUAL "")
+ set(LLVM_LIT_BASE_DIR ${LLVM_LIT_OUTPUT_DIR})
+ elseif(NOT "${LLVM_RUNTIME_OUTPUT_INTDIR}" STREQUAL "")
+ set(LLVM_LIT_BASE_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
+ else()
+ set(LLVM_LIT_BASE_DIR "")
+ endif()
+
+ # Cache this so we don't have to do it again and have subsequent calls
+ # potentially disagree on the value.
+ set_property(GLOBAL PROPERTY LLVM_LIT_BASE_DIR ${LLVM_LIT_BASE_DIR})
+ set(${base_dir} ${LLVM_LIT_BASE_DIR} PARENT_SCOPE)
+endfunction()
+
# A raw function to create a lit target. This is used to implement the testuite
# management functions.
function(add_lit_target target comment)
list(APPEND LIT_ARGS --param build_mode=${CMAKE_CFG_INTDIR})
endif ()
- set(suffix "")
- if (WIN32 AND NOT CYGWIN)
- # llvm-lit needs suffix.py for multiprocess to find a main module.
- set(suffix .py)
- endif ()
- set(llvm_lit_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-lit${suffix})
-
- set (LIT_COMMAND "${PYTHON_EXECUTABLE};${llvm_lit_path}"
- CACHE STRING "Command used to spawn llvm-lit" FORCE)
+ # Get the path to the lit to *run* tests with. This can be overriden by
+ # the user by specifying -DLLVM_EXTERNAL_LIT=<path-to-lit.py>
+ get_llvm_lit_path(
+ lit_base_dir
+ lit_file_name
+ ALLOW_EXTERNAL
+ )
+ set(LIT_COMMAND "${PYTHON_EXECUTABLE};${lit_base_dir}/${lit_file_name}")
list(APPEND LIT_COMMAND ${LIT_ARGS})
foreach(param ${ARG_PARAMS})
list(APPEND LIT_COMMAND --param ${param})
# magic. First we grab one of the types, and a type-specific path. Then from
# the type-specific path we find the last occurrence of the type in the path,
# and replace it with CMAKE_CFG_INTDIR. This allows the build step to be type
- # agnostic again.
+ # agnostic again.
if(NOT ARG_OUTPUT_DIR)
# If you're not overriding the OUTPUT_DIR, we can make the link relative in
# the same directory.