Skip to content

Commit 1b89100

Browse files
committed
[cmake] Revert the change in subdir adds
We need to add the test directories after lib/include/tools so that the test cmake files can access target [properties] of the code which they are testing.
1 parent 5e7f0d2 commit 1b89100

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ set(CIRCT_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
187187
"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
188188

189189
option(CIRCT_INCLUDE_TESTS
190-
"Generate build targets for the CIRCT unit tests." ON)
190+
"Generate build targets for the CIRCT tests." ON)
191191

192192
list(APPEND CMAKE_MODULE_PATH "${MLIR_MAIN_SRC_DIR}/cmake/modules")
193193
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
@@ -623,19 +623,25 @@ endif()
623623

624624
if (CIRCT_INCLUDE_TESTS)
625625
add_definitions(-DCIRCT_INCLUDE_TESTS)
626-
if (CIRCT_GTEST_AVAILABLE)
627-
add_subdirectory(unittests)
628-
endif()
629-
add_subdirectory(test)
630-
add_subdirectory(integration_test)
631626
endif()
627+
632628
add_subdirectory(include/circt)
633629
add_subdirectory(lib)
634630
if(CIRCT_INCLUDE_TOOLS)
635631
add_subdirectory(tools)
636632
endif()
637633
add_subdirectory(frontends)
638634

635+
if (CIRCT_INCLUDE_TESTS)
636+
# Test directories are added after everything else so their cmake files can
637+
# use targets and target properties defined by the things they test.
638+
if (CIRCT_GTEST_AVAILABLE)
639+
add_subdirectory(unittests)
640+
endif()
641+
add_subdirectory(test)
642+
add_subdirectory(integration_test)
643+
endif()
644+
639645
option(CIRCT_INCLUDE_DOCS "Generate build targets for the CIRCT docs.")
640646
if (CIRCT_INCLUDE_DOCS)
641647
add_subdirectory(docs)

0 commit comments

Comments
 (0)