aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordamageboy <125730+damageboy@users.noreply.github.com>2023-05-04 09:54:03 +0300
committerGitHub <noreply@github.com>2023-05-04 08:54:03 +0200
commit41e206e435b3c84a6fdd937dfe2a07e8ee73e611 (patch)
treebaebbe2cbdf04e06dc81490aef7e59db27843774
parent936b9ab5515dead115606559502e3864958f7f6e (diff)
downloadcpu_features-41e206e435b3c84a6fdd937dfe2a07e8ee73e611.tar.gz
cmake: make default test building dependent on being a main project build vs. being included into other projects (#290)
-rw-r--r--CMakeLists.txt8
1 files changed, 8 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bcc9bb0..0967200 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,14 @@ project(CpuFeatures VERSION 0.8.0 LANGUAGES C)
set(CMAKE_C_STANDARD 99)
+# when cpu_features is included as subproject (i.e. using add_subdirectory(cpu_features))
+# in the source tree of a project that uses it, test rules are disabled.
+if(NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
+ option(BUILD_TESTING "Enable test rule" OFF)
+else()
+ option(BUILD_TESTING "Enable test rule" ON)
+endif()
+
# Default Build Type to be Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING