option to disable tests when subproject (#195)

This commit is contained in:
Nagy-Egri Máté Ferenc 2022-02-08 07:13:21 +01:00 committed by GitHub
parent 80c10b1f65
commit dcd5bede68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,8 @@ project(OpenCLHeaders
# https://stackoverflow.com/questions/43379311/why-does-project-affect-cmakes-opinion-on-cmake-sizeof-void-p
)
option(OPENCL_HEADERS_BUILD_TESTING "Enable support for OpenCL C headers testing." OFF)
include(GNUInstallDirs)
add_library(Headers INTERFACE)
@ -83,7 +85,9 @@ install(
DESTINATION ${config_package_location}
)
if(BUILD_TESTING)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_HEADERS_BUILD_TESTING)
include(CTest)
endif()
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_HEADERS_BUILD_TESTING) AND BUILD_TESTING)
add_subdirectory(tests)
endif()