Open federico-lmo opened 1 year ago
You comment is correct. There is some issue in this cmake file. It is fixed in v3.5 which is:
_if(NOT BUILD_SHARED_LIBS) find_package(Boost REQUIRED) option(Protobuf_USE_STATIC_LIBS "protobuf static lib" OFF) find_package(Protobuf REQUIRED) endif(NOT BUILD_SHAREDLIBS)
I'm working on a CMake project which uses the Petalinux SDK with the sysroot environment generated by the script
board_setup/mpsoc/host_cross_compiler_setup.sh
. The application uses thexir
library, whose package information is loaded viafind_package(xir)
.When the flag BUILD_SHARED_LIBS is not set, building will fail because there are no Protobuf static libraries available in the sysroot.
The reason is this extract from
petalinux_sdk_2022.2/sysroots/cortexa72-cortexa53-xilinx-linux/usr/share/cmake/xir/xir-config.cmake
My understanding from the BUILD_SHARED_LIBS flag documentation is that it is meant to be used from the command line (or from a CMake preset) if one wants to force building all the libraries provided by a project as dynamic libraries. Whether the project dependencies are linked to dynamically or statically should mainly depend on what is available. Hard-coding the
BUILD_SHARED_LIBS
flag in the projectCMakeLists.txt
works but it is not a proper solution as it forces everything to be dynamic. Commenting outset(Protobuf_USE_STATIC_LIBS ON)
makes the compilation succeed and I wonder if this can be fixed upstream.INFO: Petalinux SDK: 2022.2 Vitis-AI: 3.0 CMake: 3.25.1