-
-
Notifications
You must be signed in to change notification settings - Fork 771
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
add_requires 能够查找到cmake包的头文件路径, 但无法找到cmake包的库 #2557
Comments
ok |
正常读取link.txt linkdata:
问题好像出现在这里, 这两个变量is_ldflags, is_library 一直是false |
问题出现在这里 "-Wl," 输出变成了
最后,他输出了一个警告
不知道有没有影响 |
大佬能改一下吗? |
更新到 dev 再试试,xmake update -s dev |
我测试了一下,有些问题
linkdata: 或许可以让它检测可用的 links, 然后添加 |
缺 linkdirs ,看下是否在 /usr 下系统库目录
自己检测是不可靠的,而且缺 linkdirs 这些 links 都会被忽略,最后link还是会失败 |
没有少, 反而是多了, xmake检测到了
DTKWIDGET,DtkWidget 我用cmake构造的dtk程序里, 不会多余这两个 |
link.txt: |
那你继续调下上面那个 find_package.lua 看看为什么多了。。那个里面也是构造的 cmakelists 让 cmake 生成的 link.txt 。。 |
我找到问题的位置了 _find_package 生成的 CMakeLists.txt: cmake_minimum_required(VERSION 3.22.1)
project(find_package)
find_package(DtkWidget REQUIRED)
if(DtkWidget_FOUND)
add_executable(test_DtkWidget test.cpp)
target_include_directories(test_DtkWidget PRIVATE ${DtkWidget_INCLUDE_DIR} ${DtkWidget_INCLUDE_DIRS})
target_include_directories(test_DtkWidget PRIVATE ${DTKWIDGET_INCLUDE_DIR} ${DTKWIDGET_INCLUDE_DIRS})
target_include_directories(test_DtkWidget PRIVATE ${DtkWidget_CXX_INCLUDE_DIRS})
target_link_libraries(test_DtkWidget DtkWidget ${DtkWidget_LIBRARY} ${DtkWidget_LIBRARIES} ${DtkWidget_LIBS})
target_link_libraries(test_DtkWidget DTKWIDGET ${DTKWIDGET_LIBRARY} ${DTKWIDGET_LIBRARIES} ${DTKWIDGET_LIBS})
endif(DtkWidget_FOUND) 其中 target_link_libraries(test_DtkWidget DtkWidget ${DtkWidget_LIBRARY} ${DtkWidget_LIBRARIES} ${DtkWidget_LIBS})
target_link_libraries(test_DtkWidget DTKWIDGET ${DTKWIDGET_LIBRARY} ${DTKWIDGET_LIBRARIES} ${DTKWIDGET_LIBS}) DtkWidget, DTKWIDGET 被链接进去了 xmake/xmake/modules/package/manager/cmake/find_package.lua Lines 84 to 87 in 3805911
当我去除一个 %s 和 name: cmakefile:print(" target_link_libraries(%s ${%s_LIBRARY} ${%s_LIBRARIES} ${%s_LIBS})",
testname, name, name, name)
cmakefile:print(" target_link_libraries(%s ${%s_LIBRARY} ${%s_LIBRARIES} ${%s_LIBS})",
testname, name:upper(), name:upper(), name:upper()) 就编译成功了 {
links = {
"dtkwidget",
"dtkcore",
"dtkgui"
},
defines = {
"DSG_DATA_DIR"
},
includedirs = {
"/usr/include/libdtk-5.5.30/DCore",
"/usr/include/libdtk-5.5.22/DGui",
"/usr/include/libdtk-5.5.21/DWidget"
}
} |
当初大小写 link 都加进去,也是因为 有些包的 links 要么在这些的 var 里,要么在大写的 var 里,无法精准判断,只能全加进去才能提取到 这块要改需要花点时间,等后面几天有空了 我再改下 |
ok, 感谢了 |
你两个都去了,还是就去掉了一个 大写的? |
两个都去了, DtkWidget只是包名, 只有dtkwidget需要链接 |
两个都去了 就没有任何 target_link_libraries 了,为啥还能解析到 links
|
我调一下cmake |
他是从 DtkWidget_LIBRARIES 出现的 dtkwidget;dtkcore;dtkgui;dtkcore |
你不是两行的 target_link_libraries 都去了么,那应该 DtkWidget_LIBRARIES 也没了吧,为啥还能取到? 还是你这只是删了 一行 大写的?
|
删了一个name参数还有一个name:upper |
如果你保留的是 upper 的,不是应该取的 DTKWIDGET_LIBRARIES 里面的么 |
改成这样 cmakefile:print(" target_link_libraries(%s ${%s_LIBRARY} ${%s_LIBRARIES} ${%s_LIBS})",
testname, name, name, name)
cmakefile:print(" target_link_libraries(%s ${%s_LIBRARY} ${%s_LIBRARIES} ${%s_LIBS})",
testname, name:upper(), name:upper(), name:upper()) |
哦,明白了,你删了一个 |
辛苦了,我试试 |
刚 push ,再试下 |
成功了 {
includedirs = {
"/usr/include/libdtk-5.5.30/DCore",
"/usr/include/libdtk-5.5.22/DGui",
"/usr/include/libdtk-5.5.21/DWidget"
},
defines = {
"DSG_DATA_DIR"
},
links = {
"dtkwidget",
"dtkcore",
"dtkgui"
}
} 辛苦了 |
Xmake 版本
2.6.8 dev
操作系统版本和架构
Deepin 20.6
描述问题
add_requires 结果如下
DtkWidget
{
defines = {
"DSG_DATA_DIR"
},
includedirs = {
"/usr/include/libdtk-5.5.30/DCore",
"/usr/include/libdtk-5.5.22/DGui",
"/usr/include/libdtk-5.5.21/DWidget"
}
并没有找到linkdir /usr/lib/x86_64-linux-gnu 和 libdtkwidget.so, libdtkgui.so 和 libdtkcore.so
期待的结果
希望能找到.so文件的路径和具体.so文件
工程配置
add_rules("mode.debug", "mode.release")
add_requires("cmake::DtkWidget", { system = true })
target("xmake-dtk")
add_rules("qt.widgetapp")
add_headerfiles("src/.h")
add_files("src/.cpp")
add_files("src/mainwindow.ui")
add_files("src/mainwindow.h")
add_packages("cmake::DtkWidget")
如果添加, 则可以顺利编译
add_linkdirs("/usr/lib/x86_64-linux-gnu")
add_links("dtkcore", "dtkgui", "dtkwidget")
附加信息和错误日志
checking for platform ... linux
checking for architecture ... x86_64
checking for gcc ... /usr/bin/gcc
checkinfo: cannot runv(dmd --version), No such file or directory
checking for dmd ... no checkinfo: cannot runv(ldc2 --version), No such file or directory checking for ldc2 ... no
checkinfo: cannot runv(gdc --version), No such file or directory
checking for gdc ... no
checkinfo: cannot runv(zig version), No such file or directory checking for zig ... no
checkinfo: cannot runv(zig version), No such file or directory checking for zig ... no
checking for unzip ... /usr/bin/unzip checking for git ... /usr/bin/git
checking for gzip ... /usr/bin/gzip checking for tar ... /usr/bin/tar
checking for ping ... /usr/bin/ping pinging for the host(gitlab.com) ... 15 ms
pinging for the host(gitee.com) ... 364 ms
pinging for the host(github.com) ... 65535 ms
finding DtkWidget from cmake ..
checking for cmake ... /usr/bin/cmake
DtkWidget
/usr/bin/cmake /dev/shm/.xmake1000/220711/_6B5F72F117D2483088BE2A8BC5A4F150.dir
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /dev/shm/.xmake1000/220711/_6B5F72F117D2483088BE2A8BC5A4F150.dir
CMAKE generated file: DO NOT EDIT!
Generated by "Unix Makefiles" Generator, CMake Version 3.22
compile CXX with /usr/bin/c++
CXX_DEFINES = -DDSG_DATA_DIR=/usr/local/share/dsg
CXX_INCLUDES = -I/usr/include/libdtk-5.5.30/DCore -I/usr/include/libdtk-5.5.22/DGui -I/usr/include/libdtk-5.5.21/DWidget
CXX_FLAGS =
/usr/bin/c++ CMakeFiles/test_DtkWidget.dir/test.cpp.o -o test_DtkWidget -lDtkWidget -ldtkwidget -ldtkcore -ldtkgui -ldtkcore -lDTKWIDGET -ldtkgui -lDTKWIDGET
{
defines = {
"DSG_DATA_DIR"
},
includedirs = {
"/usr/include/libdtk-5.5.30/DCore",
"/usr/include/libdtk-5.5.22/DGui",
"/usr/include/libdtk-5.5.21/DWidget"
}
}
checking for cmake::DtkWidget ... DtkWidget
checking for qmake ... /usr/bin/qmake
checking for Qt SDK directory ... /usr
checking for Qt SDK version ... 5.15.3
[ 14%]: compiling.qt.ui src/mainwindow.ui
/usr/lib/qt5/bin/uic src/mainwindow.ui -o build/.gens/xmake-dtk/linux/x86_64/release/rules/qt/ui/ui_mainwindow.h
checking for gcc ... /usr/bin/gcc
checking for the c++ compiler (cxx) ... gcc
checking for /usr/bin/gcc ... ok
checking for flags (-fPIC) ... ok
stack traceback:
[C]: in function 'error'
[@programdir/core/base/os.lua:872]:
[@programdir/core/sandbox/modules/os.lua:257]: in function 'runv'
[@programdir/modules/core/tools/gcc.lua:374]:
[C]: in function 'xpcall'
[@programdir/core/base/utils.lua:280]:
[@programdir/actions/build/kinds/binary.lua:74]: in function 'callback'
[@programdir/modules/core/project/depend.lua:189]: in function 'on_changed'
[@programdir/actions/build/kinds/binary.lua:55]: in function '_do_link_target'
[@programdir/actions/build/kinds/binary.lua:102]:
[@programdir/actions/build/kinds/binary.lua:129]: in function '_link_target'
[@programdir/actions/build/kinds/binary.lua:157]: in function 'jobfunc'
[@programdir/modules/private/async/runjobs.lua:232]:
[C]: in function 'xpcall'
[@programdir/core/base/utils.lua:280]: in function 'trycall'
[@programdir/core/sandbox/modules/try.lua:121]: in function 'try'
[@programdir/modules/private/async/runjobs.lua:218]: in function 'cotask'
[@programdir/core/base/scheduler.lua:388]:
stack traceback:
[C]: in function 'error'
@programdir/core/base/os.lua:872: in function 'os.raiselevel'
(...tail calls...)
@programdir/modules/private/async/runjobs.lua:256: in field 'catch'
@programdir/core/sandbox/modules/try.lua:127: in global 'try'
@programdir/modules/private/async/runjobs.lua:218: in upvalue 'cotask'
@programdir/core/base/scheduler.lua:388: in function <@programdir/core/base/scheduler.lua:385>
The text was updated successfully, but these errors were encountered: