Closed EpicWink closed 4 years ago
We want to use CONFIG mode (FooConfig.cmake) not MODULE mode (FindFoo.cmake) - see find_package.
So instead of CMAKE_MODULE_PATH=/usr/share/cmake/Modules
could you please try setting CMAKE_PREFIX_PATH=/usr/share/cmake/Modules
?
If that does not work, then please try forcing CONFIG mode in CMakeLists.txt:
find_package( TBB COMPONENTS tbb CONFIG )
Actually, looking at the packages file list, I don't think that path is correct. We're looking for the path to the file TBBConfig.cmake
- this is probably generated on installation.
Let's reverse my suggestions - remove the CMAKE_MODULE_PATH
and change _findpackage to add CONFIG
first.
If that doesn't work, we need to find that TBBConfig.cmake
and add a CMAKE_PREFIX_PATH
.
On macOS it's in <brew>/lib/cmake/TBB
so it might be living in /usr/lib/cmake/TBB
? If so, try CMAKE_PREFIX_PATH=/usr/lib/cmake
.
find / -iname *tbb*
(click to expand)So all TBB CMake files (except the CGAL vendors) are in /usr/share/cmake/Modules
. Also, you'll note that I don't have any TBBConfig.cmake
, but I do have TBBBuild.cmake
and TBBMakeConfig.cmake
I'm working on generating and compiling with the added CONFIG
argument
There should be another directory with the TBBConfig.cmake file. /usr/lib/cmake/TBB
or /usr/share/lib/cmake/TBB
?
If you look at the list of files, it includes:
/usr/share/cmake/Modules/templates/TBBConfig.cmake.in
Which implies that it is generated on install.
If so, then forcing CONFIG should be able to find it. 🤞🏻 If not, then we need to use CMAKE_PREFIX_PATH
.
Ah - just saw your list of files. Sorry I missed the "expand" (it's early :-).
I'm not sure then. Without Linux installed, I'm just guessing based on what I see in the package and what I do with homebrew on macOS.
I suspect TBBMakeConfig.cmake
is the file that is generated, and is the one we're looking for.
I implemented your suggestion with adding the CONFIG
argument, and it works perfectly.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 42471b1..d680f33 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -162,7 +162,7 @@ endif()
# TBB (optional)
# Must come before CGAL so it can use TBB properly
if ( CCCORELIB_USE_TBB )
- find_package( TBB COMPONENTS tbb )
+ find_package( TBB COMPONENTS tbb CONFIG )
if ( TBB_FOUND )
target_link_libraries( CCCoreLib
Ah fantastic!
_findpackage runs through a whole bunch of optional names, so that's what's happening I suppose.
Alright - I'll fix it.
Thanks @EpicWink!
I'm trying to build CloudCompare with enabling TBB (setting
CCCORELIB_USE_TBB=ON
). Compilation completes successfully, but I'm unable to finish linking, getting undefined reference errors. Disabling building with TBB works fine, and then I'm able to use all features of CloudCompare.Details
Linker error output (click to expand)
``` [ 82%] Linking CXX executable CloudCompare /usr/bin/ld: CMakeFiles/CloudCompare.dir/ccContourExtractor.cpp.o: in function `FindNearestCandidate(unsigned int&, std::_List_iteratorReproduction
``` -- Found Intel TBB -- OpenMP found -- Found 3rd party plugin: ~/src/CloudCompare/plugins/3rdParty/MeshIO -- Found 3rd party plugin: ~/src/CloudCompare/plugins/3rdParty/qRDBIO -- Configuring done -- Generating done -- Build files have been written to: ~/src/CloudCompare/build -- Cache values ASSIMP_ASAN:BOOL=OFF ASSIMP_BIN_INSTALL_DIR:STRING=bin ASSIMP_BUILD_ARCHITECTURE:STRING= ASSIMP_BUILD_COMPILER:STRING= ASSIMP_BUILD_ZLIB:BOOL=OFF ASSIMP_DOUBLE_PRECISION:BOOL=OFF ASSIMP_INCLUDE_INSTALL_DIR:STRING=include ASSIMP_LIBRARY_SUFFIX:STRING= ASSIMP_LIB_INSTALL_DIR:STRING=lib ASSIMP_OPT_BUILD_PACKAGES:BOOL=OFF ASSIMP_PACKAGE_VERSION:STRING=0 ASSIMP_UBSAN:BOOL=OFF ASSIMP_WERROR:BOOL=OFF BUILD_FRAMEWORK:BOOL=OFF BUILD_TESTING:BOOL=OFF Boost_DEBUG:BOOL=OFF Boost_INCLUDE_DIR:PATH=/usr/include CCACHE_PROGRAM:FILEPATH=/usr/bin/ccache CCCORELIB_SCALAR_DOUBLE:BOOL=ON CCCORELIB_SHARED:BOOL=ON CCCORELIB_USE_CGAL:BOOL=OFF CCCORELIB_USE_QT_CONCURRENT:BOOL=ON CCCORELIB_USE_TBB:BOOL=ON CGAL_CTEST_DISPLAY_MEM_AND_TIME:BOOL=OFF CGAL_DEV_MODE:BOOL=OFF CGAL_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/CGAL CMAKE_AR:FILEPATH=/usr/bin/ar CMAKE_BUILD_TYPE:STRING=Release CMAKE_COLOR_MAKEFILE:BOOL=ON CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++ CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-9 CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-9 CMAKE_CXX_FLAGS:STRING= CMAKE_CXX_FLAGS_DEBUG:STRING=-g CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc CMAKE_C_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-9 CMAKE_C_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-9 CMAKE_C_FLAGS:STRING= CMAKE_C_FLAGS_DEBUG:STRING=-g CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG CMAKE_DEBUG_POSTFIX:STRING= CMAKE_EXE_LINKER_FLAGS:STRING= CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING= CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING= CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING= CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING= CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF CMAKE_INSTALL_BINDIR:PATH=bin CMAKE_INSTALL_DATADIR:PATH= CMAKE_INSTALL_DATAROOTDIR:PATH=share CMAKE_INSTALL_DOCDIR:PATH= CMAKE_INSTALL_INCLUDEDIR:PATH=include CMAKE_INSTALL_INFODIR:PATH= CMAKE_INSTALL_LIBDIR:PATH=lib CMAKE_INSTALL_LIBEXECDIR:PATH=libexec CMAKE_INSTALL_LOCALEDIR:PATH= CMAKE_INSTALL_LOCALSTATEDIR:PATH=var CMAKE_INSTALL_MANDIR:PATH= CMAKE_INSTALL_OLDINCLUDEDIR:PATH=/usr/include CMAKE_INSTALL_PREFIX:PATH=/usr/local CMAKE_INSTALL_RUNSTATEDIR:PATH= CMAKE_INSTALL_SBINDIR:PATH=sbin CMAKE_INSTALL_SHAREDSTATEDIR:PATH=com CMAKE_INSTALL_SYSCONFDIR:PATH=etc CMAKE_LINKER:FILEPATH=/usr/bin/ld CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make CMAKE_MODULE_LINKER_FLAGS:STRING= CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING= CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING= CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING= CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING= CMAKE_MODULE_PATH:STRING=/usr/share/cmake/Modules CMAKE_NM:FILEPATH=/usr/bin/nm CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib CMAKE_SHARED_LINKER_FLAGS:STRING= CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING= CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING= CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING= CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING= CMAKE_SKIP_INSTALL_RPATH:BOOL=NO CMAKE_SKIP_RPATH:BOOL=NO CMAKE_STATIC_LINKER_FLAGS:STRING= CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING= CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING= CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING= CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING= CMAKE_STRIP:FILEPATH=/usr/bin/strip CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE DXF_LIB_DIR:PATH=extern/dxflib EIGEN_ROOT_DIR:PATH=/usr/include/eigen3 FFMPEG_INCLUDE_DIR:PATH=/usr/include/x86_64-linux-gnu FFMPEG_LIBRARY_DIR:PATH=/usr/lib/x86_64-linux-gnu HUNTER_ENABLED:BOOL=OFF HUNTER_STATUS_DEBUG:BOOL=OFF HUNTER_STATUS_PRINT:BOOL=ON HUNTER_TLS_VERIFY:BOOL=ON IGNORE_GIT_HASH:BOOL=OFF INJECT_DEBUG_POSTFIX:BOOL=ON NANOFLANN_ROOT_DIR:PATH=~/src/CloudCompare/plugins/core/Standard/qHoughNormals/src/nanoflann OPTION_BUILD_CCVIEWER:BOOL=OFF OPTION_GL_QUAD_BUFFER_SUPPORT:BOOL=OFF OPTION_SUPPORT_3DCONNEXION_DEVICES:BOOL=OFF OPTION_SUPPORT_GAMEPADS:BOOL=OFF OPTION_USE_DXF_LIB:BOOL=ON OPTION_USE_GDAL:BOOL=OFF OPTION_USE_OCULUS_SDK:BOOL=OFF OPTION_USE_SHAPE_LIB:BOOL=ON OpenMP_CXX_FLAGS:STRING=-fopenmp OpenMP_CXX_LIB_NAMES:STRING=gomp;pthread OpenMP_C_FLAGS:STRING=-fopenmp OpenMP_C_LIB_NAMES:STRING=gomp;pthread OpenMP_gomp_LIBRARY:FILEPATH=/usr/lib/gcc/x86_64-linux-gnu/9/libgomp.so OpenMP_pthread_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpthread.so PKG_CONFIG_EXECUTABLE:FILEPATH=/usr/bin/pkg-config PLUGIN-3rdParty_MESH_IO:BOOL=OFF PLUGIN_EXAMPLE_GL:BOOL=OFF PLUGIN_EXAMPLE_IO:BOOL=OFF PLUGIN_EXAMPLE_STANDARD:BOOL=OFF PLUGIN_GL_QEDL:BOOL=OFF PLUGIN_GL_QSSAO:BOOL=OFF PLUGIN_IO_QADDITIONAL:BOOL=OFF PLUGIN_IO_QCORE:BOOL=ON PLUGIN_IO_QCSV_MATRIX:BOOL=OFF PLUGIN_IO_QE57:BOOL=ON PLUGIN_IO_QFBX:BOOL=OFF PLUGIN_IO_QPDAL:BOOL=OFF PLUGIN_IO_QPHOTOSCAN:BOOL=OFF PLUGIN_IO_QRDB:BOOL=OFF PLUGIN_STANDARD_QANIMATION:BOOL=ON PLUGIN_STANDARD_QBROOM:BOOL=OFF PLUGIN_STANDARD_QCANUPO:BOOL=OFF PLUGIN_STANDARD_QCOMPASS:BOOL=OFF PLUGIN_STANDARD_QCORK:BOOL=OFF PLUGIN_STANDARD_QCSF:BOOL=OFF PLUGIN_STANDARD_QFACETS:BOOL=OFF PLUGIN_STANDARD_QHOUGH_NORMALS:BOOL=ON PLUGIN_STANDARD_QHPR:BOOL=ON PLUGIN_STANDARD_QM3C2:BOOL=OFF PLUGIN_STANDARD_QPCL:BOOL=OFF PLUGIN_STANDARD_QPCV:BOOL=OFF PLUGIN_STANDARD_QPOISSON_RECON:BOOL=ON PLUGIN_STANDARD_QRANSAC_SD:BOOL=OFF PLUGIN_STANDARD_QSRA:BOOL=OFF POISSON_RECON_WITH_OPEN_MP:BOOL=ON QT5_ROOT_PATH:PATH=/usr/lib/x86_64-linux-gnu/qt5 Qt5Concurrent_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5Concurrent Qt5Core_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5Core Qt5Gui_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5Gui Qt5LinguistTools_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5LinguistTools Qt5OpenGLExtensions_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5OpenGLExtensions Qt5OpenGL_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5OpenGL Qt5PrintSupport_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5PrintSupport Qt5Svg_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5Svg Qt5Widgets_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5Widgets Qt5_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt5 RT_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/librt.so SHAPELIB_LIB_DIR:PATH=extern/shapelib SYSTEM_IRRXML:BOOL=ON TBB_DEBUG_LIBRARY:FILEPATH=TBB_DEBUG_LIBRARY-NOTFOUND TBB_DIR:PATH=TBB_DIR-NOTFOUND TBB_INCLUDE_DIR:PATH=/usr/include TBB_INCLUDE_DIRS:PATH=/usr/include TBB_INSTALL_DIR:PATH=/opt/intel/tbb;/usr/local/include;/usr/include TBB_LIBRARIES:PATH=optimized;/usr/lib/x86_64-linux-gnu/libtbb.so;debug;/usr/lib/x86_64-linux-gnu/libtbb.so;optimized;/usr/lib/x86_64-linux-gnu/libtbbmalloc.so;debug;/usr/lib/x86_64-linux-gnu/libtbbmalloc.so;general;-pthread TBB_LIBRARY_DIRS:PATH=/usr/lib/x86_64-linux-gnu TBB_MALLOCPROXY_DEBUG_LIBRARY:FILEPATH=TBB_MALLOCPROXY_DEBUG_LIBRARY-NOTFOUND TBB_MALLOCPROXY_RELEASE_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libtbbmalloc_proxy.so TBB_MALLOC_DEBUG_LIBRARY:FILEPATH=TBB_MALLOC_DEBUG_LIBRARY-NOTFOUND TBB_MALLOC_RELEASE_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libtbbmalloc.so TBB_RELEASE_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libtbb.so WITH_FFMPEG_SUPPORT:BOOL=ON XercesC_INCLUDE_DIR:PATH=/usr/include XercesC_LIBRARY_DEBUG:FILEPATH=XercesC_LIBRARY_DEBUG-NOTFOUND XercesC_LIBRARY_RELEASE:FILEPATH=/usr/lib/x86_64-linux-gnu/libxerces-c.so ZLIB_INCLUDE_DIR:PATH=/usr/include ZLIB_LIBRARY_DBG:FILEPATH=/usr/lib/x86_64-linux-gnu/libz.so ZLIB_LIBRARY_REL:FILEPATH=/usr/lib/x86_64-linux-gnu/libz.so pkgcfg_lib_UNZIP_minizip:FILEPATH=/usr/lib/x86_64-linux-gnu/libminizip.so ``` *Home directory collapsed to `~`*cmake ../ -LA
(click to expand)Checkout master of CloudCompare repo, then build with the above configuration (I used ccmake)
Expected behaviour
Successful build
Environment