Skip to content
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 fails to find debug TBB libraries on Windows. #38

Closed
zomgrolf opened this issue Aug 14, 2019 · 3 comments
Closed

CMake fails to find debug TBB libraries on Windows. #38

zomgrolf opened this issue Aug 14, 2019 · 3 comments

Comments

@zomgrolf
Copy link

I hit this when trying to build a debug version of OIDN on Windows: debug versions of TBB use the _debug suffix, which seemingly confuses the TBB.cmake script in your fork of MKL-DNN.

@atafra
Copy link
Collaborator

atafra commented Aug 15, 2019

I can't reproduce this issue, the build succeeds. Could you please share the exact error message, compiler, CMake, and TBB versions?

@zomgrolf
Copy link
Author

My apologies, I didn't expect you'd try to reproduce it:

CMake version: 3.14.3
Visual Studio 2017: 15.9.15
TBB version: 2019_U6

The key difference here is that I'm building OIDN against TBB that comes with a binary build of Pixar's USD -- it doesn't follow the same layout as the binary release of TBB, it simply puts the .dll in the bin subdirectory, import libraries in the lib subdirectory and the entire directory structure for header files in its include subdirectory. Simply pointing TBBROOT to the USD directory almost works (it does work flawlessly with release builds of USD), but somehow gets confused when trying to configure the debug build (gets the directories right, but eventually fails trying to find the files, I suspect it hits a slightly different path in the cmake script?):

cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="c:/workdir/pub/EXTERNAL/OIDN/master" -DTBB_ROOT="c:/workdir/pub/EXTERNAL/USD/19.05/Debug" -DCMAKE_INSTALL_LIBDIR=c:/workdir/pub/EXTERNAL/OIDN/master/lib/Debug -DCMAKE_INSTALL_BINDIR=c:/workdir/pub/EXTERNAL/OIDN/master/bin/Debug -DOIDN_STATIC_LIB=OFF
-- The CXX compiler identification is MSVC 19.16.27032.1
-- Check for working CXX compiler: c:/apps/MVS15/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe
-- Check for working CXX compiler: c:/apps/MVS15/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The C compiler identification is MSVC 19.16.27032.1
-- Check for working C compiler: c:/apps/MVS15/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe
-- Check for working C compiler: c:/apps/MVS15/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- This is a product build
-- Could NOT find TBB (missing: TBB_LIBRARY TBB_LIBRARY_MALLOC)
-- Found Git: C:/tools/git/cmd/git.exe (found version "2.21.0.windows.1")
-- Could NOT find TBB (missing: TBB_LIBRARY TBB_LIBRARY_MALLOC)
-- Found PythonInterp: C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python37_64/python.exe (found version "3.7.3")

And here's an example of changes I've made to make it work on my machine:

diff --git a/TBB.cmake b/TBB.cmake
index c3be583..0327964 100644
--- a/TBB.cmake
+++ b/TBB.cmake
@@ -82,7 +82,18 @@ if(WIN32)
         set(TBB_LIBRARY TBB_LIBRARY-NOTFOUND)
         set(TBB_LIBRARY_MALLOC TBB_LIBRARY_MALLOC-NOTFOUND)
         find_path(TBB_INCLUDE_DIR tbb/task_scheduler_init.h PATHS ${TBB_ROOT}/include NO_DEFAULT_PATH)
-        find_path(TBB_BIN_DIR tbb.dll
+
+        if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+            set(TBB_DLL_NAME tbb_debug.dll)
+            set(TBB_NAME tbb_debug)
+            set(TBB_MALLOC_NAME tbbmalloc_debug)
+        else()
+            set(TBB_DLL_NAME tbb.dll)
+            set(TBB_NAME tbb)
+            set(TBB_MALLOC_NAME tbbmalloc)
+        endif()
+
+        find_path(TBB_BIN_DIR ${TBB_DLL_NAME}
             HINTS
                 ${TBB_ROOT}/bin/${TBB_ARCH}/${TBB_VCVER}
                 ${TBB_ROOT}/bin
@@ -91,8 +102,8 @@ if(WIN32)
             NO_DEFAULT_PATH
         )
         set(TBB_LIB_DIR ${TBB_ROOT}/lib/${TBB_ARCH}/${TBB_VCVER})
-        find_library(TBB_LIBRARY tbb PATHS ${TBB_LIB_DIR} ${TBB_ROOT}/lib NO_DEFAULT_PATH)
-        find_library(TBB_LIBRARY_MALLOC tbbmalloc PATHS ${TBB_LIB_DIR} ${TBB_ROOT}/lib NO_DEFAULT_PATH)
+        find_library(TBB_LIBRARY ${TBB_NAME} PATHS ${TBB_LIB_DIR} ${TBB_ROOT}/lib NO_DEFAULT_PATH)
+        find_library(TBB_LIBRARY_MALLOC ${TBB_MALLOC_NAME} PATHS ${TBB_LIB_DIR} ${TBB_ROOT}/lib NO_DEFAULT_PATH)
     endif()
 
 else()

If I use the binary release package (or use vcpkg + cmake toolchain file) it all works perfectly.

@davidak
Copy link

davidak commented Feb 17, 2023

This is how we fixed the issue on NixOS Linux: NixOS/nixpkgs#216844

@atafra atafra closed this as completed May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants