FindBolt.cmake 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. # Locate an BOLT implementation.
  17. #
  18. # Defines the following variables:
  19. #
  20. # BOLT_FOUND - Found an Bolt imlementation
  21. #
  22. # Also defines the library variables below as normal
  23. # variables.
  24. #
  25. # BOLT_LIBRARIES - These contain debug/optimized keywords when a debugging library is found
  26. # BOLT_INCLUDE_DIRS - All relevant Bolt include directories
  27. #
  28. # Accepts the following variables as input:
  29. #
  30. # BOLT_ROOT - (as a CMake or environment variable)
  31. # The root directory of an BOLT installation
  32. #
  33. # FIND_LIBRARY_USE_LIB64_PATHS - Global property that controls whether FindBOLT should search for
  34. # 64bit or 32bit libs
  35. #
  36. #-----------------------
  37. # Example Usage:
  38. #
  39. # find_package(BOLT REQUIRED)
  40. # include_directories(${BOLT_INCLUDE_DIRS})
  41. #
  42. # add_executable(foo foo.cc)
  43. # target_link_libraries(foo ${BOLT_LIBRARIES})
  44. #
  45. #-----------------------
  46. # This module helps to use BOLT_FIND_COMPONENTS, BOLT_FIND_REQUIRED, BOLT_FIND_QUIETLY
  47. include( FindPackageHandleStandardArgs )
  48. # Search for 64bit libs if FIND_LIBRARY_USE_LIB64_PATHS is set to true in the global environment, 32bit libs else
  49. get_property( LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS )
  50. # Debug print statements
  51. #message( "BOLT_LIBRARY_PATH_SUFFIXES: ${BOLT_LIBRARY_PATH_SUFFIXES}" )
  52. #message( "ENV{BOLT_ROOT}: $ENV{BOLT_ROOT}" )
  53. #message( "BOLT_FIND_COMPONENTS: ${BOLT_FIND_COMPONENTS}" )
  54. #message( "BOLT_FIND_REQUIRED: ${BOLT_FIND_REQUIRED}" )
  55. # Set the component to find if the user does not specify explicitely
  56. if( NOT BOLT_FIND_COMPONENTS )
  57. set( BOLT_FIND_COMPONENTS CL )
  58. endif( )
  59. if(WIN32)
  60. if( MSVC_VERSION VERSION_LESS 1600 )
  61. set( myMSVCVer "vc90" )
  62. elseif( MSVC_VERSION VERSION_LESS 1700 )
  63. set( myMSVCVer "vc100" )
  64. elseif( MSVC_VERSION VERSION_LESS 1800 )
  65. set( myMSVCVer "vc110" )
  66. else()
  67. set( myMSVCVer "vc120" )
  68. endif( )
  69. else()
  70. set( myMSVCVer "gcc" )
  71. endif()
  72. if(WIN32)
  73. set( BoltLibName "clBolt.runtime.${myMSVCVer}")
  74. set( LIB_EXT "lib")
  75. else()
  76. set( BoltLibName "libclBolt.runtime.${myMSVCVer}")
  77. set( LIB_EXT "a")
  78. endif()
  79. # Eventually, Bolt may support multiple backends, but for now it only supports CL
  80. list( FIND BOLT_FIND_COMPONENTS CL find_CL )
  81. if( NOT find_CL EQUAL -1 )
  82. set( BOLT_LIBNAME_BASE ${BoltLibName} )
  83. endif( )
  84. if( NOT find_CL EQUAL -1 )
  85. # Find and set the location of main BOLT static lib file
  86. find_library( BOLT_LIBRARY_STATIC_RELEASE
  87. NAMES ${BOLT_LIBNAME_BASE}.${LIB_EXT}
  88. HINTS
  89. ${BOLT_ROOT}
  90. ENV BOLT_ROOT
  91. DOC "BOLT static library path"
  92. PATH_SUFFIXES lib
  93. )
  94. mark_as_advanced( BOLT_LIBRARY_STATIC_RELEASE )
  95. # Find and set the location of main BOLT static lib file
  96. find_library( BOLT_LIBRARY_STATIC_DEBUG
  97. NAMES ${BOLT_LIBNAME_BASE}.debug.${LIB_EXT}
  98. HINTS
  99. ${BOLT_ROOT}
  100. ENV BOLT_ROOT
  101. DOC "BOLT static library path"
  102. PATH_SUFFIXES lib
  103. )
  104. mark_as_advanced( BOLT_LIBRARY_STATIC_DEBUG )
  105. if( BOLT_LIBRARY_STATIC_RELEASE )
  106. set( BOLT_LIBRARY_STATIC optimized ${BOLT_LIBRARY_STATIC_RELEASE} )
  107. else( )
  108. set( BOLT_LIBRARY_STATIC "" )
  109. message( "${BOLT_LIBNAME_BASE}.${LIB_EXT}: Release static bolt library not found" )
  110. endif( )
  111. if( BOLT_LIBRARY_STATIC_DEBUG )
  112. set( BOLT_LIBRARY_STATIC ${BOLT_LIBRARY_STATIC} debug ${BOLT_LIBRARY_STATIC_DEBUG} )
  113. else( )
  114. message( "${BOLT_LIBNAME_BASE}.debug.${LIB_EXT}: Debug static bolt library not found" )
  115. endif( )
  116. find_path( BOLT_INCLUDE_DIRS
  117. NAMES bolt/cl/bolt.h
  118. HINTS
  119. ${BOLT_ROOT}
  120. ENV BOLT_ROOT
  121. DOC "BOLT header file path"
  122. PATH_SUFFIXES include
  123. )
  124. mark_as_advanced( BOLT_INCLUDE_DIRS )
  125. FIND_PACKAGE_HANDLE_STANDARD_ARGS( BOLT DEFAULT_MSG BOLT_LIBRARY_STATIC BOLT_INCLUDE_DIRS )
  126. endif( )
  127. if( BOLT_FOUND )
  128. list( APPEND BOLT_LIBRARIES ${BOLT_LIBRARY_STATIC} )
  129. else( )
  130. if( NOT BOLT_FIND_QUIETLY )
  131. message( WARNING "FindBOLT could not find the BOLT library" )
  132. message( STATUS "Did you remember to set the BOLT_ROOT environment variable?" )
  133. endif( )
  134. endif()