summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAlan Antonuk <alan.antonuk@gmail.com>2021-04-01 06:17:21 +0000
committerAlan Antonuk <alan.antonuk@gmail.com>2021-03-31 23:26:41 -0700
commit79edd8348052c0d14c2f4a2554d429572353612e (patch)
treea91709613f148e35b6fccfa8bb148b48dacc3d65 /CMakeLists.txt
parente2ee767868531e837391c91caf0fefe2a4f3a993 (diff)
downloadrabbitmq-c-79edd8348052c0d14c2f4a2554d429572353612e.tar.gz
cmake: modernize how tests are enabled
Note this changes the build option from BUILD_TESTS to BUILD_TESTING. Signed-off-by: GitHub <noreply@github.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt9
1 files changed, 5 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bae759d..a9a29fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -239,6 +239,9 @@ if (POPT_FOUND AND XmlTo_FOUND)
set(DO_DOCS ON)
endif()
+if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
+ include(CTest)
+endif()
option(BUILD_SHARED_LIBS "Build rabbitmq-c as a shared library" ON)
option(BUILD_STATIC_LIBS "Build rabbitmq-c as a static library" ON)
@@ -246,7 +249,6 @@ option(BUILD_STATIC_LIBS "Build rabbitmq-c as a static library" ON)
option(BUILD_EXAMPLES "Build Examples" ON)
option(BUILD_TOOLS "Build Tools (requires POPT Library)" ${POPT_FOUND})
option(BUILD_TOOLS_DOCS "Build man pages for Tools (requires xmlto)" ${DO_DOCS})
-option(BUILD_TESTS "Build tests (run tests with make test)" ON)
option(BUILD_API_DOCS "Build Doxygen API docs" ${DOXYGEN_FOUND})
option(RUN_SYSTEM_TESTS "Run system tests (i.e. tests requiring an accessible RabbitMQ server instance on localhost)" OFF)
@@ -270,15 +272,14 @@ if (BUILD_TOOLS)
endif ()
endif ()
-if (BUILD_TESTS)
+if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
if (NOT BUILD_STATIC_LIBS)
message(FATAL_ERROR
"Tests can only be built against static libraries "
"(set BUILD_STATIC_LIBS=ON)")
endif ()
- enable_testing()
add_subdirectory(tests)
-endif (BUILD_TESTS)
+endif ()
if (BUILD_API_DOCS)
if (NOT DOXYGEN_FOUND)