Skip to content

Introduce diagnostic for calling set_kind() in package() #6842

@sveljko

Description

@sveljko

Xmake Version

3.0.2

Operating System Version and Architecture

AlmaLinux 9

Describe Bug

In my own xmake-repo, I introduced a simple package definition for a small static library. Because of copy-paste, I left set_kind("static") in it, like:

package("mylib")
    set_kind("static")
    set_urls("<mylibURL>")
    on_install(function (pkg)
        import("package.tools.xmake").install(pkg, {})
    end)

The static library itself is very simple, nothing interesting to report.

add_rules("mode.debug", "mode.release")
set_languages("gnuxx20")
target("mylib")
    set_kind("static")
    add_files("source/*.cpp")
    add_includedirs("include", {public = true})
    add_headerfiles("include/*.hpp")

When building my project which add_requires("mylib", {configs={"local"}}) and for the target add_packages("mylib", ...<other libs>), the package installed fine and, with -v verbose output, I saw that the table for the installed library contains sysincludedirs. But the cache (.xmake/linux/x86_64/cache/package) did not have sysincludedirs for the mylib package, thus the build failed.

It took a while for me to notice the set_kind() "inside" package() and when I removed it, it worked fine.

Expected Behavior

Obviously the set_kind() "inside" package() wreaks havoc. Now, maybe some of this is intended behavior, but even if it is, it's strange. So, either:

  • report an error when calling set_kind() "inside" package()
  • report a warning about it having potentially unwanted effect, with some way of suppressing said warning for those who are fine with it

Project Configuration

add_rules("mode.debug", "mode.release")
add_requires("mylib main", {configs = {"local"}})
set_languages "gnuxx20"
target "myapp"
    set_kind "binary"
    add_files(<stuff>)
    add_packages("mylib", ...<other packages>)

Additional Information and Error Logs

nothing to add

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions