Skip to content

Commit 8b47786

Browse files
committed
cmake: Only install and test when top level project
Signed-off-by: Diogo Behrens <[email protected]>
1 parent c332564 commit 8b47786

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

CMakeLists.txt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@ project(
1010

1111
include(GNUInstallDirs)
1212
include(CheckSymbolExists)
13-
include(cmake/export.cmake)
1413

1514
# Create vatomic header library
1615
add_library(vatomic INTERFACE)
1716
target_include_directories(
1817
vatomic INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
1918
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
2019

20+
# Enable testing and other targes only if this is the top level project
21+
if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
22+
return()
23+
endif()
24+
2125
# Prepare install targets
26+
include(cmake/export.cmake)
2227
install(DIRECTORY include/vsync DESTINATION include)
2328
install(FILES vmm.cat DESTINATION share/vsync/)
2429
install(TARGETS vatomic EXPORT ${PROJECT_TARGETS})
@@ -52,12 +57,10 @@ add_dependencies(clang-format-apply sanitize-vatomic)
5257
# General diff check for pipeline
5358
add_custom_target(diff-check COMMAND git --no-pager diff --exit-code)
5459

55-
# Enable testing and verification only if this is the top level project
56-
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
57-
include(CTest)
58-
include(ProcessorCount)
59-
include(cmake/v_add_test.cmake)
60-
enable_testing()
61-
add_subdirectory(test)
62-
add_subdirectory(verify)
63-
endif()
60+
# Configure testing
61+
include(CTest)
62+
include(ProcessorCount)
63+
include(cmake/v_add_test.cmake)
64+
enable_testing()
65+
add_subdirectory(test)
66+
add_subdirectory(verify)

0 commit comments

Comments
 (0)