@@ -26,11 +26,11 @@ configure_file(
26
26
# Add the CMake directory for custon CMake modules
27
27
set (CMAKE_MODULE_PATH "${SCALAPACK_SOURCE_DIR} /CMAKE" ${CMAKE_MODULE_PATH} )
28
28
29
- if (UNIX )
30
- if ( " ${ CMAKE_Fortran_COMPILER_ID} " STREQUAL "Intel" )
31
- set ( CMAKE_Fortran_FLAGS " ${CMAKE_Fortran_FLAGS} -fltconsistency -fp_port" )
32
- endif ()
33
- endif ()
29
+ if (UNIX )
30
+ if ( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" )
31
+ add_compile_options ( "$<$<COMPILE_LANGUAGE:Fortran>: -fltconsistency; -fp_port>" )
32
+ endif ()
33
+ endif ()
34
34
35
35
#
36
36
# MPI
@@ -85,12 +85,6 @@ else()
85
85
endif ()
86
86
87
87
88
- if (UNIX )
89
- if ("${CMAKE_Fortran_COMPILER_ID} " STREQUAL "Intel" )
90
- set ( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fltconsistency -fp_port" )
91
- endif ()
92
- endif ()
93
-
94
88
macro (SCALAPACK_install_library lib)
95
89
install (TARGETS ${lib} EXPORT scalapack-targets
96
90
ARCHIVE DESTINATION lib${LIB_SUFFIX}
@@ -114,18 +108,11 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SCALAPACK_BINARY_DIR}/lib)
114
108
115
109
# --------------------------------------------------
116
110
# By default static library
117
- function (invertBoolean varName varValue)
118
- if (${varValue} )
119
- set (${varName} false PARENT_SCOPE)
120
- else ()
121
- set (${varName} true PARENT_SCOPE)
122
- endif ()
123
- endfunction ()
124
111
option (BUILD_SHARED_LIBS "Build shared libraries" OFF )
125
- invertBoolean( " BUILD_STATIC_LIBS" ${ BUILD_SHARED_LIBS} )
126
- if (( ${ BUILD_SHARED_LIBS} EQUAL ON ) AND NOT CMAKE_POSITION_INDEPENDENT_CODE )
112
+ set ( BUILD_STATIC_LIBS $< NOT : BUILD_SHARED_LIBS > )
113
+ if ( BUILD_SHARED_LIBS )
127
114
set (CMAKE_POSITION_INDEPENDENT_CODE ON )
128
- endif ()
115
+ endif ()
129
116
130
117
# --------------------------------------------------
131
118
# Check for any necessary platform specific compiler flags
@@ -166,13 +153,25 @@ IF(LAPACK_LIBRARIES)
166
153
include (CheckFortranFunctionExists)
167
154
message (STATUS "--> LAPACK supplied by user is ${LAPACK_LIBRARIES} ." )
168
155
set (CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES} )
169
- CHECK_FORTRAN_FUNCTION_EXISTS("dgesv" LAPACK_FOUND)
156
+ set (LAPACK_FOUND true )
157
+ if (BUILD_SINGLE)
158
+ check_fortran_function_exists("sgesv" LAPACK_s_FOUND)
159
+ if (NOT LAPACK_s_FOUND)
160
+ set (LAPACK_FOUND false )
161
+ endif ()
162
+ endif ()
163
+ if (BUILD_DOUBLE)
164
+ check_fortran_function_exists("dgesv" LAPACK_d_FOUND)
165
+ if (NOT LAPACK_d_FOUND)
166
+ set (LAPACK_FOUND false )
167
+ endif ()
168
+ endif ()
170
169
unset ( CMAKE_REQUIRED_LIBRARIES )
171
- message (STATUS "--> LAPACK routine dgesv is found: ${LAPACK_FOUND} ." )
170
+ message (STATUS "--> LAPACK routine gesv is found: ${LAPACK_FOUND} ." )
172
171
ENDIF ()
173
172
174
173
if (LAPACK_FOUND)
175
- message (STATUS "--> LAPACK supplied by user is WORKING, will use ${LAPACK_LIBRARIES} ." )
174
+ message (STATUS "--> LAPACK supplied by user is WORKING, will use ${LAPACK_LIBRARIES} ." )
176
175
else (LAPACK_FOUND)
177
176
if (USE_OPTIMIZED_LAPACK_BLAS)
178
177
message (STATUS "--> Searching for optimized LAPACK and BLAS libraries on your machine." )
@@ -258,27 +257,33 @@ append_subdir_files(src-C "SRC")
258
257
259
258
if (NOT MSVC )
260
259
add_library (scalapack ${blacs} ${tools} ${tools-C} ${extra_lapack} ${pblas} ${pblas-F} ${ptzblas} ${ptools} ${pbblas} ${redist} ${src} ${src-C})
261
- set_target_properties (scalapack PROPERTIES
262
- VERSION ${SCALAPACK_VERSION}
263
- SOVERSION ${SCALAPACK_VERSION_MAJOR} .${SCALAPACK_VERSION_MINOR} )
264
- target_link_libraries ( scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_C)
265
- scalapack_install_library(scalapack)
266
260
else () # Need to separate Fortran and C Code
267
261
OPTION (BUILD_SHARED_LIBS "Build shared libraries" ON )
268
262
add_library (scalapack ${blacs} ${tools-C} ${pblas} ${ptools} ${redist} ${src-C})
269
- set_target_properties (scalapack PROPERTIES
270
- VERSION ${SCALAPACK_VERSION}
271
- SOVERSION ${SCALAPACK_VERSION_MAJOR} .${SCALAPACK_VERSION_MINOR} )
272
- target_link_libraries ( scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_C)
273
263
add_library (scalapack-F ${pblas-F} ${pbblas} ${ptzblas} ${tools} ${src} ${extra_lapack} )
274
264
set_target_properties (scalapack-F PROPERTIES
275
265
VERSION ${SCALAPACK_VERSION}
276
266
SOVERSION ${SCALAPACK_VERSION_MAJOR} .${SCALAPACK_VERSION_MINOR} )
277
- target_link_libraries ( scalapack-F ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
278
- scalapack_install_library(scalapack)
267
+ target_link_libraries ( scalapack-F PRIVATE ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
279
268
scalapack_install_library(scalapack-F)
280
269
endif ()
281
270
271
+ include (CheckCCompilerFlag)
272
+ # C99+ default compilers such as Clang error without this
273
+ # test the non-no form, otherwise always succeeds
274
+ check_c_compiler_flag(-Wimplicit-function-declaration HAS_IMPLICIT_FUNC_FLAG)
275
+ if (HAS_IMPLICIT_FUNC_FLAG)
276
+ target_compile_options (scalapack PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wno-implicit-function-declaration>)
277
+ endif ()
278
+
279
+ target_link_libraries (scalapack PRIVATE ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_C)
280
+
281
+ set_target_properties (scalapack PROPERTIES
282
+ VERSION ${SCALAPACK_VERSION}
283
+ SOVERSION ${SCALAPACK_VERSION_MAJOR} .${SCALAPACK_VERSION_MINOR} )
284
+
285
+ scalapack_install_library(scalapack)
286
+
282
287
if (TARGET lapack)
283
288
add_dependencies (scalapack lapack)
284
289
endif ()
0 commit comments