From 9e24b489e0a523ea04a9b729eedbcad5ea8bdc09 Mon Sep 17 00:00:00 2001 From: Boris Basic Date: Sun, 6 Mar 2022 14:54:20 +0100 Subject: [PATCH] Fix Mingw compilation --- CMAKE/FortranMangling.cmake | 12 +- CMakeLists.txt | 23 ++-- scalapack_build.cmake | 224 ------------------------------------ 3 files changed, 17 insertions(+), 242 deletions(-) delete mode 100644 scalapack_build.cmake diff --git a/CMAKE/FortranMangling.cmake b/CMAKE/FortranMangling.cmake index bfe9690f..d03811c3 100644 --- a/CMAKE/FortranMangling.cmake +++ b/CMAKE/FortranMangling.cmake @@ -13,12 +13,16 @@ FUNCTION(COMPILE RESULT) MESSAGE(STATUS "=========") MESSAGE(STATUS "Compiling and Building BLACS INSTALL Testing to set correct variables") - + + if(CMAKE_BUILD_TYPE) + SET(BUILD_TYPE -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}) + endif() + # Configure: EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} - "-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}" - "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "${PROJECT_SOURCE_DIR}//BLACS/INSTALL" - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/BLACS/INSTALL/ + "${PROJECT_SOURCE_DIR}/BLACS/INSTALL" + -G ${CMAKE_GENERATOR} ${BUILD_TYPE} + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/BLACS/INSTALL/ RESULT_VARIABLE RESVAR OUTPUT_VARIABLE LOG1_OUT ERROR_VARIABLE LOG1_ERR ) if(RESVAR EQUAL 0) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc1c7c4b..0c33719e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,10 +21,7 @@ endif () # # MPI # -#set(MPI_BASE_DIR "/Users/julie/opt/openmpi/" CACHE PATH "MPI Path") -#set(MPI_BASE_DIR "/Users/julie/opt/mpich2/" CACHE PATH "MPI Path") set(CMAKE_PREFIX_PATH "${MPI_BASE_DIR};${CMAKE_PREFIX_PATH}") -#set(MPI_COMPILER ${MPI_BASE_DIR}/bin/mpicc) find_package(MPI) if (MPI_FOUND) @@ -51,8 +48,6 @@ if (MPI_FOUND) DOC "MPI Fortran compiler.") MARK_AS_ADVANCED(MPI_Fortran_COMPILER) - - if ("${MPI_Fortran_COMPILER}" STREQUAL "MPI_Fortran_COMPILER-NOTFOUND") message(ERROR "--> MPI Fortran Compiler NOT FOUND (please set MPI_BASE_DIR accordingly") else() @@ -161,18 +156,18 @@ else(LAPACK_FOUND) message(STATUS "--> LAPACK and BLAS were not found. Reference LAPACK and BLAS will be downloaded and installed") include(ExternalProject) ExternalProject_Add( - lapack - URL http://www.netlib.org/lapack/lapack.tgz - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${SCALAPACK_BINARY_DIR} + lapack + URL http://www.netlib.org/lapack/lapack.tgz + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${SCALAPACK_BINARY_DIR} PREFIX ${SCALAPACK_BINARY_DIR}/dependencies ) - if (UNIX) + if (NOT MSVC) SET(LAPACK_LIBRARIES ${SCALAPACK_BINARY_DIR}/lib/liblapack.a CACHE STRING "LAPACK library" FORCE) SET(BLAS_LIBRARIES ${SCALAPACK_BINARY_DIR}/lib/libblas.a CACHE STRING "BLAS library" FORCE) - else (UNIX) # On Windows + else () # MSVC SET(LAPACK_LIBRARIES ${SCALAPACK_BINARY_DIR}/lib/liblapack.lib CACHE STRING "LAPACK library" FORCE) SET(BLAS_LIBRARIES ${SCALAPACK_BINARY_DIR}/lib/libblas.lib CACHE STRING "BLAS library" FORCE) - endif (UNIX) + endif () ENDIF() ENDIF() @@ -234,14 +229,14 @@ add_subdirectory(SRC) append_subdir_files(src "SRC") append_subdir_files(src-C "SRC") -if (UNIX) +if (NOT MSVC) add_library(scalapack ${blacs} ${tools} ${tools-C} ${extra_lapack} ${pblas} ${pblas-F} ${ptzblas} ${ptools} ${pbblas} ${redist} ${src} ${src-C}) set_target_properties(scalapack PROPERTIES VERSION ${SCALAPACK_VERSION} SOVERSION ${SCALAPACK_VERSION_MAJOR}.${SCALAPACK_VERSION_MINOR}) target_link_libraries( scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) scalapack_install_library(scalapack) -else (UNIX) # Need to separate Fortran and C Code +else () # Need to separate Fortran and C Code OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON ) add_library(scalapack ${blacs} ${tools-C} ${pblas} ${ptools} ${redist} ${src-C}) set_target_properties(scalapack PROPERTIES @@ -255,7 +250,7 @@ else (UNIX) # Need to separate Fortran and C Code target_link_libraries( scalapack-F ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) scalapack_install_library(scalapack) scalapack_install_library(scalapack-F) -endif (UNIX) +endif () if(TARGET lapack) add_dependencies(scalapack lapack) diff --git a/scalapack_build.cmake b/scalapack_build.cmake deleted file mode 100644 index ba30a872..00000000 --- a/scalapack_build.cmake +++ /dev/null @@ -1,224 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -################################################################### -# The values in this section must always be provided -################################################################### -if(UNIX) - if(NOT compiler) - set(compiler gcc) - endif(NOT compiler) - if(NOT c_compiler) - set(c_compiler gcc) - endif(NOT c_compiler) - if(NOT full_compiler) - set(full_compiler g++) - endif(NOT full_compiler) -endif(UNIX) - -if(EXISTS "/proc/cpuinfo") - set(parallel 1) - file(STRINGS "/proc/cpuinfo" CPUINFO) - foreach(line ${CPUINFO}) - if("${line}" MATCHES processor) - math(EXPR parallel "${parallel} + 1") - endif() - endforeach(line) -endif() - -if(WIN32) - set(VSLOCATIONS - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\6.0\\Setup;VsCommonDir]/MSDev98/Bin" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.0\\Setup\\VS;EnvironmentDirectory]" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1\\Setup\\VS;EnvironmentDirectory]" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup;Dbghelp_path]" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VS;EnvironmentDirectory]" - ) - set(GENERATORS - "Visual Studio 6" - "Visual Studio 7" - "Visual Studio 7 .NET 2003" - "Visual Studio 8 2005" - "Visual Studio 8 2005" - "Visual Studio 9 2008" - ) - set(vstype 0) - foreach(p ${VSLOCATIONS}) - get_filename_component(VSPATH ${p} PATH) - if(NOT "${VSPATH}" STREQUAL "/" AND EXISTS "${VSPATH}") - message(" found VS install = ${VSPATH}") - set(genIndex ${vstype}) - endif() - math(EXPR vstype "${vstype} +1") - endforeach() - if(NOT DEFINED genIndex) - message(FATAL_ERROR "Could not find installed visual stuido") - endif() - list(GET GENERATORS ${genIndex} GENERATOR) - set(CTEST_CMAKE_GENERATOR "${GENERATOR}") - message("${CTEST_CMAKE_GENERATOR} - found") - set(compiler cl) -endif(WIN32) - -find_program(HOSTNAME NAMES hostname) -find_program(UNAME NAMES uname) - -# Get the build name and hostname -exec_program(${HOSTNAME} ARGS OUTPUT_VARIABLE hostname) -string(REGEX REPLACE "[/\\\\+<> #]" "-" hostname "${hostname}") - -message("HOSTNAME: ${hostname}") -# default to parallel 1 -if(NOT DEFINED parallel) - set(parallel 1) -endif(NOT DEFINED parallel) - -# find SVN -find_program(SVN svn PATHS $ENV{HOME}/bin /vol/local/bin) -if(NOT SVN) - message(FATAL_ERROR "SVN not found") -endif() - -set(CTEST_UPDATE_COMMAND ${SVN}) -macro(getuname name flag) - exec_program("${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}") - string(REGEX REPLACE "[/\\\\+<> #]" "-" "${name}" "${${name}}") - string(REGEX REPLACE "^(......|.....|....|...|..|.).*" "\\1" "${name}" "${${name}}") -endmacro(getuname) - -getuname(osname -s) -getuname(osver -v) -getuname(osrel -r) -getuname(cpu -m) -if("${osname}" MATCHES Darwin) - find_program(SW_VER sw_vers) - execute_process(COMMAND "${SW_VER}" -productVersion OUTPUT_VARIABLE osver) - string(REPLACE "\n" "" osver "${osver}") - set(osname "MacOSX") - set(osrel "") - if("${cpu}" MATCHES "Power") - set(cpu "ppc") - endif("${cpu}" MATCHES "Power") -endif("${osname}" MATCHES Darwin) - -if(NOT compiler) - message(FATAL_ERROR "compiler must be set") -endif(NOT compiler) - - -set(BUILDNAME "${osname}${osver}${osrel}${cpu}-${compiler}") -message("BUILDNAME: ${BUILDNAME}") - -# this is the cvs module name that should be checked out -set (CTEST_MODULE_NAME scalapack) -set (CTEST_DIR_NAME "${CTEST_MODULE_NAME}SVN") - -# Settings: -message("NOSPACES = ${NOSPACES}") -if(NOSPACES) - set(CTEST_DASHBOARD_ROOT "$ENV{HOME}/Dashboards/MyTests-${BUILDNAME}") -else(NOSPACES) - set(CTEST_DASHBOARD_ROOT "$ENV{HOME}/Dashboards/My Tests-${BUILDNAME}") -endif(NOSPACES) -set(CTEST_SITE "${hostname}") -set(CTEST_BUILD_NAME "${BUILDNAME}") -set(CTEST_TEST_TIMEOUT "600") - -# CVS command and the checkout command -if(NOT EXISTS "${CTEST_DASHBOARD_ROOT}/${CTEST_DIR_NAME}") - set(CTEST_CHECKOUT_COMMAND - "\"${CTEST_UPDATE_COMMAND}\" co https://icl.cs.utk.edu/svn/scalapack-dev/scalapack/trunk ${CTEST_DIR_NAME}") -endif(NOT EXISTS "${CTEST_DASHBOARD_ROOT}/${CTEST_DIR_NAME}") - -# Set the generator and build configuration -if(NOT DEFINED CTEST_CMAKE_GENERATOR) - set(CTEST_CMAKE_GENERATOR "Unix Makefiles") -endif(NOT DEFINED CTEST_CMAKE_GENERATOR) -set(CTEST_PROJECT_NAME "ScaLAPACK") -set(CTEST_BUILD_CONFIGURATION "Release") - -# Extra special variables -set(ENV{DISPLAY} "") -if(CTEST_CMAKE_GENERATOR MATCHES Makefiles) - set(ENV{CC} "${c_compiler}") - set(ENV{FC} "${f_compiler}") - set(ENV{CXX} "${full_compiler}") -endif(CTEST_CMAKE_GENERATOR MATCHES Makefiles) - -#---------------------------------------------------------------------------------- -# Should not need to edit under this line -#---------------------------------------------------------------------------------- - -# if you do not want to use the default location for a -# dashboard then set this variable to the directory -# the dashboard should be in -make_directory("${CTEST_DASHBOARD_ROOT}") -# these are the the name of the source and binary directory on disk. -# They will be appended to DASHBOARD_ROOT -set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_DIR_NAME}") -set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}-${CTEST_BUILD_NAME}") -set(CTEST_NOTES_FILES "${CTEST_NOTES_FILES}" - "${CMAKE_CURRENT_LIST_FILE}" - ) - -# check for parallel -if(parallel GREATER 1) - if(NOT CTEST_BUILD_COMMAND) - set(CTEST_BUILD_COMMAND "make -j${parallel} -i") - endif(NOT CTEST_BUILD_COMMAND) - - message("Use parallel build") - message("CTEST_BUILD_COMMAND: ${CTEST_BUILD_COMMAND}") - message("CTEST_CONFIGURE_COMMAND: ${CTEST_CONFIGURE_COMMAND}") -endif(parallel GREATER 1) - -################################################################### -# Values for the cmake build -################################################################### - -set( CACHE_CONTENTS " -SITE:STRING=${hostname} -BUILDNAME:STRING=${BUILDNAME} -DART_ROOT:PATH= -SVNCOMMAND:FILEPATH=${CTEST_UPDATE_COMMAND} -DROP_METHOD:STRING=https -DART_TESTING_TIMEOUT:STRING=${CTEST_TEST_TIMEOUT} -# Specific Fortran Compiler (uncomment and add flags directly after = ) -#CMAKE_Fortran_COMPILER:STRING= -# Specific Fortran Compiler Flags (uncomment and add flags directly after = ) -#CMAKE_Fortran_FLAGS:STRING= -# Use Reference BLAS and LAPACK by default -USE_OPTIMIZED_LAPACK_BLAS:OPTION=OFF -" ) - -########################################################################## -# wipe the binary dir -message("Remove binary directory...") -ctest_empty_binary_directory("${CTEST_BINARY_DIRECTORY}") - -message("CTest Directory: ${CTEST_DASHBOARD_ROOT}") -message("Initial checkout: ${CTEST_CVS_CHECKOUT}") -message("Initial cmake: ${CTEST_CMAKE_COMMAND}") -message("CTest command: ${CTEST_COMMAND}") - -# this is the initial cache to use for the binary tree, be careful to escape -# any quotes inside of this string if you use it -file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "${CACHE_CONTENTS}") - -message("Start dashboard...") -ctest_start(Nightly) -#ctest_start(Experimental) -message(" Update") -ctest_update(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) -message(" Configure") -ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -message("read custom files after configure") -ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") -message(" Build") -ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -message(" Test") -ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -message(" Submit") -ctest_submit(RETURN_VALUE res) -message(" All done") - -