@@ -34,12 +34,37 @@ CPMAddPackage("gh:fmtlib/fmt#10.0.0")
3434
3535set (Protobuf_USE_STATIC_LIBS ON )
3636
37- find_package (protobuf CONFIG )
38- if (NOT protobuf_FOUND) # Legacy protobuf support
39- message (STATUS "Trying legacy method of finding protobuf" )
37+ if (DEFINED EXTERNAL_LIBPROTOBUF_PATH AND DEFINED EXTERNAL_PROTOC_PATH)
38+ # In case protobuf location is defined externally (Windows/CI hack)
39+ find_package (Protobuf ) # fails but defines protobuf_generate_cpp lmaoooo
40+ cmake_path (SET Protobuf_LIBRARIES ${EXTERNAL_LIBPROTOBUF_PATH} /lib/libprotobuf.lib )
41+ cmake_path (SET PROTOBUF_INCLUDE_DIRS ${EXTERNAL_LIBPROTOBUF_PATH} /include )
42+ cmake_path (SET Protobuf_PROTOC_EXECUTABLE ${EXTERNAL_PROTOC_PATH} /bin/protoc.exe )
43+
44+ message (STATUS "GONNA DEBUG STUFF" )
45+ get_filename_component (ABSOLUTE_PROTOC_EXE ${Protobuf_PROTOC_EXECUTABLE} ABSOLUTE )
46+ message (STATUS ${ABSOLUTE_PROTOC_EXE} )
47+ set (Protobuf_PROTOC_EXECUTABLE ${ABSOLUTE_PROTOC_EXE} )
48+
49+ get_filename_component (ABSOLUTE_PROTOBUF_INCLUDE ${PROTOBUF_INCLUDE_DIRS} ABSOLUTE )
50+ message (STATUS ${ABSOLUTE_PROTOBUF_INCLUDE} )
51+ set (PROTOBUF_INCLUDE_DIRS ${ABSOLUTE_PROTOBUF_INCLUDE} )
52+
53+ get_filename_component (ABSOLUTE_PROTOBUF_LIB ${Protobuf_LIBRARIES} ABSOLUTE )
54+ message (STATUS ${ABSOLUTE_PROTOBUF_LIB} )
55+ set (Protobuf_LIBRARIES ${ABSOLUTE_PROTOBUF_LIB} )
56+
57+ add_executable (protobuf::protoc IMPORTED )
58+ set_target_properties (protobuf::protoc PROPERTIES IMPORTED_LOCATION "${Protobuf_PROTOC_EXECUTABLE} " )
4059 set (protobuf_MODULE_COMPATIBLE ON )
41- include (FindProtobuf )
42- find_package (Protobuf REQUIRED )
60+ else ()
61+ find_package (protobuf CONFIG )
62+ if (NOT protobuf_FOUND) # Legacy protobuf support
63+ message (STATUS "Trying legacy method of finding protobuf" )
64+ set (protobuf_MODULE_COMPATIBLE ON )
65+ include (FindProtobuf )
66+ find_package (Protobuf REQUIRED )
67+ endif ()
4368endif ()
4469
4570# Generate Protobuf files
0 commit comments