Skip to content

Commit 0db6e07

Browse files
author
Kent Knox
committed
Improved detection of the OpenCL dependencies during the 'copy' step
A little refactoring of the FindOpenCL & FindFFTW to make it more standard
1 parent b4484e9 commit 0db6e07

File tree

3 files changed

+76
-67
lines changed

3 files changed

+76
-67
lines changed

src/FindFFTW.cmake

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
# FFTW_ROOT - (as a CMake or environment variable)
3434
# The root directory of the fftw install prefix
3535
#
36-
#-----------------------
36+
# FIND_LIBRARY_USE_LIB64_PATHS - Global property that controls whether
37+
# findFFTW should search for 64bit or 32bit libs
38+
#-----------------------------------------------
3739
# Example Usage:
3840
#
3941
# find_package(FFTW REQUIRED)
@@ -42,53 +44,52 @@
4244
# add_executable(foo foo.cc)
4345
# target_link_libraries(foo ${FFTW_LIBRARIES})
4446
#
45-
#-----------------------
46-
if( DEFINED ENV{FFTW_ROOT} )
47-
set( FFTW_ROOT $ENV{FFTW_ROOT} CACHE PATH "Environment variable defining the root of FFTW" )
48-
else( )
49-
set( FFTW_ROOT "/usr/lib" CACHE PATH "Environment variable defining the root of FFTW" )
50-
endif( )
47+
#-----------------------------------------------
5148

5249
find_path(FFTW_INCLUDE_DIRS
53-
NAMES fftw3.h
50+
NAMES fftw3.h
5451
HINTS
55-
${FFTW_ROOT}/api
5652
${FFTW_ROOT}/include
53+
${FFTW_ROOT}/api
5754
${FFTW_ROOT}
58-
$ENV{FFTW_ROOT}/api
5955
$ENV{FFTW_ROOT}/include
60-
$ENV{FFTW_ROOT}
61-
PATHS
62-
/usr/include
63-
/usr/local/include
56+
$ENV{FFTW_ROOT}/api
57+
ENV FFTW_ROOT
58+
PATHS
59+
/usr/include
60+
/usr/local/include
6461
)
6562
mark_as_advanced( FFTW_INCLUDE_DIRS )
6663

6764
find_library( FFTW_SINGLE_PRECISION_LIBRARIES
68-
NAMES fftw3f libfftw3f-3
69-
HINTS
70-
${FFTW_ROOT}
71-
${FFTW_ROOT}/lib
72-
$ENV{FFTW_ROOT}
73-
$ENV{FFTW_ROOT}/lib
74-
PATHS
75-
/usr/lib
76-
/usr/local/lib
77-
DOC "FFTW dynamic library"
65+
NAMES fftw3f libfftw3f-3
66+
HINTS
67+
${FFTW_ROOT}/lib
68+
${FFTW_ROOT}/.libs
69+
${FFTW_ROOT}
70+
$ENV{FFTW_ROOT}/lib
71+
$ENV{FFTW_ROOT}/.libs
72+
ENV FFTW_ROOT
73+
PATHS
74+
/usr/lib
75+
/usr/local/lib
76+
DOC "FFTW dynamic library"
7877
)
7978
mark_as_advanced( FFTW_SINGLE_PRECISION_LIBRARIES )
8079

8180
find_library( FFTW_DOUBLE_PRECISION_LIBRARIES
82-
NAMES fftw3 libfftw3-3
83-
HINTS
84-
${FFTW_ROOT}
85-
${FFTW_ROOT}/lib
86-
$ENV{FFTW_ROOT}
87-
$ENV{FFTW_ROOT}/lib
88-
PATHS
89-
/usr/lib
90-
/usr/local/lib
91-
DOC "FFTW dynamic library"
81+
NAMES fftw3 libfftw3-3
82+
HINTS
83+
${FFTW_ROOT}/lib
84+
${FFTW_ROOT}/.libs
85+
${FFTW_ROOT}
86+
$ENV{FFTW_ROOT}/lib
87+
$ENV{FFTW_ROOT}/.libs
88+
ENV FFTW_ROOT
89+
PATHS
90+
/usr/lib
91+
/usr/local/lib
92+
DOC "FFTW dynamic library"
9293
)
9394
mark_as_advanced( FFTW_DOUBLE_PRECISION_LIBRARIES )
9495

@@ -99,6 +100,6 @@ include( FindPackageHandleStandardArgs )
99100
FIND_PACKAGE_HANDLE_STANDARD_ARGS( FFTW DEFAULT_MSG FFTW_LIBRARIES FFTW_INCLUDE_DIRS )
100101

101102
if( NOT FFTW_FOUND )
102-
message( STATUS "FindFFTW looked for single precision libraries named: fftw3f or libfftw3f-3" )
103-
message( STATUS "FindFFTW looked for double precision libraries named: fftw3 or libfftw3-3" )
103+
message( STATUS "FindFFTW looked for single precision libraries named: fftw3f or libfftw3f-3" )
104+
message( STATUS "FindFFTW looked for double precision libraries named: fftw3 or libfftw3-3" )
104105
endif()

