[Workflow] Try to fix code-formatter failing to find changes in some cases.
[llvm-project.git] / lldb / utils / lldb-dotest / CMakeLists.txt
blob09f41dbce421ecb9fc8964a090cc222ac9f71ec1
1 # Make lldb-dotest a custom target.
2 add_custom_target(lldb-dotest)
3 add_dependencies(lldb-dotest lldb-test-depends)
4 set_target_properties(lldb-dotest PROPERTIES FOLDER "lldb utils")
6 get_property(LLDB_TEST_USER_ARGS GLOBAL PROPERTY LLDB_TEST_USER_ARGS_PROPERTY)
7 get_property(LLDB_TEST_COMMON_ARGS GLOBAL PROPERTY LLDB_TEST_COMMON_ARGS_PROPERTY)
8 set(LLDB_LIBS_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
10 llvm_canonicalize_cmake_booleans(
11   LLDB_BUILD_INTEL_PT
12   LLDB_HAS_LIBCXX
15 if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
16   set(LLDB_HAS_LIBCXX ON)
17   if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
18     set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
19     set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
20     set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
21   else()
22     set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
23     set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
24   endif()
25 endif()
27 set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}")
28 set(vars
29   LLDB_TEST_COMMON_ARGS
30   LLDB_TEST_USER_ARGS
31   LLDB_SOURCE_DIR
32   LLDB_FRAMEWORK_DIR
33   LLDB_TEST_BUILD_DIRECTORY
34   LLDB_TEST_EXECUTABLE
35   LLDB_TEST_COMPILER
36   LLDB_TEST_DSYMUTIL
37   LLDB_LIBS_DIR
38   LLVM_TOOLS_DIR
39   LIBCXX_LIBRARY_DIR
40   LIBCXX_GENERATED_INCLUDE_DIR
41   LIBCXX_GENERATED_INCLUDE_TARGET_DIR
42   )
44 llvm_canonicalize_cmake_booleans(LLDB_HAS_LIBCXX)
46 # Generate lldb-dotest Python driver script for each build mode.
47 if(LLDB_BUILT_STANDALONE)
48   set(config_types ".")
49   if(CMAKE_CONFIGURATION_TYPES)
50     set(config_types ${CMAKE_CONFIGURATION_TYPES})
51   endif()
52   foreach(config_type ${config_types})
53     # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our actual configuration names.
54     string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR})
55     foreach(var ${vars})
56       string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} "${var}_CONFIGURED" "${${var}}")
57     endforeach()
59     # Remaining ones must be paths to the provided LLVM build-tree.
60     if(${config_type} IN_LIST LLVM_CONFIGURATION_TYPES)
61       # Multi-configuration generator like Xcode (with a matching config).
62       foreach(var ${vars})
63         string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} "${var}_CONFIGURED" "${${var}}")
64       endforeach()
65     else()
66       # Single-configuration generator like Ninja.
67       foreach(var ${vars})
68         string(REPLACE ${CMAKE_CFG_INTDIR} "." "${var}_CONFIGURED" "${${var}}")
69       endforeach()
70     endif()
72     configure_file(
73       lldb-dotest.in
74       ${config_runtime_output_dir}/lldb-dotest @ONLY
75     )
76   endforeach()
77 elseif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
78   foreach(LLVM_BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
79     string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
80     foreach(var ${vars})
81       string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} "${var}_CONFIGURED" "${${var}}")
82     endforeach()
84     configure_file(
85       lldb-dotest.in
86       ${LLDB_DOTEST_DIR}/lldb-dotest
87       )
88   endforeach()
89 else()
90   foreach(var ${vars})
91     set("${var}_CONFIGURED" "${${var}}")
92   endforeach()
94   configure_file(
95     lldb-dotest.in
96     ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-dotest
97     )
98 endif()