11cmake_minimum_required (VERSION 3.6)
22
3- project (LAPACK Fortran C )
3+ project (LAPACK)
44
55set (LAPACK_MAJOR_VERSION 3)
66set (LAPACK_MINOR_VERSION 11)
@@ -129,92 +129,6 @@ configure_file(
129129include (PreventInSourceBuilds)
130130include (PreventInBuildInstalls)
131131
132- # Check if recursive flag exists
133- include (CheckFortranCompilerFlag)
134- if (CMAKE_Fortran_COMPILER_ID STREQUAL Flang)
135- check_fortran_compiler_flag("-Mrecursive" _MrecursiveFlag)
136- elseif (CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
137- check_fortran_compiler_flag("-frecursive" _frecursiveFlag)
138- elseif (CMAKE_Fortran_COMPILER_ID MATCHES Intel)
139- check_fortran_compiler_flag("-recursive" _recursiveFlag)
140- elseif (CMAKE_Fortran_COMPILER_ID STREQUAL XL)
141- check_fortran_compiler_flag("-qrecur" _qrecurFlag)
142- elseif (CMAKE_Fortran_COMPILER_ID STREQUAL NAG)
143- check_fortran_compiler_flag("-recursive" _recursiveFlag)
144- elseif (CMAKE_Fortran_COMPILER_ID STREQUAL NVHPC)
145- check_fortran_compiler_flag("-Mrecursive" _MrecursiveFlag)
146- else ()
147- message (WARNING "Fortran local arrays should be allocated on the stack."
148- " Please use a compiler which guarantees that feature."
149- " See https://github.com/Reference-LAPACK/lapack/pull/188 and references therein." )
150- endif ()
151-
152- # Add recursive flag
153- if (_MrecursiveFlag)
154- string (REGEX MATCH "-Mrecursive" output_test <string > "${CMAKE_Fortran_FLAGS} " )
155- if (NOT output_test)
156- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mrecursive"
157- CACHE STRING "Recursive flag must be set" FORCE)
158- endif ()
159- elseif (_frecursiveFlag)
160- string (REGEX MATCH "-frecursive" output_test <string > "${CMAKE_Fortran_FLAGS} " )
161- if (NOT output_test)
162- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -frecursive"
163- CACHE STRING "Recursive flag must be set" FORCE)
164- endif ()
165- elseif (_recursiveFlag)
166- string (REGEX MATCH "-recursive" output_test <string > "${CMAKE_Fortran_FLAGS} " )
167- if (NOT output_test)
168- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -recursive"
169- CACHE STRING "Recursive flag must be set" FORCE)
170- endif ()
171- elseif (_qrecurFlag)
172- string (REGEX MATCH "-qrecur" output_test <string > "${CMAKE_Fortran_FLAGS} " )
173- if (NOT output_test)
174- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qrecur"
175- CACHE STRING "Recursive flag must be set" FORCE)
176- endif ()
177- endif ()
178-
179- if (UNIX )
180- if (CMAKE_Fortran_COMPILER_ID MATCHES Intel)
181- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict" )
182- endif ()
183- if (CMAKE_Fortran_COMPILER_ID STREQUAL XL)
184- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qnosave -qstrict" )
185- endif ()
186- # Delete libmtsk in linking sequence for Sun/Oracle Fortran Compiler.
187- # This library is not present in the Sun package SolarisStudio12.3-linux-x86-bin
188- string (REPLACE \;mtsk\; \; CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES} " )
189- endif ()
190-
191- if (CMAKE_Fortran_COMPILER_ID STREQUAL Compaq)
192- if (WIN32 )
193- if (CMAKE_GENERATOR STREQUAL "NMake Makefiles" )
194- get_filename_component (CMAKE_Fortran_COMPILER_CMDNAM ${CMAKE_Fortran_COMPILER} NAME_WE )
195- message (STATUS "Using Compaq Fortran compiler with command name ${CMAKE_Fortran_COMPILER_CMDNAM} " )
196- set (cmd ${CMAKE_Fortran_COMPILER_CMDNAM} )
197- string (TOLOWER "${cmd} " cmdlc)
198- if (cmdlc STREQUAL "df" )
199- message (STATUS "Assume the Compaq Visual Fortran Compiler is being used" )
200- set (CMAKE_Fortran_USE_RESPONSE_FILE_FOR_OBJECTS 1)
201- set (CMAKE_Fortran_USE_RESPONSE_FILE_FOR_INCLUDES 1)
202- #This is a workaround that is needed to avoid forward-slashes in the
203- #filenames listed in response files from incorrectly being interpreted as
204- #introducing compiler command options
205- if (${BUILD_SHARED_LIBS} )
206- message (FATAL_ERROR "Making of shared libraries with CVF has not been tested." )
207- endif ()
208- set (str "NMake version 9 or later should be used. NMake version 6.0 which is\n " )
209- set (str "${str} included with the CVF distribution fails to build Lapack because\n " )
210- set (str "${str} the number of source files exceeds the limit for NMake v6.0\n " )
211- message (STATUS ${str} )
212- set (CMAKE_Fortran_LINK_EXECUTABLE "LINK /out:<TARGET> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS>" )
213- endif ()
214- endif ()
215- endif ()
216- endif ()
217-
218132# Add option to enable flat namespace for symbol resolution on macOS
219133if (APPLE )
220134 option (USE_FLAT_NAMESPACE "Use flat namespaces for symbol resolution during build and runtime." OFF )
@@ -272,26 +186,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/bin)
272186set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR} /lib)
273187set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR} /lib)
274188
275- # --------------------------------------------------
276- # Check for any necessary platform specific compiler flags
277- include (CheckLAPACKCompilerFlags)
278- CheckLAPACKCompilerFlags()
279-
280- # --------------------------------------------------
281- # Check second function
282-
283- include (CheckTimeFunction)
284- set (TIME_FUNC NONE)
285- CHECK_TIME_FUNCTION(NONE TIME_FUNC)
286- CHECK_TIME_FUNCTION(INT_CPU_TIME TIME_FUNC)
287- CHECK_TIME_FUNCTION(EXT_ETIME TIME_FUNC)
288- CHECK_TIME_FUNCTION(EXT_ETIME_ TIME_FUNC)
289- CHECK_TIME_FUNCTION(INT_ETIME TIME_FUNC)
290- message (STATUS "--> Will use second_${TIME_FUNC} .f and dsecnd_${TIME_FUNC} .f as timing function." )
291-
292- set (SECOND_SRC ${LAPACK_SOURCE_DIR} /INSTALL /second_${TIME_FUNC} .f)
293- set (DSECOND_SRC ${LAPACK_SOURCE_DIR} /INSTALL /dsecnd_${TIME_FUNC} .f)
294-
295189# deprecated LAPACK and LAPACKE routines
296190option (BUILD_DEPRECATED "Build deprecated routines" OFF )
297191message (STATUS "Build deprecated routines: ${BUILD_DEPRECATED} " )
@@ -403,6 +297,27 @@ endif()
403297if (NOT LATESTLAPACK_FOUND)
404298 message (STATUS "Using supplied NETLIB LAPACK implementation" )
405299 set (LAPACK_LIBRARIES ${LAPACKLIB} )
300+
301+ enable_language (Fortran)
302+
303+ # Check for any necessary platform specific compiler flags
304+ include (CheckLAPACKCompilerFlags)
305+ CheckLAPACKCompilerFlags()
306+
307+ # Check second function
308+ include (CheckTimeFunction)
309+ set (TIME_FUNC NONE)
310+ CHECK_TIME_FUNCTION(NONE TIME_FUNC)
311+ CHECK_TIME_FUNCTION(INT_CPU_TIME TIME_FUNC)
312+ CHECK_TIME_FUNCTION(EXT_ETIME TIME_FUNC)
313+ CHECK_TIME_FUNCTION(EXT_ETIME_ TIME_FUNC)
314+ CHECK_TIME_FUNCTION(INT_ETIME TIME_FUNC)
315+
316+ # Set second function
317+ message (STATUS "--> Will use second_${TIME_FUNC} .f and dsecnd_${TIME_FUNC} .f as timing function." )
318+ set (SECOND_SRC ${LAPACK_SOURCE_DIR} /INSTALL /second_${TIME_FUNC} .f)
319+ set (DSECOND_SRC ${LAPACK_SOURCE_DIR} /INSTALL /dsecnd_${TIME_FUNC} .f)
320+
406321 add_subdirectory (SRC)
407322else ()
408323 set (CMAKE_EXE_LINKER_FLAGS
@@ -438,6 +353,7 @@ if(BUILD_TESTING OR LAPACKE_WITH_TMG)
438353 if (LATESTLAPACK_FOUND AND LAPACKE_WITH_TMG)
439354 set (CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES} )
440355 # Check if dlatms (part of tmg) is found
356+ include (CheckFortranFunctionExists)
441357 CHECK_FORTRAN_FUNCTION_EXISTS("dlatms" LAPACK_WITH_TMGLIB_FOUND)
442358 unset (CMAKE_REQUIRED_LIBRARIES)
443359 if (NOT LAPACK_WITH_TMGLIB_FOUND)
@@ -452,9 +368,7 @@ endif()
452368set (LAPACK_INSTALL_EXPORT_NAME ${LAPACK_INSTALL_EXPORT_NAME_CACHE} )
453369unset (LAPACK_INSTALL_EXPORT_NAME_CACHE)
454370
455- if (LAPACKE)
456- add_subdirectory (LAPACKE)
457- endif ()
371+ add_subdirectory (LAPACKE)
458372
459373
460374#-------------------------------------
0 commit comments