From 370467150873ce8616a859edf9a510fd28fffbe5 Mon Sep 17 00:00:00 2001 From: Bruno Coelho <4brunu@gmail.com> Date: Tue, 5 Jul 2016 15:37:44 +0100 Subject: [PATCH] Add option to disable unit tests --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 350b4ba..ae8c412 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ project(json11 VERSION 1.0.0 LANGUAGES CXX) enable_testing() +option(JSON11_BUILD_TESTS "Build unit tests" ON) + add_library(json11 json11.cpp) target_include_directories(json11 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_options(json11 @@ -10,8 +12,10 @@ target_compile_options(json11 PRIVATE -fno-rtti -fno-exceptions -Wall -Wextra -Werror) configure_file("json11.pc.in" "json11.pc" @ONLY) -add_executable(json11_test test.cpp) -target_link_libraries(json11_test json11) +if (JSON11_BUILD_TESTS) + add_executable(json11_test test.cpp) + target_link_libraries(json11_test json11) +endif() install(TARGETS json11 DESTINATION lib) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/json11.hpp" DESTINATION include)