Hi everyone,
I'm trying to add components to the protobuf recipe but I'm not being able to pass the tests. The default FindProtobuf.cmake exports several components:
The following :prop_tgt:`IMPORTED` targets are also defined:
``protobuf::libprotobuf``
The protobuf library.
``protobuf::libprotobuf-lite``
The protobuf lite library.
``protobuf::libprotoc``
The protoc library.
``protobuf::protoc``
The protoc compiler.
The definition of package_info() in the current recipe of protobuf/3.11.4 is:
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.libs.sort(reverse=True)
if self.settings.os == "Linux":
self.cpp_info.system_libs.append("pthread")
if self._is_clang_x86 or "arm" in str(self.settings.arch):
self.cpp_info.system_libs.append("atomic")
if self.settings.os == "Windows":
if self.options.shared:
self.cpp_info.defines = ["PROTOBUF_USE_DLLS"]
self.cpp_info.names["cmake_find_package"] = "Protobuf"
self.cpp_info.names["cmake_find_package_multi"] = "Protobuf"
self.cpp_info.builddirs = [
self._cmake_install_base_path,
]
self.cpp_info.build_modules = [
os.path.join(self._cmake_install_base_path, "protobuf-generate.cmake"),
os.path.join(self._cmake_install_base_path, "protobuf-module.cmake"),
os.path.join(self._cmake_install_base_path, "protobuf-options.cmake"),
]
bindir = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment variable: {}".format(bindir))
self.env_info.PATH.append(bindir)
I'm trying to change it to:
def package_info(self):
self.cpp_info.names["cmake_find_package"] = "Protobuf"
self.cpp_info.names["cmake_find_package_multi"] = "Protobuf"
# Component libprotobuf
self.cpp_info.components["libprotobuf"].libs = ["libprotobuf"]
if self.settings.os == "Linux":
self.cpp_info.components["libprotobuf"].system_libs.append("pthread")
if self._is_clang_x86 or "arm" in str(self.settings.arch):
self.cpp_info.components["libprotobuf"].append("atomic")
if self.settings.os == "Windows":
if self.options.shared:
self.cpp_info.components["libprotobuf"].defines = ["PROTOBUF_USE_DLLS"]
# Component libprotoc
self.cpp_info.components["libprotoc"].libs = ["libprotoc"]
# Component protoc
# How to add an executable?
if not self.options.lite:
self.cpp_info.components["protoc"].libs = ["libprotoc"]
# Should this be the same for libprotoc
self.cpp_info.components["libprotobuf"].builddirs = [
self._cmake_install_base_path,
]
self.cpp_info.components["libprotobuf"].build_modules = [
os.path.join(self._cmake_install_base_path, "protobuf-generate.cmake"),
os.path.join(self._cmake_install_base_path, "protobuf-module.cmake"),
os.path.join(self._cmake_install_base_path, "protobuf-options.cmake"),
]
bindir = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment variable: {}".format(bindir))
self.env_info.PATH.append(bindir)
Does this seem reasonable?
When creating the package, the testing fails with:
Using lockfile: '/home/juan/conan-center-index/recipes/protobuf/all/test_package/build/8e7da137254ca61c29cfd61de2482b72ba0ff99c/conan.lock'
Using cached profile from lockfile
protobuf/3.11.4@juan/test (test package): Calling build()
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: called by CMake conan helper
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Conan: Compiler GCC>=5, checking major version 8
-- Conan: Checking correct version: 8
-- Conan: C++ stdlib: libstdc++11
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_EXPORT_NO_PACKAGE_REGISTRY
-- Build files have been written to: /home/juan/conan-center-index/recipes/protobuf/all/test_package/build/8e7da137254ca61c29cfd61de2482b72ba0ff99c/without_protoc
/usr/local/bin/cmake -S/home/juan/conan-center-index/recipes/protobuf/all/test_package -B/home/juan/conan-center-index/recipes/protobuf/all/test_package/build/8e7da137254ca61c29cfd61de2482b72ba0ff99c/without_protoc --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /home/juan/conan-center-index/recipes/protobuf/all/test_package/build/8e7da137254ca61c29cfd61de2482b72ba0ff99c/without_protoc/CMakeFiles /home/juan/conan-center-index/recipes/protobuf/all/test_package/build/8e7da137254ca61c29cfd61de2482b72ba0ff99c/without_protoc//CMakeFiles/progress.marks
/usr/bin/make -s -f CMakeFiles/Makefile2 all
Scanning dependencies of target test_package
[ 33%] Building CXX object CMakeFiles/test_package.dir/test_package.cpp.o
[ 66%] Building CXX object CMakeFiles/test_package.dir/addressbook.pb.cc.o
[100%] Linking CXX executable bin/test_package
/usr/bin/ld: cannot find -llibprotobuf
/usr/bin/ld: cannot find -llibprotoc
collect2: error: ld returned 1 exit status
CMakeFiles/test_package.dir/build.make:118: recipe for target 'bin/test_package' failed
make[2]: *** [bin/test_package] Error 1
CMakeFiles/Makefile2:95: recipe for target 'CMakeFiles/test_package.dir/all' failed
make[1]: *** [CMakeFiles/test_package.dir/all] Error 2
Makefile:103: recipe for target 'all' failed
make: *** [all] Error 2
Any ideas? Thanks for the help.
@Croydon thank you. Closing this issue.
I should provide component today or next yet. Finally we all support from Conan to generate the correct targets and variables. Protobuf is kind of exotic in terms of cmake
Most helpful comment
I should provide component today or next yet. Finally we all support from Conan to generate the correct targets and variables. Protobuf is kind of exotic in terms of cmake