-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
自定义cmake查找路径时,找不到对应的cmake包 #5102
Comments
Title: When customizing the cmake search path, the corresponding cmake package cannot be found |
这个库很复杂,先试试用 xrepo 上的 abseil |
This library is very complex. Try using abseil on xrepo first. |
cmake::xxx 包,首先 cmake 本身的跟着 FindXXX 就很不可靠,要各种传参调整。。这块你只能自己调,可以先搞个 cmake 工程,直接去调通参数,再原样传进来。。。另外 xmake 内部目前的实现比较 hack,它需要解析提取获取到的 links 。。 所以,能不用就不要去用,尽可能用 xmake-repo 仓库的包。。如果非要用,自己调下 https://github.com/xmake-io/xmake/blob/master/xmake/modules/package/manager/cmake/find_package.lua |
感谢您的解答,那如果想在xmake项目中集成这个cmake仓库,这个支持components吗,比如说foo::a,foo::b.看了add_requires貌似没找到相关的API呢 |
cmake::xxx package, first of all, cmake itself is very unreliable with FindXXX, and requires various parameter adjustment. . You can only adjust this yourself. You can first create a cmake project, directly adjust the parameters, and then pass them in as they are. . . In addition, the current internal implementation of xmake is relatively hacky, and it needs to parse and extract the obtained links. . Therefore, don’t use it if you can’t use it, and use the packages from the xmake-repo warehouse as much as possible. . If you must use it, adjust it yourself https://github.com/xmake-io/xmake/blob/master/xmake/modules/package/manager/cmake/find_package.lua |
Thank you for your answer. If you want to integrate this cmake warehouse in the xmake project, does it support components, such as foo::a, foo::b. After looking at add_requires, it seems that I can't find the relevant API. |
支持,参考 sdl 那个包,文档不也有么 https://xmake.io/#/manual/package_dependencies?id=add-package-components |
Xmake 版本
v2.9.1+20240511
操作系统版本和架构
Linux b2c613d49b5d 5.4.241-1-tlinux4-0017.8 #1 SMP Fri Mar 15 12:14:37 CST 2024 x86_64 GNU/Linux
描述问题
在
xmake.lua
中添加cmake依赖执行xmake后,提示
但是在添加了
presets = {absl_DIR = "/workspace/cpp/3rd/lib/cmake/absl"}
xmake可以执行成功,但是链接的时候提示找不到对象,同时用xmake project -k cmakelists生成的cmakelists.txt文件中也没有链接absl的库
期待的结果
能够正确链接absl库
工程配置
absl的cmake配置如下
absl.tar.gz
附加信息和错误日志
xmake执行结果
checking for gcc ... /usr/bin/gcc
checking for unzip ... /usr/bin/unzip
checking for git ... /usr/local/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
finding absl from cmake ..
checking for cmake ... /usr/bin/cmake
finding it from the generated CMakeLists.txt:
cmake_minimum_required(VERSION 3.25.1)
project(find_package)
list(APPEND CMAKE_MODULE_PATH "/workspace/cpp/3rd/lib/cmake/absl")
find_package(absl REQUIRED )
if(absl_FOUND)
add_executable(test_absl test.cpp)
target_include_directories(test_absl PRIVATE absl_INCLUDE_DIR absl_INCLUDE_DIRS ABSL_INCLUDE_DIR ABSL_INCLUDE_DIRS)
target_include_directories(test_absl PRIVATE absl_CXX_INCLUDE_DIRS)
target_link_libraries(test_absl PRIVATE absl::base absl::strings absl::status absl::statusor absl::flat_hash_map)
endif(absl_FOUND)
/usr/bin/cmake /tmp/.xmake271055/240514/_B8CA1E0960DF4E3081E6F60394B39C60.dir
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.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
CMake Error at CMakeLists.txt:4 (find_package):
By not providing "Findabsl.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "absl", but
CMake did not find one.
Could not find a package configuration file provided by "absl" with any of
the following names:
Add the installation prefix of "absl" to CMAKE_PREFIX_PATH or set
"absl_DIR" to a directory containing one of the above files. If "absl"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/tmp/.xmake271055/240514/_B8CA1E0960DF4E3081E6F60394B39C60.dir/CMakeFiles/CMakeOutput.log".
checking for cmake::absl ... no
finding OpenSSL from cmake ..
finding it from the generated CMakeLists.txt:
cmake_minimum_required(VERSION 3.25.1)
project(find_package)
find_package(OpenSSL REQUIRED COMPONENTS Crypto)
if(OpenSSL_FOUND)
add_executable(test_OpenSSL test.cpp)
target_include_directories(test_OpenSSL PRIVATE OpenSSL_INCLUDE_DIR OpenSSL_INCLUDE_DIRS OPENSSL_INCLUDE_DIR OPENSSL_INCLUDE_DIRS)
target_include_directories(test_OpenSSL PRIVATE OpenSSL_CXX_INCLUDE_DIRS)
target_link_libraries(test_OpenSSL PRIVATE OpenSSL_LIBRARY OpenSSL_LIBRARIES OpenSSL_LIBS OPENSSL_LIBRARY OPENSSL_LIBRARIES OPENSSL_LIBS)
endif(OpenSSL_FOUND)
/usr/bin/cmake /tmp/.xmake271055/240514/_77EC808472554A208803F3986A0F6430.dir
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.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
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.0.11") found components: Crypto
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/.xmake271055/240514/_77EC808472554A208803F3986A0F6430.dir
finding includes from /tmp/.xmake271055/240514/_77EC808472554A208803F3986A0F6430.dir/CMakeFiles/test_OpenSSL.dir/flags.make
CMAKE generated file: DO NOT EDIT!
Generated by "Unix Makefiles" Generator, CMake Version 3.25
compile CXX with /usr/bin/c++
CXX_DEFINES =
CXX_INCLUDES =
CXX_FLAGS =
finding links from /tmp/.xmake271055/240514/_77EC808472554A208803F3986A0F6430.dir/CMakeFiles/test_OpenSSL.dir/link.txt
/usr/bin/c++ CMakeFiles/test_OpenSSL.dir/test.cpp.o -o test_OpenSSL /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/libcrypto.so
checking for cmake::OpenSSL ... OpenSSL
note: the following packages were not found on your system, try again after installing them:
-> cmake::absl latest
error: @programdir/core/main.lua:329: @programdir/core/sandbox/modules/import/core/base/task.lua:65: stack traceback:
[C]: in function 'error'
[@programdir/core/base/os.lua:984]:
[...modules/private/action/require/impl/install_packages.lua:754]:
[@programdir/modules/private/action/require/install.lua:85]:
[@programdir/actions/config/main.lua:387]:
[C]: in function 'xpcall'
[@programdir/core/base/utils.lua:275]:
[@programdir/core/base/task.lua:491]: in function 'run'
[@programdir/core/sandbox/modules/import/core/base/task.lua:63]: in function 'run'
[@programdir/actions/build/main.lua:191]:
[C]: in function 'xpcall'
[@programdir/core/base/utils.lua:275]:
[@programdir/core/base/task.lua:491]: in function 'run'
[@programdir/core/main.lua:327]: in function 'cotask'
[@programdir/core/base/scheduler.lua:406]:
stack traceback:
[C]: in function 'error'
@programdir/core/base/os.lua:973: in function 'base/os.raiselevel'
(...tail calls...)
@programdir/core/main.lua:329: in upvalue 'cotask'
@programdir/core/base/scheduler.lua:406: in function <@programdir/core/base/scheduler.lua:399>
The text was updated successfully, but these errors were encountered: