Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make /utf-8 from fmt public #4657

Closed
wants to merge 1 commit into from
Closed

Conversation

SFGrenade
Copy link
Contributor

probably a good idea, since otherwise the flag would be lost on targets dependent on targets that have fmt

probably a good idea, since otherwise the flag would be lost on targets dependent on targets that have fmt
@star-hengxing
Copy link
Contributor

package cxflags, defines etc... public by default.

@SFGrenade
Copy link
Contributor Author

@star-hengxing
Copy link
Contributor

It work for me:

add_requires("spdlog", {configs = {fmt_external = true}})

target("test")
    set_kind("shared")
    add_files("src/main.cpp")
    add_packages("spdlog")
$ xmake show -t test
The information of target(test):
    at: A:\project\xmake\test\xmake.lua
    kind: shared
    targetfile: build\windows\x64\release\test.dll
    packages:
      -> spdlog -> .\xmake.lua:13
    links:
      -> fmt -> package(spdlog)
    defines:
      -> SPDLOG_FMT_EXTERNAL -> package(spdlog)
    cxxflags:
      -> /utf-8 -> package(spdlog)
    linkdirs:
      -> C:\Users\star\AppData\Local\.xmake\packages\f\fmt\11.0.1\1c78db9bda7a44839b9037b8ec565ca1\lib -> package(spdlog)
    sysincludedirs:
      -> C:\Users\star\AppData\Local\.xmake\packages\f\fmt\11.0.1\1c78db9bda7a44839b9037b8ec565ca1\include -> package(spdlog)
      -> C:\Users\star\AppData\Local\.xmake\packages\s\spdlog\v1.14.1\56c0109d4bc3441e928483ae0c35bbed\include -> package(spdlog)
    files:
      -> src\main.cpp -> .\xmake.lua:12
    compiler (cxx): C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\bin\HostX64\x64\cl.exe
      -> -nologo
    linker (sh): C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\bin\HostX64\x64\link.exe
      -> -nologo -machine:x64
    compflags (cxx):
      -> -nologo -std:c++20 -DSPDLOG_FMT_EXTERNAL -external:W0 -external:IC:\Users\star\AppData\Local\.xmake\packages\s\spdlog\v1.14.1\56c0109d4bc3441e928483ae0c35bbed\include -external:W0 -external:IC:\Users\star\AppData\Local\.xmake\packages\f\fmt\11.0.1\1c78db9bda7a44839b9037b8ec565ca1\include /utf-8
    linkflags (sh):
      -> -nologo -machine:x64 -libpath:C:\Users\star\AppData\Local\.xmake\packages\f\fmt\11.0.1\1c78db9bda7a44839b9037b8ec565ca1\lib fmt.lib

@SFGrenade
Copy link
Contributor Author

SFGrenade commented Jul 14, 2024

for me the linked setup is basically:

./logger/xmake.lua:
add_requires( "spdlog" )
add_requireconfs( "spdlog", { configs = { fmt_external_ho = true } } )
target( "Logger" )
    set_kind( "static" )
    add_packages( "spdlog", { public = true } )
    add_includedirs( "include", { public = true } )
    add_headerfiles( "include/(*.h)" )
    add_files( "src/*.cpp" )

./anything_else/xmake.lua:
target( "ActualProgram" )
    set_kind( "binary" )
    add_deps( "Logger", { public = true } )
    add_includedirs( "include", { public = true } )
    add_headerfiles( "include/(*.h)" )
    add_files( "src/*.cpp" )

with which ActualProgram would get compiled without /utf-8, causing compiler errors.
but as soon as i did:

./logger/xmake.lua:
add_requires( "spdlog" )
add_requireconfs( "spdlog", { configs = { fmt_external_ho = true } } )
target( "Logger" )
    set_kind( "static" )
    add_packages( "spdlog", { public = true } )
    if is_plat( "windows" ) then                     -- this is extra
        add_cxxflags( "/utf-8", { public = true } )  -- this is extra
    end                                              -- this is extra
    add_includedirs( "include", { public = true } )
    add_headerfiles( "include/(*.h)" )
    add_files( "src/*.cpp" )

it compiled successfully

@star-hengxing
Copy link
Contributor

@waruqi Any idea?

@@ -52,7 +52,7 @@ package("fmt")
end
end
if package:is_plat("windows") and package:config("unicode") then
package:add("cxxflags", "/utf-8")
package:add("cxxflags", "/utf-8", {public = true})
Copy link
Member

Choose a reason for hiding this comment

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

package:add does not {public}, only target supports it.

@waruqi
Copy link
Member

waruqi commented Jul 15, 2024

Currently, only abstract interfaces support exporting from a package to a parent target. e.g. add_defines, add_syslinks ...

but add_cxflags, add_ldflags do not support now.

@star-hengxing
Copy link
Contributor

#4942

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.

None yet

3 participants