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

QT工程,生成CMake文件之后,无法直接使用Qt Creator编译 #4884

Closed
supf1994 opened this issue Mar 27, 2024 · 4 comments
Closed
Labels
Milestone

Comments

@supf1994
Copy link

supf1994 commented Mar 27, 2024

Xmake 版本

2.8.9

操作系统版本和架构

windows10

描述问题

QT工程,使用xmake project -k cmake 指令生成CMake文件之后,无法直接使用Qt Creator编译,提示错误

image

似乎是因为生成的cl 指令参数中带有
将cmake工程生成脚本中的 _translate_flag函数修改后可以正常运行,修改后的文件位于工程目录下的 plugins/project_test/cmake文件夹中

-- translate flag
function _translate_flag(flag, outputdir)
    if flag then
        if path.instance_of(flag) then
            --flag = flag:clone():set(_get_relative_unix_path_to_cmake(flag:str(), outputdir)):str()
            flag = flag:clone():set(_get_relative_unix_path_to_cmake(flag:rawstr(), outputdir)):str()
        -- it may be table, https://github.com/xmake-io/xmake/issues/4816
        elseif type(flag) == "string" then
            if path.is_absolute(flag) then
                flag = _get_relative_unix_path_to_cmake(flag, outputdir)
            elseif flag:startswith("-fmodule-file=") then
                flag = "-fmodule-file=" .. _get_relative_unix_path_to_cmake(flag:sub(15), outputdir)
            elseif flag:startswith("-fmodule-mapper=") then
                flag = "-fmodule-mapper=" .. _get_relative_unix_path_to_cmake(flag:sub(17), outputdir)
            elseif flag:startswith("-F") then
                if flag:startswith("-Fd") then
                    flag = '-Fd' .. _get_relative_unix_path_to_cmake(flag:sub(4), outputdir)
                elseif flag:startswith("-Fe") then
                    flag = '-Fe' .. _get_relative_unix_path_to_cmake(flag:sub(4), outputdir)
                elseif flag:startswith("-Fi") then
                    flag = '-Fi' .. _get_relative_unix_path_to_cmake(flag:sub(4), outputdir)
                elseif flag:startswith("-FI") then
                    flag = '-FI' .. _get_relative_unix_path_to_cmake(flag:sub(4), outputdir)
                elseif flag:startswith("-Fo") then
                    flag = '-Fo' .. _get_relative_unix_path_to_cmake(flag:sub(4), outputdir)
                elseif flag:startswith("-Fp") then
                    flag = '-Fp' .. _get_relative_unix_path_to_cmake(flag:sub(4), outputdir)
                elseif flag:startswith("-FR") then
                    flag = '-FR' .. _get_relative_unix_path_to_cmake(flag:sub(4), outputdir)
                elseif flag:startswith("-Fr") then
                    flag = '-Fr' .. _get_relative_unix_path_to_cmake(flag:sub(4), outputdir)
                elseif string.len(flag) > 5 then
                    flag = '-F' .. _get_relative_unix_path_to_cmake(flag:sub(3), outputdir)
                end
            elseif flag:startswith("-I") then
                flag = '-I' .. _get_relative_unix_path_to_cmake(flag:sub(3), outputdir)
            elseif flag:startswith("-external:I") then
                flag = '-external:I' .. _get_relative_unix_path_to_cmake(flag:sub(12), outputdir)
            elseif flag:startswith("-Yu") then
                flag = '-Yu' .. _get_relative_unix_path_to_cmake(flag:sub(4), outputdir) 
            elseif flag:match("(.+)=(.+)") then
                local k, v = flag:match("(.+)=(.+)")
                if v and (v:endswith(".ifc") or v:endswith(".map")) then -- e.g. hello=xxx/hello.ifc
                    flag = k .. "=" .. _get_relative_unix_path_to_cmake(v, outputdir)
                end
            end
        end
    end
    return flag
end

测试工程
qt_test.zip

期待的结果

生成后可以直接生成

工程配置

...

附加信息和错误日志

....

@supf1994 supf1994 added the bug label Mar 27, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: QT project, after generating the CMake file, cannot be compiled directly using Qt Creator

@waruqi
Copy link
Member

waruqi commented Mar 27, 2024

试下这个 patch #4888

xmake update -s dev

@waruqi waruqi added this to the v2.9.1 milestone Mar 27, 2024
@waruqi
Copy link
Member

waruqi commented Mar 29, 2024

可以了么

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Is it okay?

@waruqi waruqi closed this as completed Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants