@ -5,6 +5,10 @@
# C U D A _ N P P _ L I B R A R Y _ R O O T _ D I R - - P a t h t o t h e N P P d o r e c t o r y .
# C U D A _ N P P _ I N C L U D E S - - N P P I n c l u d e d i r e c t o r i e s .
# C U D A _ N P P _ L I B R A R I E S - - N P P l i b r a r i e s .
# N P P _ V E R S I O N - - N P P v e r s i o n i n f o r m a t " m a j o r . m i n o r . b u i l d " .
#
# I f n o t f o u n d a u t o m a t i c a l l y , p l e a s e s e t C U D A _ N P P _ L I B R A R Y _ R O O T _ D I R o r
# s e t e n v i r o m e n t v a r i v a b e $ C U D A _ N P P _ R O O T
#
# A u t h o r : A n a t o l y B a k s h e e v , I t s e e z L t d .
#
@ -41,24 +45,25 @@ if(NOT "${CUDA_NPP_LIBRARY_ROOT_DIR}" STREQUAL "${CUDA_NPP_LIBRARY_ROOT_DIR_INTE
unset ( CUDA_NPP_LIBRARIES CACHE )
endif ( )
if ( ${ CMAKE_SIZEOF_VOID_P } EQUAL 4 )
if ( CMAKE_SIZEOF_VOID_P EQUAL 4 )
if ( UNIX OR APPLE )
set ( NPP_SUFFIX "32" )
else ( )
set ( NPP_SUFFIX "-mt" )
endif ( )
else ( ${ CMAKE_SIZEOF_VOID_P } EQUAL 4 )
else ( CMAKE_SIZEOF_VOID_P EQUAL 4 )
if ( UNIX OR APPLE )
set ( NPP_SUFFIX "64" )
else ( )
set ( NPP_SUFFIX "-mt-x64" )
endif ( )
endif ( ${ CMAKE_SIZEOF_VOID_P } EQUAL 4 )
endif ( CMAKE_SIZEOF_VOID_P EQUAL 4 )
if ( NOT CUDA_NPP_LIBRARY_ROOT_DIR )
set ( CUDA_NPP_LIBRARY_ROOT_DIR $ENV{ CUDA_NPP_ROOT } CACHE PATH "NPP root directory." FORC E )
if ( NOT CUDA_NPP_LIBRARY_ROOT_DIR OR CUDA_NPP_LIBRARY_ROOT_DIR STREQUAL "" )
un set( CUDA_NPP_LIBRARY_ROOT_DIR CACHE )
find_path ( CUDA_NPP_LIBRARY_ROOT_DIR "common/npp/include/npp.h" PATHS ENV CUDA_NPP_ROOT DOC "NPP root directory." )
endif ( NOT CUDA_NPP_LIBRARY_ROOT_DIR )
MESSAGE ( STATUS "NPP root directory: " ${ CUDA_NPP_LIBRARY_ROOT_DIR } )
endif ( )
# S e a r c h i n c l u d e s i n o u r o w n p a t h s .
find_path ( CUDA_NPP_INCLUDES npp.h PATHS "${CUDA_NPP_LIBRARY_ROOT_DIR}/common/npp/include" )
@ -76,30 +81,42 @@ find_library(CUDA_NPP_LIBRARIES
# S e a r c h d e f a u l t s e a r c h p a t h s , a f t e r w e s e a r c h o u r o w n s e t o f p a t h s .
find_library ( CUDA_NPP_LIBRARIES NAMES npp ${ NPP_SUFFIX } libnpp ${ NPP_SUFFIX } DOC "NPP library" )
mark_as_advanced ( CUDA_NPP_LIBRARIES )
mark_as_advanced ( CUDA_NPP_LIBRARIES )
if ( EXISTS ${ CUDA_NPP_INCLUDES } /nppversion.h )
file ( STRINGS ${ CUDA_NPP_INCLUDES } /nppversion.h npp_major REGEX "#define NPP_VERSION_MAJOR.*" )
file ( STRINGS ${ CUDA_NPP_INCLUDES } /nppversion.h npp_minor REGEX "#define NPP_VERSION_MINOR.*" )
file ( STRINGS ${ CUDA_NPP_INCLUDES } /nppversion.h npp_build REGEX "#define NPP_VERSION_BUILD.*" )
string ( REGEX REPLACE "#define NPP_VERSION_MAJOR[ \t]+|//.*" "" npp_major ${ npp_major } )
string ( REGEX REPLACE "#define NPP_VERSION_MINOR[ \t]+|//.*" "" npp_minor ${ npp_minor } )
string ( REGEX REPLACE "#define NPP_VERSION_BUILD[ \t]+|//.*" "" npp_build ${ npp_build } )
string ( REGEX MATCH "[0-9]+" npp_major ${ npp_major } )
string ( REGEX MATCH "[0-9]+" npp_minor ${ npp_minor } )
string ( REGEX MATCH "[0-9]+" npp_build ${ npp_build } )
set ( NPP_VERSION "${npp_major}.${npp_minor}.${npp_build}" )
MESSAGE ( STATUS "Npp version: " ${ NPP_VERSION } )
endif ( )
if ( NOT EXISTS ${ CUDA_NPP_LIBRARIES } OR NOT EXISTS ${ CUDA_NPP_INCLUDES } /npp.h )
set ( CUDA_FOUND FALSE )
set ( CUDA_NPP_ FOUND FALSE )
unset ( CUDA_NPP_INCLUDES CACHE )
unset ( CUDA_NPP_LIBRARIES CACHE )
if ( NPP_FIND_REQUIRED )
message ( FATAL_ERROR "NPP headers/libraries are not found. Specify CUDA_NPP_LIBRARY_ROOT_DIR." )
elseif ( NOT CUDA_FIND_QUIETLY )
message ( "NPP headers/libraries are not found. Please specify CUDA_NPP_LIBRARY_ROOT_DIR in CMake or set $NPP_ROOT_DIR." )
endif ( )
else ( )
if ( APPLE )
# W e n e e d t o a d d t h e p a t h t o c u d a r t t o t h e l i n k e r u s i n g r p a t h , s i n c e t h e
# l i b r a r y n a m e f o r t h e c u d a l i b r a r i e s i s p r e p e n d e d w i t h @ r p a t h .
get_filename_component ( _cuda_path_to_npp "${CUDA_NPP_LIBRARIES}" PATH )
if ( _cuda_path_to_npp )
list ( APPEND CUDA_NPP_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_npp}" )
endif ( )
endif ( )
set ( CUDA_NPP_FOUND TRUE )
set ( CUDA_NPP_LIBRARY_ROOT_DIR_INTERNAL "${CUDA_NPP_LIBRARY_ROOT_DIR}" CACHE INTERNAL "This is the value of the last time CUDA_NPP_LIBRARY_ROOT_DIR was set successfully." FORCE )
message ( FATAL_ERROR "NPP headers/libraries are not found. Please specify CUDA_NPP_LIBRARY_ROOT_DIR in CMake or set $NPP_ROOT_DIR." )
endif ( )
if ( APPLE )
# W e n e e d t o a d d t h e p a t h t o c u d a r t t o t h e l i n k e r u s i n g r p a t h , s i n c e t h e
# l i b r a r y n a m e f o r t h e c u d a l i b r a r i e s i s p r e p e n d e d w i t h @ r p a t h .
get_filename_component ( _cuda_path_to_npp "${CUDA_NPP_LIBRARIES}" PATH )
if ( _cuda_path_to_npp )
list ( APPEND CUDA_NPP_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_npp}" )
endif ( )
endif ( )
set ( CUDA_NPP_FOUND TRUE )
set ( CUDA_NPP_LIBRARY_ROOT_DIR_INTERNAL "${CUDA_NPP_LIBRARY_ROOT_DIR}" CACHE INTERNAL "This is the value of the last time CUDA_NPP_LIBRARY_ROOT_DIR was set successfully." FORCE )