-DENABLE_TBB=1 is an artifact and only appended for backwards compatibility. Some older modules used a #cmakedefine HAVE_TBB ENABLE_TBB. I guess we can drop the whole ENABLE_TBB. The other parameter is use to enforce C++11 mode of TBB.
Both parameters are added regardless of whether TBB was found or not, as they don't hurt in that case. But it is true that this is surprising.
The TBB find module is a bit broken. I already proposed to replace it with something simpler, cleaner and more stable. I can send you a quick replacement, if you want to use TBB and will make a MR for dune-common in the near future.
Then, the easiest solution is to point TBB_Dir to the directory containing the cmake-config file. The FindTBB.cmake macro is just a fall-back solution in case of very old TBB implementation.
(to be called from within you dune-module directory,
or using dunecontrol
dunecontrol --module=dune-module cmake -DTBB_Dir=[path/to/tbb/cmake/config]dunecontrol --module=dune-module make
where dune-module is the module you currently try to configure. Note, the cmake flags can also be stored into a configuration file for reuse, e.g., a file config.opts containing
We use cmake to search for the package TBB by calling find_package(TBB ...). This searches for the file TBBConfig.cmake or tbb-config.cmake, inspecting some standard directories, but also the directory TBB_Dir. Additionally, if no such file is found, it searches for a file FindTBB.cmake that we provide. It is a fallback searching manually for all the TBB include directory, library and flags. In order to work successfully, it needs some input from the user, like e.g., the information where to find the TBB installation.
-- Library dir: TBB_LIBRARY_DIR-NOTFOUND-- Performing Test TBB_COMPILE_TEST-- Performing Test TBB_COMPILE_TEST - Failed-- Could NOT find TBB (missing: TBB_INCLUDE_DIRS TBB_COMPILE_TEST)...... Manually-specified variables were not used by the project: BOOST_PYTHON_SUFFIX CMAKE_C_FLAGS_DEBUG CMAKE_MODULE_LINKER_FLAGS TBB_Dir
Ok, I see. The TBB_Dir variable is not used. The problem is that the FindTBB.cmake is preferred over the tbb-config.cmake file, unfortunately. As I said, the current TBB configuration is a bit broken. If you want to try it out, you could change one line in dune-common/cmake/modules/DuneCommonMacros.cmake. There is the line 41:
As @christi explained, TBB is currently only rarely used in the dune core modules, if at all. So, you don't need it to configure and compile dune. If you want to use it in your own module, you could simply add a line like the above in your cmake/modules/MyDuneModuleMacros.cmake file.
Now it is found with -DTBB_INCLUDE_DIR=${LOCALBASE}/include -DTBB_LIBRARIES=${LOCALBASE}/lib/libtbb.so:
-- Library dir: TBB_LIBRARY_DIR-NOTFOUND-- Performing Test TBB_COMPILE_TEST-- Performing Test TBB_COMPILE_TEST - Success-- Found TBB: /usr/local/include found components: allocator missing components: cpf-- defaulting TBB_CACHE_ALIGNED_ALLOCATOR_ALIGNMENT to 128
@simon.praetorius does it make sense to change the cmake tests (right now), or should we wait for the bigger cleanup?
Is there any way for the use to get the necessary options without reading the code? In the old autotools times, the generated configure featured a --help with all information on the parameters for the tests.
I will make a cleanup of this module. Then, I will add the necessary information how to configure for a local TBB installation in the documentation of that module. Currently this information is somehow missing or miss-leading or I just missed it.
@yuri.vic Would you mind testing the fix for the broken TBB cmake configuration in the branch feature/cleanup_find_tbb? I have tested myself using recent oneTBB but also a system installation. In case the TBB is installed in system default locations, it should be found automatically. Otherwise, set the TBB_DIR variable to point to the directory containing the TBBConfig.cmake. This is typically something like <prefix>/lib/cmake/TBB/ with <prefix> your installation prefix set in the TBB cmake configuration.
Now, the ENABLE_TBB=1 flag is only set if it is actually found.