mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 06:22:15 -07:00
Add a wrapper.
Took 35 minutes
This commit is contained in:
parent
e5f23f1906
commit
1d1de904e0
164 changed files with 25 additions and 34 deletions
|
|
@ -327,8 +327,8 @@ endif()
|
|||
include(CPack)
|
||||
|
||||
add_subdirectory(common)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/libs/protocol ${CMAKE_BINARY_DIR}/libs/protocol)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/libs/deck_list ${CMAKE_BINARY_DIR}/libs/deck_list)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/libs/pb ${CMAKE_BINARY_DIR}/libs/pb)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/libs/rng ${CMAKE_BINARY_DIR}/libs/rng)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/libs/server ${CMAKE_BINARY_DIR}/libs/server)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/libs/settings ${CMAKE_BINARY_DIR}/libs/settings)
|
||||
|
|
|
|||
|
|
@ -25,10 +25,12 @@ add_library(cockatrice_deck_list STATIC
|
|||
${MOC_SOURCES}
|
||||
)
|
||||
|
||||
add_dependencies(cockatrice_deck_list cockatrice_protocol_wrapper)
|
||||
|
||||
target_include_directories(cockatrice_deck_list
|
||||
PUBLIC include
|
||||
)
|
||||
|
||||
target_link_libraries(cockatrice_deck_list
|
||||
PUBLIC cockatrice_protocol utility ${COCKATRICE_QT_MODULES}
|
||||
PUBLIC cockatrice_protocol_wrapper utility ${COCKATRICE_QT_MODULES}
|
||||
)
|
||||
|
|
|
|||
14
libs/protocol/CMakeLists.txt
Normal file
14
libs/protocol/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Top-level wrapper for the protobuf library
|
||||
add_library(cockatrice_protocol_wrapper STATIC
|
||||
# Optionally, you can add a dummy source if needed
|
||||
)
|
||||
|
||||
# Link the actual generated protobuf library
|
||||
target_link_libraries(cockatrice_protocol_wrapper
|
||||
PUBLIC cockatrice_protocol
|
||||
)
|
||||
|
||||
# Expose the pb/ folder so consumers can do #include "pb/header.pb.h"
|
||||
target_include_directories(cockatrice_protocol_wrapper
|
||||
PUBLIC ${CMAKE_BINARY_DIR} # points to the generated headers
|
||||
)
|
||||
|
|
@ -165,46 +165,18 @@ set(PROTO_FILES
|
|||
session_event.proto
|
||||
)
|
||||
|
||||
# Common output directory for generated files
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pb)
|
||||
set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/pb")
|
||||
|
||||
if(${Protobuf_VERSION} VERSION_LESS "3.21.0.0")
|
||||
message(STATUS "Using Protobuf Legacy Mode")
|
||||
|
||||
include_directories(${PROTOBUF_INCLUDE_DIRS})
|
||||
include_directories(${PROTO_BINARY_DIR}) # expose pb/ folder
|
||||
|
||||
# Generate protobuf cpp/h files directly into pb/
|
||||
set(PROTO_SRCS)
|
||||
set(PROTO_HDRS)
|
||||
foreach (f ${PROTO_FILES})
|
||||
get_filename_component(fname ${f} NAME_WE)
|
||||
set(src_cpp ${PROTO_BINARY_DIR}/${fname}.pb.cc)
|
||||
set(src_h ${PROTO_BINARY_DIR}/${fname}.pb.h)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${src_cpp} ${src_h}
|
||||
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
|
||||
--cpp_out=${PROTO_BINARY_DIR}
|
||||
-I ${CMAKE_CURRENT_LIST_DIR}
|
||||
${CMAKE_CURRENT_LIST_DIR}/${f}
|
||||
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/${f}
|
||||
COMMENT "Generating ${fname}.pb.cc / .pb.h"
|
||||
)
|
||||
|
||||
list(APPEND PROTO_SRCS ${src_cpp})
|
||||
list(APPEND PROTO_HDRS ${src_h})
|
||||
endforeach ()
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
|
||||
|
||||
add_library(cockatrice_protocol ${PROTO_SRCS} ${PROTO_HDRS})
|
||||
|
||||
set(cockatrice_protocol_LIBS ${PROTOBUF_LIBRARIES})
|
||||
if(UNIX)
|
||||
set(cockatrice_protocol_LIBS ${cockatrice_protocol_LIBS} -lpthread)
|
||||
endif(UNIX)
|
||||
target_link_libraries(cockatrice_protocol ${cockatrice_protocol_LIBS})
|
||||
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")
|
||||
|
|
@ -218,7 +190,8 @@ if(${Protobuf_VERSION} VERSION_LESS "3.21.0.0")
|
|||
else()
|
||||
add_library(cockatrice_protocol ${PROTO_FILES})
|
||||
target_link_libraries(cockatrice_protocol PUBLIC protobuf::libprotobuf)
|
||||
target_include_directories(cockatrice_protocol PUBLIC "${PROTOBUF_INCLUDE_DIRS}" PUBLIC ${CMAKE_CURRENT_BINARY_DIR} PUBLIC ${PROTO_BINARY_DIR})
|
||||
set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
target_include_directories(cockatrice_protocol PUBLIC "${PROTOBUF_INCLUDE_DIRS}")
|
||||
|
||||
protobuf_generate(
|
||||
TARGET cockatrice_protocol IMPORT_DIRS "${CMAKE_CURRENT_LIST_DIR}" PROTOC_OUT_DIR "${PROTO_BINARY_DIR}"
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue