Skip to content

Commit c81d449

Browse files
authored
[LLVM][CMake] Build examples for llvm-test-depends
Build examples and example plug-ins by default when running tests. If examples are unwanted, they can still be disabled completely using LLVM_INCLUDE_EXAMPLES=OFF. Plugin tests depend on examples and it is beneficial to test them by default. By default, Examples will still not be included in the default target or be installed, this remains controlled by LLVM_BUILD_EXAMPLES (which defaults to OFF). The additional cost for building examples for tests is 17 compilation units (12 C++, 5 C), which should be tolerable. I don't know how broken the examples currently are in the various build configurations, but if we find breakage, it would be good to fix it. Pull Request: #171998
1 parent e7c652b commit c81d449

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

llvm/docs/CMake.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,10 @@ its enabled sub-projects. Nearly all of these variable names begin with
366366
``LLVM_ENABLE_SPHINX`` and ``LLVM_ENABLE_DOXYGEN``.
367367

368368
**LLVM_BUILD_EXAMPLES**:BOOL
369-
Build LLVM examples. Defaults to OFF. Targets for building each example are
370-
generated in any case. See documentation for *LLVM_BUILD_TOOLS* above for more
371-
details.
369+
Include LLVM examples in the 'all' build target and install them as part of
370+
the ``install`` target. Defaults to OFF. Targets for building examples are
371+
still generated, this is controlled by *LLVM_INCLUDE_EXAMPLES*. Note that some
372+
examples might still be built as dependencies for tests.
372373

373374
**LLVM_BUILD_INSTRUMENTED_COVERAGE**:BOOL
374375
If enabled, `source-based code coverage

llvm/test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ llvm_canonicalize_cmake_booleans(
1313
LLVM_LINK_LLVM_DYLIB
1414
LLVM_TOOL_LTO_BUILD
1515
LLVM_USE_INTEL_JITEVENTS
16-
LLVM_BUILD_EXAMPLES
16+
LLVM_INCLUDE_EXAMPLES
1717
LLVM_ENABLE_PLUGINS
1818
LLVM_BYE_LINK_INTO_TOOLS
1919
LLVM_EXAMPLEIRTRANSFORMS_LINK_INTO_TOOLS
@@ -186,7 +186,7 @@ if (TARGET llvm-mt)
186186
list(APPEND LLVM_TEST_DEPENDS llvm-mt)
187187
endif ()
188188

189-
if(LLVM_BUILD_EXAMPLES)
189+
if(LLVM_INCLUDE_EXAMPLES)
190190
list(APPEND LLVM_TEST_DEPENDS
191191
Kaleidoscope-Ch3
192192
Kaleidoscope-Ch4

llvm/test/Examples/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if not config.build_examples or sys.platform in ["win32"]:
1+
if not config.include_examples or sys.platform in ["win32"]:
22
config.unsupported = True
33

44
# Test discovery should ignore subdirectories that contain test inputs.

llvm/test/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ def enable_ptxas(ptxas_executable):
511511
if config.has_plugins:
512512
config.available_features.add("plugins")
513513

514-
if config.build_examples:
514+
if config.include_examples:
515515
config.available_features.add("examples")
516516

517517
if config.linked_bye_extension:

llvm/test/lit.site.cfg.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ config.have_curl = @LLVM_ENABLE_CURL@
4040
config.have_httplib = @LLVM_ENABLE_HTTPLIB@
4141
config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
4242
config.enable_ffi = @LLVM_ENABLE_FFI@
43-
config.build_examples = @LLVM_BUILD_EXAMPLES@
43+
config.include_examples = @LLVM_INCLUDE_EXAMPLES@
4444
config.enable_backtrace = @ENABLE_BACKTRACES@
4545
config.enable_threads = @LLVM_ENABLE_THREADS@
4646
config.build_shared_libs = @BUILD_SHARED_LIBS@

0 commit comments

Comments
 (0)