Skip to content

Fix the libdir inside the installed CMake import files#6984

Merged
waruqi merged 1 commit intoxmake-io:devfrom
MeanSquaredError:cmake_importfiles_libdir
Nov 2, 2025
Merged

Fix the libdir inside the installed CMake import files#6984
waruqi merged 1 commit intoxmake-io:devfrom
MeanSquaredError:cmake_importfiles_libdir

Conversation

@MeanSquaredError
Copy link
Contributor

This PR fixes the library directory inside the generated CMake import files.

Currently it is possible to customize the install location of a target library by calling

target:set ("prefixdir", "/", {libdir = libdir})

where libdir is the custom library directory

Also it is possible to customize the location of the CMake import files for that target by calling

target:extraconf_set ("rules", "utils.install.cmake_importfiles", "libdir", libdir)

where libdir is the custom library directory of the import files. However the import files have the library location hardcoded as lib.

This means that it is possible to install the library and the CMake import files into a custom directory (e.g. lib64, but the import files will always assume that the custom library is in lib. This in turn means that any attempts to find the installed library from CMake will fail.

This PR fixes that issue by changing the import file templates so that they don't hardcode the lib directory but instead use the variable LIBDIR. Then the import files generator script is modified to substitute the correct value for the LIBDIR variable when processing the templates.

…e libdir where the import files are installed.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @MeanSquaredError, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue where CMake import files failed to correctly locate installed libraries when a custom library directory was specified. By introducing a dynamic LIBDIR variable in the import file templates and updating the generation logic, it ensures that CMake can now accurately find libraries installed in non-default locations, improving flexibility for library installation.

Highlights

  • CMake Import File Customization: Previously, CMake import files hardcoded the library directory as 'lib', causing issues when libraries were installed to a custom location (e.g., 'lib64') and CMake failed to find them.
  • Dynamic Library Directory Resolution: The fix introduces a LIBDIR variable into CMake import file templates, allowing the library directory to be dynamically set based on the custom libdir configuration provided during installation.
  • Generator Script Update: The import file generator script (cmake_importfiles.lua) has been updated to correctly pass and substitute the LIBDIR variable with the appropriate custom library directory when processing the templates.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly addresses an issue where the library directory was hardcoded in generated CMake import files. By introducing a LIBDIR variable in the templates and substituting it in the generator script, the changes allow for customizable library installation paths like lib64. The implementation is sound and the changes are consistent across the modified files. I have one minor suggestion regarding code duplication to improve maintainability.

@waruqi waruqi added this to the v3.0.5 milestone Nov 2, 2025
@waruqi waruqi merged commit 6b06cea into xmake-io:dev Nov 2, 2025
22 checks passed
@MeanSquaredError MeanSquaredError deleted the cmake_importfiles_libdir branch November 3, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants