Fallback for ProtoBuf detection

Avoid always having to write out the setting for older systems
This commit is contained in:
Seth Hillbrand 2025-06-05 12:10:15 -07:00
parent 29dc45d584
commit 1a432cae3b

View File

@ -838,24 +838,29 @@ if( OCC_VERSION_STRING VERSION_LESS 7.5.0 )
endif()
include_directories( SYSTEM ${OCC_INCLUDE_DIR} )
if( KICAD_USE_CMAKE_FINDPROTOBUF )
# Try to find Protobuf with modern approach first, fallback to legacy if needed
set( _protobuf_found FALSE )
if( NOT KICAD_USE_CMAKE_FINDPROTOBUF )
message( STATUS "Attempting to find Protobuf using CONFIG mode..." )
find_package( Protobuf QUIET CONFIG )
if( Protobuf_FOUND )
set( Protobuf_LIBRARY "protobuf::libprotobuf" )
set( _protobuf_found TRUE )
message( STATUS "Found Protobuf using CONFIG mode" )
else()
message( STATUS "CONFIG mode failed, falling back to FindProtobuf.cmake" )
set( KICAD_USE_CMAKE_FINDPROTOBUF ON )
endif()
endif()
if( NOT _protobuf_found )
message( STATUS "Using FindProtobuf.cmake to locate Protobuf..." )
include( FindProtobuf )
find_package( Protobuf REQUIRED )
else()
find_package( Protobuf REQUIRED CONFIG )
set( Protobuf_LIBRARY "protobuf::libprotobuf" )
endif()
if( NOT Protobuf_PROTOC_EXECUTABLE )
if( NOT KICAD_USE_CMAKE_FINDPROTOBUF)
set( Protobuf_PROTOC_EXECUTABLE "protobuf::protoc" )
else()
MESSAGE( FATAL_ERROR "Protobuf compiler not found. Please install protobuf-compiler." )
endif()
endif()
if( NOT Protobuf_INCLUDE_DIR )
get_target_property( Protobuf_INCLUDE_DIR protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES )
if( Protobuf_FOUND )
message( STATUS "Found Protobuf using FindProtobuf.cmake" )
endif()
endif()