FindTBB.cmake 4.84 KB
Newer Older
schultezub's avatar
schultezub committed
1
2
3
4
5
6
7
8
# Try to find TBB library and include path. Once done this will define:
# TBB_FOUND
# TBB_DEFINITIONS
# TBB_INCLUDE_DIR
# TBB_LIBRARY (containing both debug and release libraries on win32)
# TBB_LICENSE_FILE

IF (WIN32)
9
    IF(NOT TBB_ROOT)
10
11
12
13
14
15
16
17
        # check environment variables
        IF(NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "")
            SET(TbbDirectory $ENV{TBB_INSTALL_DIR})
        ENDIF(NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "")
        
        # check default install directory
        set(_TbbSeachPaths "C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB" "${CampvisHome}/ext/tbb")
        FIND_PATH( 
18
            TBB_ROOT 
19
20
21
22
            NAMES include/tbb/tbb.h
            PATHS ${_TbbSeachPaths}
            DOC "Intel TBB directory with includes, libs and dlls (i.e. where you extracted the binary distribution from threadingbuildingblocks.org.)"
        )
23
24
25
26
        
        IF(NOT TBB_ROOT)
            MESSAGE(FATAL_ERROR "Could not find Intel TBB. Please set TBB_ROOT to the Intel TBB directory with includes, libs and dlls (i.e. where you extracted the binary distribution from threadingbuildingblocks.org.)")
        ENDIF()
27
    ENDIF()
28
29
    
    SET(TbbDirectory ${TBB_ROOT})
30
31
   
    IF(CAMPVIS_MSVC2010)
schultezub's avatar
schultezub committed
32
        SET(TbbCompilerDirectory "vc10")
33
34
    ELSEIF(CAMPVIS_MSVC11)
        SET(TbbCompilerDirectory "vc11")
35
36
    ELSEIF(CAMPVIS_MSVC12)
        SET(TbbCompilerDirectory "vc12")
schultezub's avatar
schultezub committed
37
38
    ELSE()
        MESSAGE(WARNING "Compiler not supported by makefile, you might be able to fix that...")
39
40
41
42
43
44
45
46
47
    ENDIF(CAMPVIS_MSVC2010)
    
    FIND_PATH( 
        TBB_INCLUDE_DIR 
        NAMES tbb/tbb.h
        PATHS ${TbbDirectory}/include
        DOC "Intel TBB include directory (i.e. where tbb/tbb.h is)"
    )
    
schultezub's avatar
schultezub committed
48
    # set debug and release library
schultezub's avatar
schultezub committed
49
    IF(CAMPVIS_WIN32)
50
        SET(TbbPlatformDirectory "ia32")
schultezub's avatar
schultezub committed
51
    ELSEIF(CAMPVIS_WIN64)
52
        SET(TbbPlatformDirectory "intel64")
schultezub's avatar
schultezub committed
53
    ELSE()
schultezub's avatar
schultezub committed
54
55
        MESSAGE(FATAL_ERROR "Neither CAMPVIS_WIN32 nor CAMPVIS_WIN64 defined!")
    ENDIF(CAMPVIS_WIN32)
schultezub's avatar
schultezub committed
56

57
58
59
60
61
62
63
    SET(TBB_LIBRARY_DEBUG      "${TbbDirectory}/lib/${TbbPlatformDirectory}/${TbbCompilerDirectory}/tbb_debug.lib")
    SET(TBB_DLL_DEBUG          "${TbbDirectory}/bin/${TbbPlatformDirectory}/${TbbCompilerDirectory}/tbb_debug.dll")
    SET(TBB_PDB_DEBUG          "${TbbDirectory}/bin/${TbbPlatformDirectory}/${TbbCompilerDirectory}/tbb_debug.pdb")
    SET(TBB_LIBRARY_RELEASE    "${TbbDirectory}/lib/${TbbPlatformDirectory}/${TbbCompilerDirectory}/tbb.lib")
    SET(TBB_DLL_RELEASE        "${TbbDirectory}/bin/${TbbPlatformDirectory}/${TbbCompilerDirectory}/tbb.dll")
    SET(TBB_PDB_RELEASE        "${TbbDirectory}/bin/${TbbPlatformDirectory}/${TbbCompilerDirectory}/tbb.pdb")
    IF(TBB_LIBRARY_DEBUG AND TBB_LIBRARY_RELEASE)
