Hello 

I'm facing an issue that consumes a lot of time trying to find out what is 
the issue and i hope someone could help 

I build Protobuffer for windows by using the following CMake and it does 
work 
some of the setting flags are duplicated but it's okay 

# === definitions ===
include(FetchContent)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(BUILD_TESTING OFF)
set(protobuf_MSVC_STATIC_RUNTIME OFF)
set(protobuf_USE_EXTERNAL_GTEST ON)
SET(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "Build Shared Libraries" 
FORCE)
SET(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link static runtime 
libraries" FORCE)
message(CHECK_START "Fetching Protobuf")
list(APPEND CMAKE_MESSAGE_INDENT "  ")

FetchContent_Declare(
  protobuf
  GIT_REPOSITORY "https://github.com/protocolbuffers/protobuf.git";
  GIT_TAG "v21.12" 
  FIND_PACKAGE_ARGS NAMES protobuf
  )

set(protobuf_BUILD_TESTS OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(protobuf)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")

include(Findprotobuf)

include_directories(${Protobuf_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# === targets ===
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER media.proto)
message("PROTO_SRC ${PROTO_SRC}")
message("PROTO_HEADER ${PROTO_HEADER}")
add_library(PROTO STATIC  ${PROTO_HEADER} ${PROTO_SRC} CProtoWrapper.cpp)

target_link_libraries(PROTO
    PUBLIC
        protobuf::libprotobuf
        ${protobuf_LIBRARIES}

        
)

target_include_directories(PROTO PUBLIC 
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
#=== install ===
install(TARGETS PROTO EXPORT PROTO_Targets
        RUNTIME COMPONENT PROTO_Runtime
        LIBRARY COMPONENT PROTO_Runtime
        NAMELINK_COMPONENT PROTO_Development
        ARCHIVE COMPONENT PROTO_Development
        INCLUDES DESTINATION "${CMAKE_INSTALL_LIBDIR}")

install(EXPORT PROTO_Targets
        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PROTO
        COMPONENT PROTO_Development)   


Now using the same file but crossing-compiling for android and invoking 
CMake using the following  python script 

    cmake_args += [
        f"-D 
CMAKE_TOOLCHAIN_FILE={ndk_dir}\\build\\cmake\\android.toolchain.cmake",
        f"-D CMAKE_MAKE_PROGRAM={sdk_dir}\\cmake\\3.18.1\\bin\\ninja.exe",
        f"-D ANDROID_PLATFORM=android-21",
        f"-D CMAKE_EXPORT_COMPILE_COMMANDS=ON",
        f"-D CMAKE_VERBOSE_MAKEFILE=ON",
       f"-D ANDROID_ABI=x86_64",
       f"-D SWYPE_APK_BUILD_ABI=i86_android_64bit"
        f"-D CMAKE_IMPORT_LIBRARY_SUFFIX=.a"
    ]
    subprocess.run(
        ["cmake", "-G Ninja Multi-Config","-S", ".."] + cmake_args, 
check=True
    )
 
now ninja compiler uses this line which causes an issue in building 
protobuf::protoc --cpp_out, where *protobuf::protoc has no expansion *in 
that case 

Any idea would be appreciated 
Thanks 

        

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/81b906f6-35de-4c14-9f51-7aca5d3969a4n%40googlegroups.com.

Reply via email to