From cbc0a2ac9a95cad33dd20519483f64cec90c877b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Or=C5=A1uli=C4=87?= Date: Fri, 8 Mar 2019 11:43:07 +0100 Subject: [PATCH] Do not use native CMake config for Protobuf on Linux (#1529) On Ubuntu 16.04, we have to install Protobuf 3. Unfortunately, `find_package()`ing Protobuf using native installed CMake `CONFIG` is problematic in case if there is a system Protobuf 2 installed, while the bundled CMake module works correctly and manages to avoid interference with system-installed Protobuf 2. --- CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3975f5f..de3645d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,10 +39,11 @@ find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS}) find_package(Ceres REQUIRED COMPONENTS SuiteSparse) find_package(Eigen3 REQUIRED) find_package(LuaGoogle REQUIRED) -# On Windows, Protobuf is incorrectly found by the bundled CMake module. Prefer native CMake config, if possible. -set(protobuf_MODULE_COMPATIBLE TRUE CACHE INTERNAL "") -find_package(Protobuf 3.0.0 CONFIG QUIET) -if (NOT PROTOBUF_FOUND) +if(WIN32) + # On Windows, Protobuf is incorrectly found by the bundled CMake module, so prefer native CMake config. + set(protobuf_MODULE_COMPATIBLE TRUE CACHE INTERNAL "") + find_package(Protobuf 3.0.0 CONFIG) +else() find_package(Protobuf 3.0.0 REQUIRED) endif()