schultezub's avatar
schultezub committed
64
65
66
        SET(TBB_LIBRARY debug ${TBB_LIBRARY_DEBUG} optimized ${TBB_LIBRARY_RELEASE})
    ENDIF(TBB_LIBRARY_DEBUG AND TBB_LIBRARY_RELEASE)
    
67
68
69
70
71
72
73
74
75
76
77

    SET(TBB_MALLOC_LIBRARY_DEBUG      "${TbbDirectory}/lib/${TbbPlatformDirectory}/${TbbCompilerDirectory}/tbbmalloc_debug.lib")
    SET(TBB_MALLOC_DLL_DEBUG          "${TbbDirectory}/bin/${TbbPlatformDirectory}/${TbbCompilerDirectory}/tbbmalloc_debug.dll")
    SET(TBB_MALLOC_PDB_DEBUG          "${TbbDirectory}/bin/${TbbPlatformDirectory}/${TbbCompilerDirectory}/tbbmalloc_debug.pdb")
    SET(TBB_MALLOC_LIBRARY_RELEASE    "${TbbDirectory}/lib/${TbbPlatformDirectory}/${TbbCompilerDirectory}/tbbmalloc.lib")
    SET(TBB_MALLOC_DLL_RELEASE        "${TbbDirectory}/bin/${TbbPlatformDirectory}/${TbbCompilerDirectory}/tbbmalloc.dll")
    SET(TBB_MALLOC_PDB_RELEASE        "${TbbDirectory}/bin/${TbbPlatformDirectory}/${TbbCompilerDirectory}/tbbmalloc.pdb")
    IF(TBB_MALLOC_LIBRARY_DEBUG AND TBB_MALLOC_LIBRARY_RELEASE)
        SET(TBB_MALLOC_LIBRARY debug ${TBB_MALLOC_LIBRARY_DEBUG} optimized ${TBB_MALLOC_LIBRARY_RELEASE})
    ENDIF(TBB_MALLOC_LIBRARY_DEBUG AND TBB_MALLOC_LIBRARY_RELEASE)
    
schultezub's avatar
schultezub committed
78
    SET(TBB_LICENSE_FILE "${TbbDirectory}/COPYING")
schultezub's avatar
schultezub committed
79
80
81
82
83
    
ELSE (WIN32)
    FIND_PATH( 
        TBB_INCLUDE_DIR 
        NAMES tbb/mutex.h
schultezub's avatar
schultezub committed
84
        PATHS ${TbbDirectory}/include /usr/include /usr/local/include /sw/include /opt/local/include
schultezub's avatar
schultezub committed
85
86
87
88
        DOC "The directory where tbb/*.h resides"
    )
    FIND_LIBRARY(
        TBB_LIBRARY
89
        NAMES libtbb.so
schultezub's avatar
schultezub committed
90
        PATHS ${TbbDirectory}/lib /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib /sw/lib /opt/local/lib
schultezub's avatar
schultezub committed
91
92
        DOC "The TBB library"
    )
93
94
95
96
97
98
    FIND_LIBRARY(
        TBB_MALLOC_LIBRARY
        NAMES libtbbmalloc.so
        PATHS ${TbbDirectory}/lib /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib /sw/lib /opt/local/lib
        DOC "The TBB malloc library"
    )
schultezub's avatar
schultezub committed
99
100
101
102
103
104
105
106
ENDIF (WIN32)

IF(TBB_INCLUDE_DIR AND TBB_LIBRARY)
    SET(TBB_FOUND TRUE)
ELSE(TBB_INCLUDE_DIR AND TBB_LIBRARY)
    SET(TBB_FOUND FALSE)
ENDIF(TBB_INCLUDE_DIR AND TBB_LIBRARY)

schultezub's avatar
schultezub committed
107
108
UNSET(TbbDirectory)
MARK_AS_ADVANCED(TbbDirectory TbbDirectory TBB_INCLUDE_DIR TBB_LIBRARY TBB_LIBRARY_DEBUG TBB_LIBRARY_RELEASE TBB_DLL_DEBUG TBB_DLL_RELEASE)