Skip to content

Commit 89b143d

Browse files
author
jagar
committed
GTestsuite:Search library in user specified-path
In Gtestsuite CMakeLists.txt, find_library() will search user-mentioned library in default system paths first then in user specified paths. To avoid this CMake is updated to search the user mentioned library in user specified path and ignore searching in default path. AMD-Internal: [CPUPL-4284] Change-Id: Ia99cf59eb39deac4110d3d733f17548d432dde64
1 parent 7a5a150 commit 89b143d

1 file changed

Lines changed: 30 additions & 34 deletions

File tree

gtestsuite/CMakeLists.txt

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,6 @@ endif()
6060
set(BLIS_INCLUDE ${BLIS_PATH}/include/ ${BLIS_PATH}/include/blis CACHE STRING "Setting the path to the BLIS headers.")
6161
set(BLIS_LIB_PATH ${BLIS_PATH}/lib CACHE STRING "Setting the path to the BLIS library.")
6262

63-
# Use REF_BLAS to set the library that will be used for reference results.
64-
set(REF_CBLAS CACHE STRING "Library used to compute reference results.")
65-
# Set the possible values of reference CBLAS for cmake-gui and throw errors for disabled options.
66-
if(LINUX)
67-
set_property(CACHE REF_CBLAS PROPERTY STRINGS "OpenBLAS" "Netlib" "MKL")
68-
if(NOT ((REF_CBLAS STREQUAL "OpenBLAS") OR (REF_CBLAS STREQUAL "Netlib") OR(REF_CBLAS STREQUAL "MKL")))
69-
message(FATAL_ERROR "REF_CBLAS option '${REF_CBLAS}' is not supported. Please, use one of the following options \
70-
during CMake invokation: OpenBLAS, Netlib, MKL or modify CMakeLists.txt to include this option.")
71-
endif()
72-
else()
73-
set_property(CACHE REF_CBLAS PROPERTY STRINGS "OpenBLAS" "MKL")
74-
if(NOT ((REF_CBLAS STREQUAL "OpenBLAS") OR (REF_CBLAS STREQUAL "MKL")))
75-
message(FATAL_ERROR "REF_CBLAS option '${REF_CBLAS}' is not supported. Please, use one of the following options \
76-
during CMake invokation: OpenBLAS, MKL or modify CMakeLists.txt to include this option.")
77-
endif()
78-
endif()
79-
8063
# Set OpenMP as the default option
8164
set(ENABLE_THREADING "openmp" CACHE STRING "the threading flag")
8265
# Set the possible values of theading libraries for cmake-gui
@@ -99,12 +82,6 @@ if(WIN32)
9982
set(OpenMP_libomp_LIBRARY "C:/Program Files/LLVM/lib/libomp.lib" CACHE STRING "openmp library path")
10083
endif()
10184

102-
# If MKL is used as a reference set up the threading library options.
103-
if(REF_CBLAS STREQUAL "MKL")
104-
# MKL threading option is set up as BLIS threading option by default.
105-
set(MKL_ENABLE_THREADING ${ENABLE_THREADING} CACHE STRING "Setting MKL threading option.")
106-
endif()
107-
10885
# Set up OpenMP flags correctly if it's required.
10986
if( (ENABLE_THREADING STREQUAL "openmp") OR (MKL_ENABLE_THREADING STREQUAL "openmp") )
11087
find_package(OpenMP)
@@ -113,6 +90,12 @@ if( (ENABLE_THREADING STREQUAL "openmp") OR (MKL_ENABLE_THREADING STREQUAL "open
11390
endif()
11491
endif()
11592

93+
# If MKL is used as a reference set up the threading library options.
94+
if(REF_CBLAS STREQUAL "MKL")
95+
# MKL threading option is set up as BLIS threading option by default.
96+
set(MKL_ENABLE_THREADING ${ENABLE_THREADING} CACHE STRING "Setting MKL threading option.")
97+
endif()
98+
11699
# Set static BLIS as the default library we build against.
117100
set(BLIS_LINKING_TYPE "static" CACHE STRING "Type of BLIS library (shared or static) that is being tested.")
118101
# Set the possible values of BLIS linking type for cmake-gui
@@ -158,21 +141,30 @@ endif()
158141

159142
if(LINUX)
160143
if(REF_LIB)
161-
set(REFLIB_PATH ${REF_LIB}/..)
162-
find_library(reflib NAMES openblas cblas mkl_rt HINTS ${REFLIB_PATH} PATHS ${REFLIB_PATH})
144+
get_filename_component(REFLIB_PATH ${REF_LIB}/.. ABSOLUTE)
145+
get_filename_component(library ${REF_LIB} NAME)
146+
find_library(reflib NAMES ${library} PATHS ${REFLIB_PATH} NO_DEFAULT_PATH)
163147
if(${reflib} STREQUAL reflib-NOTFOUND)
164148
message(FATAL_ERROR "Reference Library not found : " ${REF_LIB})
165149
else()
166150
message(STATUS "Found Reference Library : " ${reflib})
167151
endif()
168152
else()
153+
# Use REF_BLAS to set the library that will be used for reference results.
154+
set(REF_CBLAS CACHE STRING "Library used to compute reference results.")
155+
# Set the possible values of theading libraries for cmake-gui
156+
set_property(CACHE REF_CBLAS PROPERTY STRINGS "OpenBLAS" "Netlib" "MKL")
157+
if(NOT ((REF_CBLAS STREQUAL "OpenBLAS") OR (REF_CBLAS STREQUAL "Netlib") OR(REF_CBLAS STREQUAL "MKL")))
158+
message(FATAL_ERROR "REF_CBLAS option '${REF_CBLAS}' is not supported. Please, use one of the following options \
159+
during CMake invokation: OpenBLAS, Netlib, MKL or modify CMakeLists.txt to include this option.")
160+
endif()
169161
if(REF_CBLAS STREQUAL "OpenBLAS")
170162
if(NOT(OPENBLAS_PATH))
171163
message(FATAL_ERROR "Need to provide an OpenBLAS installation path \
172164
during CMake invokation when OpenBLAS is used for reference results. Please use \
173165
$ cmake .. -DOPENBLAS_PATH=/home/username/openblas_installation")
174166
endif()
175-
find_library(reflib NAMES openblas HINTS ${OPENBLAS_PATH} PATHS ${OPENBLAS_PATH})
167+
find_library(reflib NAMES openblas PATHS ${OPENBLAS_PATH} NO_DEFAULT_PATH)
176168
if(${reflib} STREQUAL reflib-NOTFOUND)
177169
message(FATAL_ERROR "OpenBLAS Reference Library not found : " ${OPENBLAS_PATH})
178170
else()
@@ -186,9 +178,9 @@ if(LINUX)
186178
$ cmake .. -DNETLIB_PATH=/home/username/netlib_installation")
187179
endif()
188180
if(INT_SIZE STREQUAL "32")
189-
find_library(netlib NAMES cblas HINTS ${NETLIB_PATH} PATHS ${NETLIB_PATH})
181+
find_library(netlib NAMES cblas PATHS ${NETLIB_PATH} NO_DEFAULT_PATH)
190182
else()
191-
find_library(netlib NAMES cblas64 HINTS ${NETLIB_PATH} PATHS ${NETLIB_PATH})
183+
find_library(netlib NAMES cblas64 PATHS ${NETLIB_PATH} NO_DEFAULT_PATH)
192184
endif()
193185
if(${netlib} STREQUAL netlib-NOTFOUND)
194186
message(FATAL_ERROR "Netlib Reference Library not found : " ${NETLIB_PATH})
@@ -199,7 +191,7 @@ if(LINUX)
199191
elseif(REF_CBLAS STREQUAL "MKL")
200192
set(MKL_PATH $ENV{MKLROOT}/lib/intel64
201193
CACHE STRING "The path to MKL.")
202-
find_library(mkllib NAMES mkl_rt HINTS ${MKL_PATH} PATHS ${MKL_PATH})
194+
find_library(mkllib NAMES mkl_rt PATHS ${MKL_PATH} NO_DEFAULT_PATH)
203195
if(${mkllib} STREQUAL mkllib-NOTFOUND)
204196
message(FATAL_ERROR "MKL Reference Library not found : " ${MKL_PATH})
205197
else()
@@ -212,9 +204,13 @@ if(LINUX)
212204
endif()
213205
endif()
214206
else() #WIN32
215-
if( NOT ((REF_CBLAS STREQUAL "OpenBLAS") OR (REF_CBLAS STREQUAL "MKL")) )
216-
message(FATAL_ERROR "REF_CBLAS option ${REF_CBLAS} is not supported. Please use on of the following options \
217-
during CMake invokation: -DREF_CBLAS=OpenBLAS or -DREF_CBLAS=MKL")
207+
# Use REF_BLAS to set the library that will be used for reference results.
208+
set(REF_CBLAS CACHE STRING "Library used to compute reference results.")
209+
# Set the possible values of theading libraries for cmake-gui
210+
set_property(CACHE REF_CBLAS PROPERTY STRINGS "OpenBLAS" "MKL")
211+
if(NOT ((REF_CBLAS STREQUAL "OpenBLAS") OR (REF_CBLAS STREQUAL "MKL")))
212+
message(FATAL_ERROR "REF_CBLAS option '${REF_CBLAS}' is not supported. Please, use one of the following options \
213+
during CMake invokation: OpenBLAS, MKL or modify CMakeLists.txt to include this option.")
218214
endif()
219215
if(REF_CBLAS STREQUAL "OpenBLAS")
220216
if(NOT(OPENBLAS_PATH))
@@ -231,7 +227,7 @@ else() #WIN32
231227
$ cmake .. -DMKL_PATH=/home/username/path_to_mkl_rt")
232228
endif()
233229
set(REF_LIB "${MKL_PATH}/mkl_rt.2.dll" CACHE STRING "Reference MKL Library")
234-
message(STATUS "Found MKL Reference Library : " ${REF_LIB})
230+
message(STATUS "Found MKL Reference Library : " ${REF_LIB})
235231
endif()
236232
endif()
237233

@@ -264,7 +260,7 @@ else()
264260
endif()
265261
endif()
266262

267-
find_library(BLIS_LIBRARY NAMES ${LIBBLIS} PATHS ${BLIS_LIB_PATH})
263+
find_library(BLIS_LIBRARY NAMES ${LIBBLIS} PATHS ${BLIS_LIB_PATH} NO_DEFAULT_PATH)
268264
if(${BLIS_LIBRARY} STREQUAL BLIS_LIBRARY-NOTFOUND)
269265
message(FATAL_ERROR "Blis Library ${LIBBLIS} not found in BLIS_LIB_PATH=${BLIS_LIB_PATH}")
270266
else()

0 commit comments

Comments
 (0)