• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1############################################################################
2#   © 2012,2014 Advanced Micro Devices, Inc. All rights reserved.
3#
4#   Licensed under the Apache License, Version 2.0 (the "License");
5#   you may not use this file except in compliance with the License.
6#   You may obtain a copy of the License at
7#
8#       http://www.apache.org/licenses/LICENSE-2.0
9#
10#   Unless required by applicable law or agreed to in writing, software
11#   distributed under the License is distributed on an "AS IS" BASIS,
12#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13#   See the License for the specific language governing permissions and
14#   limitations under the License.
15
16############################################################################
17
18# Locate an BOLT implementation.
19#
20# Defines the following variables:
21#
22#   BOLT_FOUND - Found an Bolt imlementation
23#
24# Also defines the library variables below as normal
25# variables.
26#
27#   BOLT_LIBRARIES - These contain debug/optimized keywords when a debugging library is found
28#   BOLT_INCLUDE_DIRS - All relevant Bolt include directories
29#
30# Accepts the following variables as input:
31#
32#   BOLT_ROOT - (as a CMake or environment variable)
33#                The root directory of an BOLT installation
34#
35#   FIND_LIBRARY_USE_LIB64_PATHS - Global property that controls whether FindBOLT should search for
36#                              64bit or 32bit libs
37#
38#-----------------------
39# Example Usage:
40#
41#    find_package(BOLT REQUIRED)
42#    include_directories(${BOLT_INCLUDE_DIRS})
43#
44#    add_executable(foo foo.cc)
45#    target_link_libraries(foo ${BOLT_LIBRARIES})
46#
47#-----------------------
48
49# This module helps to use BOLT_FIND_COMPONENTS, BOLT_FIND_REQUIRED, BOLT_FIND_QUIETLY
50include( FindPackageHandleStandardArgs )
51
52# Search for 64bit libs if FIND_LIBRARY_USE_LIB64_PATHS is set to true in the global environment, 32bit libs else
53get_property( LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS )
54
55# Debug print statements
56#message( "BOLT_LIBRARY_PATH_SUFFIXES: ${BOLT_LIBRARY_PATH_SUFFIXES}" )
57#message( "ENV{BOLT_ROOT}: $ENV{BOLT_ROOT}" )
58#message( "BOLT_FIND_COMPONENTS: ${BOLT_FIND_COMPONENTS}" )
59#message( "BOLT_FIND_REQUIRED: ${BOLT_FIND_REQUIRED}" )
60
61# Set the component to find if the user does not specify explicitely
62if( NOT BOLT_FIND_COMPONENTS )
63    set( BOLT_FIND_COMPONENTS CL )
64endif( )
65if(WIN32)
66if( MSVC_VERSION VERSION_LESS 1600 )
67    set( myMSVCVer "vc90" )
68elseif( MSVC_VERSION VERSION_LESS 1700 )
69    set( myMSVCVer "vc100" )
70elseif( MSVC_VERSION VERSION_LESS 1800 )
71    set( myMSVCVer "vc110" )
72else()
73    set( myMSVCVer "vc120" )
74endif( )
75else()
76    set( myMSVCVer "gcc" )
77endif()
78
79if(WIN32)
80 set( BoltLibName "clBolt.runtime.${myMSVCVer}")
81 set( LIB_EXT "lib")
82else()
83 set( BoltLibName "libclBolt.runtime.${myMSVCVer}")
84 set( LIB_EXT "a")
85endif()
86
87# Eventually, Bolt may support multiple backends, but for now it only supports CL
88list( FIND BOLT_FIND_COMPONENTS CL find_CL )
89if( NOT find_CL EQUAL -1 )
90    set( BOLT_LIBNAME_BASE ${BoltLibName} )
91endif( )
92
93if( NOT find_CL EQUAL -1 )
94    # Find and set the location of main BOLT static lib file
95    find_library( BOLT_LIBRARY_STATIC_RELEASE
96        NAMES ${BOLT_LIBNAME_BASE}.${LIB_EXT}
97        HINTS
98            ${BOLT_ROOT}
99            ENV BOLT_ROOT
100        DOC "BOLT static library path"
101        PATH_SUFFIXES lib
102    )
103    mark_as_advanced( BOLT_LIBRARY_STATIC_RELEASE )
104
105    # Find and set the location of main BOLT static lib file
106    find_library( BOLT_LIBRARY_STATIC_DEBUG
107        NAMES ${BOLT_LIBNAME_BASE}.debug.${LIB_EXT}
108        HINTS
109            ${BOLT_ROOT}
110            ENV BOLT_ROOT
111        DOC "BOLT static library path"
112        PATH_SUFFIXES lib
113    )
114    mark_as_advanced( BOLT_LIBRARY_STATIC_DEBUG )
115
116    if( BOLT_LIBRARY_STATIC_RELEASE )
117        set( BOLT_LIBRARY_STATIC optimized ${BOLT_LIBRARY_STATIC_RELEASE} )
118    else( )
119        set( BOLT_LIBRARY_STATIC "" )
120        message( "${BOLT_LIBNAME_BASE}.${LIB_EXT}: Release static bolt library not found" )
121    endif( )
122
123    if( BOLT_LIBRARY_STATIC_DEBUG )
124        set( BOLT_LIBRARY_STATIC ${BOLT_LIBRARY_STATIC} debug ${BOLT_LIBRARY_STATIC_DEBUG} )
125    else( )
126        message( "${BOLT_LIBNAME_BASE}.debug.${LIB_EXT}: Debug static bolt library not found" )
127    endif( )
128
129    find_path( BOLT_INCLUDE_DIRS
130        NAMES bolt/cl/bolt.h
131        HINTS
132            ${BOLT_ROOT}
133            ENV BOLT_ROOT
134        DOC "BOLT header file path"
135        PATH_SUFFIXES include
136    )
137    mark_as_advanced( BOLT_INCLUDE_DIRS )
138
139    FIND_PACKAGE_HANDLE_STANDARD_ARGS( BOLT DEFAULT_MSG BOLT_LIBRARY_STATIC BOLT_INCLUDE_DIRS )
140endif( )
141
142if( BOLT_FOUND )
143    list( APPEND BOLT_LIBRARIES ${BOLT_LIBRARY_STATIC} )
144else( )
145    if( NOT BOLT_FIND_QUIETLY )
146        message( WARNING "FindBOLT could not find the BOLT library" )
147        message( STATUS "Did you remember to set the BOLT_ROOT environment variable?" )
148    endif( )
149endif()
150