Question
I'm modifying my CMake configuration from building and installing a library to just installing a prebuilt library.
Original configuration:
SET(BUILD_LIB tttrs)
# Build commands for BUILD_LIB
INSTALL(TARGETS ${BUILD_LIB} DESTINATION lib)
New configuration:
INSTALL(FILES libtttrs.so DESTINATION lib)
The prebuilt libtttrs.so works the same as the original, but when using INSTALL(FILES) with gbs build:
- The build log doesn't show "Provides: libtttrs.so" as it did with INSTALL(TARGETS)
- The build fails due to dependencies on this library
Both configurations show the installation line:
Installing: /home/abuild/rpmbuild/BUILDROOT/.../libtttrs.so
This works in:
- Tizen 3.0 with CMake 2.6
But fails in:
- Tizen 2.4 with CMake 2.6
How can I properly provide a prebuilt library using INSTALL(FILES) in CMake?
Answer
Problem Understanding
The issue occurs when switching from building and installing a library (INSTALL(TARGETS)) to installing a prebuilt library (INSTALL(FILES)). While the file gets installed in both cases, the package metadata (particularly the "Provides" field) isn't being generated correctly with INSTALL(FILES), causing dependency resolution to fail.
Solution Methods
-
Use RPM spec file directives: Add explicit Provides information in your RPM spec file:
Provides: libtttrs.so -
Alternative CMake approach: Use both INSTALL(FILES) and set_target_properties to ensure proper metadata:
INSTALL(FILES libtttrs.so DESTINATION lib) set_target_properties(tttrs PROPERTIES PROVIDES libtttrs.so ) -
Version-specific workaround: For Tizen 2.4 compatibility, consider:
- Using the older INSTALL(TARGETS) approach
- Creating a symbolic link if needed
- Explicitly listing dependencies in your package configuration
Additional Tips
- Verify your CMake version compatibility with different Tizen releases
- Check the RPM spec file for any missing metadata
- Consider testing with newer Tizen versions if possible
- Ensure the prebuilt library is compatible with all target platforms