From fdf08780b34d3fd460205a607726b8db0b4c67e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Sat, 4 Oct 2025 21:26:31 +0200 Subject: [PATCH] Try like this. Took 8 minutes --- libs/pb/CMakeLists.txt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libs/pb/CMakeLists.txt b/libs/pb/CMakeLists.txt index b1f70a30b..768bb8f42 100644 --- a/libs/pb/CMakeLists.txt +++ b/libs/pb/CMakeLists.txt @@ -167,15 +167,22 @@ set(PROTO_FILES if(${Protobuf_VERSION} VERSION_LESS "3.21.0.0") message(STATUS "Using Protobuf Legacy Mode") - include_directories(${PROTOBUF_INCLUDE_DIRS}) - include_directories(${CMAKE_CURRENT_BINARY_DIR}) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pb) set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/pb") + + include_directories(${PROTOBUF_INCLUDE_DIRS}) + include_directories(${PROTO_BINARY_DIR}) # pb/ folder + protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES}) - foreach (file ${PROTO_SRCS} ${PROTO_HDRS}) - get_filename_component(fname ${file} NAME) - file(RENAME ${file} ${CMAKE_CURRENT_BINARY_DIR}/pb/${fname}) + # Move files at build time using a custom command + foreach (f ${PROTO_SRCS} ${PROTO_HDRS}) + get_filename_component(fname ${f} NAME) + add_custom_command( + TARGET cockatrice_protocol POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${f} ${PROTO_BINARY_DIR}/${fname} + ) endforeach () add_library(cockatrice_protocol ${PROTO_SRCS} ${PROTO_HDRS}) @@ -184,8 +191,7 @@ if(${Protobuf_VERSION} VERSION_LESS "3.21.0.0") set(cockatrice_protocol_LIBS ${cockatrice_protocol_LIBS} -lpthread) endif(UNIX) target_link_libraries(cockatrice_protocol ${cockatrice_protocol_LIBS}) - target_include_directories(cockatrice_protocol PUBLIC "${PROTOBUF_INCLUDE_DIRS}" PUBLIC ${CMAKE_CURRENT_BINARY_DIR} PUBLIC ${PROTO_BINARY_DIR}) - + target_include_directories(cockatrice_protocol PUBLIC ${PROTO_BINARY_DIR}) # ubuntu uses an outdated package for protobuf, 3.1.0 is required if(${Protobuf_VERSION} VERSION_LESS "3.1.0") # remove unused parameter and misleading indentation warnings when compiling to avoid errors