MOBICOM/MOBICOM — comment on commit 8d37c5c7f57e0a15e4008ed1f121ece42a1f0572
File:  line 0
By TobiasSimon:

alternative idea, in which all python files are a) compiled individually (prevents namespace conflicts in ARCADE) and b) have an own "real" target
we should also make a macro out of it, in oder to define prefixes for the target libraries/pseudotarget

```cmake
file(GLOB
PROTO_INPUT RELATIVE
${CMAKE_CURRENT_SOURCE_DIR}
"*.proto")

find_program(PROTOC protoc)
find_program(PROTOC_C protoc-c)
set(PROTOC_CPP_OUT_FLAG --cpp_out)
set(PROTOC_PY_OUT_FLAG --python_out)
set(PROTOC_C_OUT_FLAG --c_out=)

unset (GEN_CPP)

set(PROTO_GEN_DIR ${CMAKE_CURRENT_BINARY_DIR})

foreach(PROTO_FILE ${PROTO_INPUT})
get_filename_component(PROTO_PREFIX ${PROTO_FILE} NAME_WE)

set(PROTO_C_FILE ${PROTO_PREFIX}.pb-c.c)
set(PROTO_GEN_C ${PROTO_GEN_C} ${PROTO_C_FILE})

add_custom_command(OUTPUT ${PROTO_C_FILE}
COMMAND ${PROTOC_C} ${PROTO_FILE} ${PROTOC_C_OUT_FLAG}${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${PROTOC_C} ${PROTO_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

if (${GEN_CPP})
set(PROTO_CPP_FILE ${PROTO_PREFIX}.pb.cc)
set(PROTO_GEN_CPP ${PROTO_GEN_CPP} ${PROTO_CPP_FILE})
add_custom_command(OUTPUT ${PROTO_CPP_FILE}
COMMAND ${PROTOC} ${PROTO_FILE} ${PROTOC_CPP_OUT_FLAG} ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${PROTOC} ${PROTO_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif (${GEN_CPP})

set(PROTO_PY_FILE ${PROTO_PREFIX}_pb2.py)
set(PROTO_GEN_PY ${PROTO_GEN_PY} ${PROTO_PY_FILE})
add_custom_command(OUTPUT ${PROTO_PY_FILE}
COMMAND ${PROTOC} ${PROTO_FILE}
ARGS ${PROTOC_PY_OUT_FLAG} ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${PROTOC} ${PROTO_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

endforeach(PROTO_FILE ${PROTO_INPUT})

if (${GEN_CPP})
ADD_LIBRARY(network_messages STATIC ${PROTO_GEN_CPP})
else (${GEN_CPP})
ADD_LIBRARY(network_messages STATIC ${PROTO_GEN_C})
endif (${GEN_CPP})

ADD_CUSTOM_TARGET(network_messages_py ALL DEPENDS ${PROTO_GEN_PY})
```