src/FindOpenCL.cmake

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,53 +46,53 @@
4646
# target_link_libraries(foo ${OPENCL_LIBRARIES})
4747
#
4848
#-----------------------
49-
if( DEFINED ENV{AMDAPPSDKROOT} )
50-
set( OPENCL_ROOT $ENV{AMDAPPSDKROOT} CACHE PATH "Environment variable defining the root of OPENCL implementation" )
51-
elseif( DEFINED ENV{CUDA_PATH} )
52-
set( OPENCL_ROOT $ENV{CUDA_PATH} CACHE PATH "Environment variable defining the root of OPENCL implementation" )
53-
else( )
54-
set( OPENCL_ROOT "/usr/lib" CACHE PATH "Environment variable defining the root of OPENCL implementation" )
55-
endif( )
5649

5750
find_path(OPENCL_INCLUDE_DIRS
58-
NAMES OpenCL/cl.h CL/cl.h
51+
NAMES OpenCL/cl.h CL/cl.h
5952
HINTS
60-
${OPENCL_ROOT}/include
61-
ENV AMDAPPSDKROOT/include
62-
PATHS
63-
/usr/include
64-
/usr/local/include
65-
DOC "OpenCL header file path"
53+
${OPENCL_ROOT}/include
54+
$ENV{AMDAPPSDKROOT}/include
55+
$ENV{CUDA_PATH}/include
56+
PATHS
57+
/usr/include
58+
/usr/local/include
59+
DOC "OpenCL header file path"
6660
)
6761
mark_as_advanced( OPENCL_INCLUDE_DIRS )
6862

6963
# Search for 64bit libs if FIND_LIBRARY_USE_LIB64_PATHS is set to true in the global environment, 32bit libs else
7064
get_property( LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS )
7165

7266
if( LIB64 )
73-
find_library( OPENCL_LIBRARIES
74-
NAMES OpenCL
75-
HINTS
76-
${OPENCL_ROOT}/lib
77-
ENV AMDAPPSDKROOT/lib
78-
DOC "OpenCL dynamic library path"
79-
PATH_SUFFIXES x86_64 x64
80-
)
67+
find_library( OPENCL_LIBRARIES
68+
NAMES OpenCL
69+
HINTS
70+
${OPENCL_ROOT}/lib
71+
$ENV{AMDAPPSDKROOT}/lib
72+
$ENV{CUDA_PATH}/lib
73+
DOC "OpenCL dynamic library path"
74+
PATH_SUFFIXES x86_64 x64
75+
PATHS
76+
/usr/lib
77+
)
8178
else( )
82-
find_library( OPENCL_LIBRARIES
83-
NAMES OpenCL
84-
HINTS
85-
${OPENCL_ROOT}/lib
86-
ENV AMDAPPSDKROOT/lib
87-
DOC "OpenCL dynamic library path"
88-
PATH_SUFFIXES x86 Win32
89-
)
79+
find_library( OPENCL_LIBRARIES
80+
NAMES OpenCL
81+
HINTS
82+
${OPENCL_ROOT}/lib
83+
$ENV{AMDAPPSDKROOT}/lib
84+
$ENV{CUDA_PATH}/lib
85+
DOC "OpenCL dynamic library path"
86+
PATH_SUFFIXES x86 Win32
87+
PATHS
88+
/usr/lib
89+
)
9090
endif( )
9191
mark_as_advanced( OPENCL_LIBRARIES )
9292

9393
include( FindPackageHandleStandardArgs )
9494
FIND_PACKAGE_HANDLE_STANDARD_ARGS( OPENCL DEFAULT_MSG OPENCL_LIBRARIES OPENCL_INCLUDE_DIRS )
9595

9696
if( NOT OPENCL_FOUND )
97-
message( STATUS "FindOpenCL looked for libraries named: OpenCL" )
97+
message( STATUS "FindOpenCL looked for libraries named: OpenCL" )
9898
endif()

src/tests/copyTestDependencies.cmake.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ if( EXISTS "@GTEST_ROOT@" )
4141
list( APPEND depList "@GTEST_ROOT@/lib@SUFFIX_LIB@" )
4242
endif( )
4343

44+
if( EXISTS "@OPENCL_LIBRARIES@" )
45+
get_filename_component( clLibName "@OPENCL_LIBRARIES@" NAME )
46+
string( REPLACE ${clLibName} "" clLibDir "@OPENCL_LIBRARIES@" )
47+
string( REGEX REPLACE "/+$" "" clLibDir ${clLibDir} )
48+
49+
list( APPEND depList "${clLibDir}" )
50+
endif( )
51+
4452
if( EXISTS "${testDir}" )
4553
list( APPEND depList "${testDir}" )
4654
endif( )

0 commit comments

Comments
 (0)