Difference between INSTALL(FILES) and INSTALL(TARGETS) in CMake for prebuilt libraries

Original Created Jun 28, 2017 | Regeneration Apr 22, 2026

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:

  1. The build log doesn't show "Provides: libtttrs.so" as it did with INSTALL(TARGETS)
  2. 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?

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

  1. Use RPM spec file directives: Add explicit Provides information in your RPM spec file:

    Provides: libtttrs.so
    
  2. 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
    )
    
  3. 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

Customize your cookie preferences

You can enable or disable non-essential cookies. Essential cookies are always on to ensure the site works properly and to keep you signed in.

Necessary

These cookies are necessary for the website to function properly and cannot be switched off. They help with things like logging in and setting your privacy preferences.

Always on

Analytics

These cookies help us improve the site by tracking which pages are most popular and how visitors move around the site.

Enable analytics cookies
Public Forum Public Forum
Employees only. Please sign in with your company account.