使用CMAKE FIND_PACKAGE模块模式时,如何将特定安装的内容包括/LIB路径?
请注意,此问题不是要在模块模式下或在配置模式下的openmpconfig.cmake的位置进行findopenmp.cmake的搜索路径,而是在我们已经使用的openMP安装路径时。模块模式。
if (USE_OPENMP_WITH_TSAN)
add_definitions("-DUSE_OPENMP")
find_package(OpenMP PATHS "/root/openmp-with-tsan" REQUIRED)
endif ()
当然无效,我从
find_package considered the following locations for the Config module:
/usr/local/OpenMPConfig.cmake
/usr/local/openmp-config.cmake
/usr/OpenMPConfig.cmake
/usr/openmp-config.cmake
/OpenMPConfig.cmake
/openmp-config.cmake
/usr/local/lib/python3.6/dist-packages/cmake/data/OpenMPConfig.cmake
/usr/local/lib/python3.6/dist-packages/cmake/data/openmp-config.cmake
/opt/OpenMPConfig.cmake
/opt/openmp-config.cmake
/root/openmp-with-tsan/OpenMPConfig.cmake
/root/openmp-with-tsan/openmp-config.cmake
The file was not found.
Cmake确实提供了a findopenmp.cmake 用于模块模式搜索。但是,看来在我的计算机中,只会寻找这些路径:
CMake Debug Log at /usr/local/lib/python3.6/dist-packages/cmake/data/share/cmake-3.22/Modules/FindOpenMP.cmake:259 (find_library):
find_library called with the following settings:
VAR: OpenMP_omp_LIBRARY
NAMES: "omp"
Documentation: Path to the omp library for OpenMP
Framework
Only Search Frameworks: 0
Search Frameworks Last: 0
Search Frameworks First: 0
AppBundle
Only Search AppBundle: 0
Search AppBundle Last: 0
Search AppBundle First: 0
NO_DEFAULT_PATH Enabled
find_library considered the following locations:
/usr/lib/gcc/x86_64-linux-gnu/8/(lib)omp(\.so|\.a)
/usr/lib/x86_64-linux-gnu/(lib)omp(\.so|\.a)
/lib/x86_64-linux-gnu/(lib)omp(\.so|\.a)
/lib64/(lib)omp(\.so|\.a)
/usr/lib/(lib)omp(\.so|\.a)
/usr/lib/llvm-12/lib/(lib)omp(\.so|\.a)
/lib/(lib)omp(\.so|\.a)
The item was not found.
显然,不包括/root/oblemp-with-tsan
。
因此,我的问题是,是否有其他特定于find_package模块模式搜索的精确包含/lib安装路径?
我使用的工具链文件:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_C_COMPILER /usr/bin/clang-12)
set(CMAKE_CXX_COMPILER /usr/bin/clang++-12)
set(CMAKE_CXX_FLAGS_INIT "-fsanitize=thread -fno-omit-frame-pointer -g")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-fsanitize=thread")
Please be noticed that this question is not about to specific the search paths of FindOpenMP.cmake in module mode or the locations of OpenMPConfig.cmake in config mode, but to specific the exactly openmp installed path when we've already using the module mode.
I've built a libomp from source by the LLVM-project. And i still want to use the gcc shipped default omp in some of my program while using this build-from-source libomp in other specificed program. So i install the build-from-source omp in path like /root/openmp-with-tsan
. In the project's CMakeLists.txt, switch the libomp implementation like:
if (USE_OPENMP_WITH_TSAN)
add_definitions("-DUSE_OPENMP")
find_package(OpenMP PATHS "/root/openmp-with-tsan" REQUIRED)
endif ()
Of course, it didn't work, i've learned from the find_package documentation page that the usage of PATHS
means that i am using full signature, so config mode is applied. Since the installed build-from-source openmp didn't provide a OpenMPConfig.cmake in the corresponding path, the search fail.
find_package considered the following locations for the Config module:
/usr/local/OpenMPConfig.cmake
/usr/local/openmp-config.cmake
/usr/OpenMPConfig.cmake
/usr/openmp-config.cmake
/OpenMPConfig.cmake
/openmp-config.cmake
/usr/local/lib/python3.6/dist-packages/cmake/data/OpenMPConfig.cmake
/usr/local/lib/python3.6/dist-packages/cmake/data/openmp-config.cmake
/opt/OpenMPConfig.cmake
/opt/openmp-config.cmake
/root/openmp-with-tsan/OpenMPConfig.cmake
/root/openmp-with-tsan/openmp-config.cmake
The file was not found.
Cmake did provide a FindOpenMP.cmake for module mode search. However, it seems that in my machine, it will only look for these paths:
CMake Debug Log at /usr/local/lib/python3.6/dist-packages/cmake/data/share/cmake-3.22/Modules/FindOpenMP.cmake:259 (find_library):
find_library called with the following settings:
VAR: OpenMP_omp_LIBRARY
NAMES: "omp"
Documentation: Path to the omp library for OpenMP
Framework
Only Search Frameworks: 0
Search Frameworks Last: 0
Search Frameworks First: 0
AppBundle
Only Search AppBundle: 0
Search AppBundle Last: 0
Search AppBundle First: 0
NO_DEFAULT_PATH Enabled
find_library considered the following locations:
/usr/lib/gcc/x86_64-linux-gnu/8/(lib)omp(\.so|\.a)
/usr/lib/x86_64-linux-gnu/(lib)omp(\.so|\.a)
/lib/x86_64-linux-gnu/(lib)omp(\.so|\.a)
/lib64/(lib)omp(\.so|\.a)
/usr/lib/(lib)omp(\.so|\.a)
/usr/lib/llvm-12/lib/(lib)omp(\.so|\.a)
/lib/(lib)omp(\.so|\.a)
The item was not found.
Obviously, the /root/openmp-with-tsan
is not included.
So my question is, is there anyway to specific the exactly include/lib installation path for find_package module mode search?
The toolchain file that i used:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_C_COMPILER /usr/bin/clang-12)
set(CMAKE_CXX_COMPILER /usr/bin/clang++-12)
set(CMAKE_CXX_FLAGS_INIT "-fsanitize=thread -fno-omit-frame-pointer -g")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-fsanitize=thread")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论