From 8a0aed1125fabaafb2f301aff1c80852662ff200 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Thu, 19 Dec 2024 17:15:42 +0100 Subject: [PATCH] Only tests need Protobuf library This is a relacement for the PR #110 by @ffontaine which has conflicts. --- CMakeLists.txt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd51940b..4722a1b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,16 +52,17 @@ endif() # #----------------------------------------------------------------------------- -# This is needed for the protobuf_generate_cpp() function to work on newer -# versions of the Protobuf CMake config. -set(protobuf_MODULE_COMPATIBLE ON CACHE BOOL "") - -# This is needed so that we pick up the (more modern) CONFIG mode cmake file -# before the (older) MODULE mode cmake config file. Seems to be needed on macOS. -set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) +if(BUILD_TESTING) + # This is needed for the protobuf_generate_cpp() function to work on newer + # versions of the Protobuf CMake config. + set(protobuf_MODULE_COMPATIBLE ON CACHE BOOL "") -find_package(Protobuf) + # This is needed so that we pick up the (more modern) CONFIG mode cmake file + # before the (older) MODULE mode cmake config file. Seems to be needed on macOS. + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) + find_package(Protobuf) +endif() #----------------------------------------------------------------------------- #