diff options
-rw-r--r-- | Modules/CMakeAddFortranSubdirectory.cmake | 10 | ||||
-rw-r--r-- | Modules/FindBLAS.cmake | 217 | ||||
-rw-r--r-- | Modules/FindLAPACK.cmake | 136 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 1 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 34 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 5 | ||||
-rw-r--r-- | Source/cmMakefile.h | 2 | ||||
-rw-r--r-- | Source/cmake.cxx | 2 | ||||
-rw-r--r-- | Source/cmake.h | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0037/RunCMakeTest.cmake | 25 | ||||
-rw-r--r-- | Tests/RunCMake/Ninja/CustomCommandJobPool.cmake | 1 |
13 files changed, 297 insertions, 142 deletions
diff --git a/Modules/CMakeAddFortranSubdirectory.cmake b/Modules/CMakeAddFortranSubdirectory.cmake index c02aa2c..69a8417 100644 --- a/Modules/CMakeAddFortranSubdirectory.cmake +++ b/Modules/CMakeAddFortranSubdirectory.cmake @@ -149,17 +149,9 @@ function(cmake_add_fortran_subdirectory subdir) -P ${build_dir}/config_mingw.cmake BUILD_COMMAND ${CMAKE_COMMAND} -P ${build_dir}/build_mingw.cmake + BUILD_ALWAYS 1 INSTALL_COMMAND "" ) - # make the external project always run make with each build - externalproject_add_step(${project_name}_build forcebuild - COMMAND ${CMAKE_COMMAND} - -E rm -f - ${CMAKE_CURRENT_BUILD_DIR}/${project_name}-prefix/src/${project_name}-stamp/${project_name}-build - DEPENDEES configure - DEPENDERS build - ALWAYS 1 - ) # create imported targets for all libraries foreach(lib ${libraries}) add_library(${lib} SHARED IMPORTED GLOBAL) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 23b5fa7..ed11364 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -41,6 +41,7 @@ The following variables may be set to influence this module's behavior: * ``Intel10_64lp_seq`` (intel mkl v10+ 64 bit, sequential code, lp64 model) * ``Intel10_64ilp`` (intel mkl v10+ 64 bit, threaded code, ilp64 model) * ``Intel10_64ilp_seq`` (intel mkl v10+ 64 bit, sequential code, ilp64 model) + * ``Intel10_64_dyn`` (intel mkl v10+ 64 bit, single dynamic library) * ``Intel`` (obsolete versions of mkl 32 and 64 bit) * ``ACML`` * ``ACML_MP`` @@ -76,7 +77,8 @@ This module defines the following variables: .. note:: - C or CXX must be enabled to use Intel Math Kernel Library (MKL) + C, CXX or Fortran must be enabled to detect a BLAS library. + C or CXX must be enabled to use Intel Math Kernel Library (MKL). For example, to use Intel MKL libraries and/or Intel compiler: @@ -88,8 +90,10 @@ This module defines the following variables: Hints ^^^^^ -Set ``MKLROOT`` environment variable to a directory that contains an MKL -installation. +Set the ``MKLROOT`` environment variable to a directory that contains an MKL +installation, or add the directory to the dynamic library loader environment +variable for your platform (``LIB``, ``DYLD_LIBRARY_PATH`` or +``LD_LIBRARY_PATH``). #]=======================================================================] @@ -113,8 +117,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) cmake_push_check_state() set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY}) -set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - if(BLA_PREFER_PKGCONFIG) find_package(PkgConfig) pkg_check_modules(PKGC_BLAS blas) @@ -125,9 +127,23 @@ if(BLA_PREFER_PKGCONFIG) endif() endif() +set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) +if(BLA_STATIC) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() +else() + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif() +endif() + # TODO: move this stuff to a separate module -macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs) +macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _addlibdir _subdirs) # This macro checks for the existence of the combination of fortran libraries # given by _list. If the combination is found, this macro checks (using the # Check_Fortran_Function_Exists macro) whether can link against that library @@ -138,52 +154,42 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs) # N.B. _prefix is the prefix applied to the names of all cached variables that # are generated internally and marked advanced by this macro. - - set(_libdir ${ARGN}) + # _addlibdir is a list of additional search paths. _subdirs is a list of path + # suffixes to be used by find_library(). set(_libraries_work TRUE) set(${LIBRARIES}) set(_combined_name) - if(NOT _libdir) - if(WIN32) - set(_libdir ENV LIB) - elseif(APPLE) - set(_libdir ENV DYLD_LIBRARY_PATH) - else() - set(_libdir ENV LD_LIBRARY_PATH) - endif() - endif() - list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + if(WIN32) + list(APPEND _addlibdir ENV LIB) + elseif(APPLE) + list(APPEND _addlibdir ENV DYLD_LIBRARY_PATH) + else() + list(APPEND _addlibdir ENV LD_LIBRARY_PATH) + endif() + list(APPEND _addlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") foreach(_library ${_list}) - set(_combined_name ${_combined_name}_${_library}) - if(NOT "${_threadlibs}" STREQUAL "") - set(_combined_name ${_combined_name}_threadlibs) - endif() - if(_libraries_work) - if(BLA_STATIC) - if(WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif() - if(APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - else() - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif() - else() - if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - # for ubuntu's libblas3gf and liblapack3gf packages - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) - endif() + if(_library MATCHES "^-Wl,--(start|end)-group$") + # Respect linker flags like --start/end-group (required by MKL) + set(${LIBRARIES} ${${LIBRARIES}} "${_library}") + else() + set(_combined_name ${_combined_name}_${_library}) + if(NOT "${_threadlibs}" STREQUAL "") + set(_combined_name ${_combined_name}_threadlibs) + endif() + if(_libraries_work) + find_library(${_prefix}_${_library}_LIBRARY + NAMES ${_library} + PATHS ${_addlibdir} + PATH_SUFFIXES ${_subdirs} + ) + #message("DEBUG: find_library(${_library}) got ${${_prefix}_${_library}_LIBRARY}") + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS ${_libdir} - ) - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endforeach() @@ -233,6 +239,8 @@ if(BLA_VENDOR STREQUAL "All") "" "" "" + "" + "" ) endif() endif() @@ -249,6 +257,13 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") set(BLAS_mkl_DLL_SUFFIX "_dll") endif() else() + if(BLA_STATIC) + set(BLAS_mkl_START_GROUP "-Wl,--start-group") + set(BLAS_mkl_END_GROUP "-Wl,--end-group") + else() + set(BLAS_mkl_START_GROUP "") + set(BLAS_mkl_END_GROUP "") + endif() # Switch to GNU Fortran support layer if needed (but not on Apple, where MKL does not provide it) if(CMAKE_Fortran_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT APPLE) set(BLAS_mkl_INTFACE "gf") @@ -287,6 +302,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") endif() + if(BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN "mkl_blas95_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX} mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}") @@ -294,11 +310,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") # Add threading/sequential libs set(BLAS_SEARCH_LIBS_WIN_THREAD "") - if(BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") - endif() - if(NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") # old version list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") @@ -306,6 +318,10 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") endif() + if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") + endif() # Cartesian product of the above foreach(MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) @@ -322,7 +338,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") # mkl >= 10.3 list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}") + "${BLAS_mkl_START_GROUP} mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}") endif() if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") # old version @@ -331,11 +347,11 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") # mkl >= 10.3 list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}") + "${BLAS_mkl_START_GROUP} mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}") endif() if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core") + "${BLAS_mkl_START_GROUP} mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core ${BLAS_mkl_END_GROUP}") endif() endif() else() @@ -355,7 +371,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") # Add threading/sequential libs set(BLAS_SEARCH_LIBS_WIN_THREAD "") - if(NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") # old version list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") @@ -363,7 +379,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") endif() - if(BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") endif() @@ -383,7 +399,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") # mkl >= 10.3 list(APPEND BLAS_SEARCH_LIBS - "mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}") + "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}") endif() if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") # old version @@ -392,11 +408,11 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") # mkl >= 10.3 list(APPEND BLAS_SEARCH_LIBS - "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}") + "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}") endif() if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS - "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core") + "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core ${BLAS_mkl_END_GROUP}") endif() #older vesions of intel mkl libs @@ -411,22 +427,32 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") endif() endif() - if(DEFINED ENV{MKLROOT}) - if(BLA_VENDOR STREQUAL "Intel10_32") - set(_BLAS_MKLROOT_LIB_DIR "$ENV{MKLROOT}/lib/ia32") - elseif(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$") - set(_BLAS_MKLROOT_LIB_DIR "$ENV{MKLROOT}/lib/intel64") - endif() + if(BLA_VENDOR MATCHES "^Intel10_64_dyn$" OR BLA_VENDOR STREQUAL "All") + # mkl >= 10.3 with single dynamic library + list(APPEND BLAS_SEARCH_LIBS + "mkl_rt") endif() - if(_BLAS_MKLROOT_LIB_DIR) - if(WIN32) - string(APPEND _BLAS_MKLROOT_LIB_DIR "_win") - elseif(APPLE) - string(APPEND _BLAS_MKLROOT_LIB_DIR "_mac") - else() - string(APPEND _BLAS_MKLROOT_LIB_DIR "_lin") - endif() + + # MKL uses a multitude of partially platform-specific subdirectories: + if(BLA_VENDOR STREQUAL "Intel10_32") + set(BLAS_mkl_ARCH_NAME "ia32") + else() + set(BLAS_mkl_ARCH_NAME "intel64") + endif() + if(WIN32) + set(BLAS_mkl_OS_NAME "win") + elseif(APPLE) + set(BLAS_mkl_OS_NAME "mac") + else() + set(BLAS_mkl_OS_NAME "lin") + endif() + if(DEFINED ENV{MKLROOT}) + set(BLAS_mkl_MKLROOT "$ENV{MKLROOT}") endif() + set(BLAS_mkl_LIB_PATH_SUFFIXES + "compiler/lib" "compiler/lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}" + "mkl/lib" "mkl/lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}" + "lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}") foreach(IT ${BLAS_SEARCH_LIBS}) string(REPLACE " " ";" SEARCH_LIBS ${IT}) @@ -438,7 +464,8 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") "" "${SEARCH_LIBS}" "${CMAKE_THREAD_LIBS_INIT};${BLAS_mkl_LM};${BLAS_mkl_LDL}" - "${_BLAS_MKLROOT_LIB_DIR}" + "${BLAS_mkl_MKLROOT}" + "${BLAS_mkl_LIB_PATH_SUFFIXES}" ) endif() endforeach() @@ -450,6 +477,10 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") unset(BLAS_mkl_DLL_SUFFIX) unset(BLAS_mkl_LM) unset(BLAS_mkl_LDL) + unset(BLAS_mkl_MKLROOT) + unset(BLAS_mkl_ARCH_NAME) + unset(BLAS_mkl_OS_NAME) + unset(BLAS_mkl_LIB_PATH_SUFFIXES) endif() endif() endif() @@ -472,6 +503,8 @@ if(BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") "" "goto2" "" + "" + "" ) endif() endif() @@ -486,6 +519,8 @@ if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") "" "openblas" "" + "" + "" ) endif() if(NOT BLAS_LIBRARIES AND (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED)) @@ -501,6 +536,8 @@ if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") "" "openblas" "${CMAKE_THREAD_LIBS_INIT}" + "" + "" ) endif() endif() @@ -515,6 +552,8 @@ if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") "" "blis" "" + "" + "" ) endif() endif() @@ -529,6 +568,8 @@ if(BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") "" "blas;f77blas;atlas" "" + "" + "" ) endif() endif() @@ -543,6 +584,8 @@ if(BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") "" "sgemm;dgemm;blas" "" + "" + "" ) endif() endif() @@ -557,6 +600,8 @@ if(BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") "" "cxml" "" + "" + "" ) endif() endif() @@ -571,6 +616,8 @@ if(BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") "" "dxml" "" + "" + "" ) endif() endif() @@ -585,6 +632,8 @@ if(BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") "-xlic_lib=sunperf" "sunperf;sunmath" "" + "" + "" ) if(BLAS_LIBRARIES) set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf") @@ -602,6 +651,8 @@ if(BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") "" "scsl" "" + "" + "" ) endif() endif() @@ -616,6 +667,8 @@ if(BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") "" "complib.sgimath" "" + "" + "" ) endif() endif() @@ -630,6 +683,8 @@ if(BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") "" "essl;blas" "" + "" + "" ) endif() endif() @@ -706,7 +761,7 @@ if(BLA_VENDOR STREQUAL "ACML_MP") BLAS_LIBRARIES BLAS sgemm - "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS} + "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS} "" ) if(BLAS_LIBRARIES) break() @@ -718,7 +773,7 @@ elseif(BLA_VENDOR STREQUAL "ACML_GPU") BLAS_LIBRARIES BLAS sgemm - "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} + "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} "" ) if(BLAS_LIBRARIES) break() @@ -730,7 +785,7 @@ else() BLAS_LIBRARIES BLAS sgemm - "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} + "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} "" ) if(BLAS_LIBRARIES) break() @@ -747,6 +802,8 @@ if(NOT BLAS_LIBRARIES) "" "acml;acml_mv" "" + "" + "" ) endif() if(NOT BLAS_LIBRARIES) @@ -757,6 +814,8 @@ if(NOT BLAS_LIBRARIES) "" "acml_mp;acml_mv" "" + "" + "" ) endif() if(NOT BLAS_LIBRARIES) @@ -767,6 +826,8 @@ if(NOT BLAS_LIBRARIES) "" "acml;acml_mv;CALBLAS" "" + "" + "" ) endif() endif() # ACML @@ -781,6 +842,8 @@ if(BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") "" "Accelerate" "" + "" + "" ) endif() endif() @@ -795,6 +858,8 @@ if(BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") "" "vecLib" "" + "" + "" ) endif() endif() @@ -809,6 +874,8 @@ if(BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") "" "blas" "" + "" + "" ) endif() endif() diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 3aa3de4..8ade0b1 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -33,6 +33,7 @@ The following variables may be set to influence this module's behavior: * ``Intel10_64lp_seq`` (intel mkl v10+ 64 bit, sequential code, lp64 model) * ``Intel10_64ilp`` (intel mkl v10+ 64 bit, threaded code, ilp64 model) * ``Intel10_64ilp_seq`` (intel mkl v10+ 64 bit, sequential code, ilp64 model) + * ``Intel10_64_dyn`` (intel mkl v10+ 64 bit, single dynamic library) * ``Intel`` (obsolete versions of mkl 32 and 64 bit) * ``ACML`` * ``Apple`` @@ -62,7 +63,8 @@ This module defines the following variables: .. note:: - C or CXX must be enabled to use Intel Math Kernel Library (MKL) + C, CXX or Fortran must be enabled to detect a BLAS/LAPACK library. + C or CXX must be enabled to use Intel Math Kernel Library (MKL). For example, to use Intel MKL libraries and/or Intel compiler: @@ -92,14 +94,26 @@ include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) cmake_push_check_state() set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY}) -set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - set(LAPACK_FOUND FALSE) set(LAPACK95_FOUND FALSE) +set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) +if(BLA_STATIC) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() +else() + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif() +endif() + # TODO: move this stuff to a separate module -macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _blas) +macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _addlibdir _subdirs _blas) # This macro checks for the existence of the combination of fortran libraries # given by _list. If the combination is found, this macro checks (using the # Check_Fortran_Function_Exists macro) whether can link against that library @@ -110,58 +124,45 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _b # N.B. _prefix is the prefix applied to the names of all cached variables that # are generated internally and marked advanced by this macro. + # _addlibdir is a list of additional search paths. _subdirs is a list of path + # suffixes to be used by find_library(). set(_libraries_work TRUE) set(${LIBRARIES}) set(_combined_name) - if(NOT _libdir) - if(WIN32) - set(_libdir ENV LIB) - elseif(APPLE) - set(_libdir ENV DYLD_LIBRARY_PATH) - else() - set(_libdir ENV LD_LIBRARY_PATH) - endif() - endif() - list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + if(WIN32) + list(APPEND _addlibdir ENV LIB) + elseif(APPLE) + list(APPEND _addlibdir ENV DYLD_LIBRARY_PATH) + else() + list(APPEND _addlibdir ENV LD_LIBRARY_PATH) + endif() + list(APPEND _addlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") foreach(_library ${_list}) - set(_combined_name ${_combined_name}_${_library}) - - if(_libraries_work) - if(BLA_STATIC) - if(WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif() - if(APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - else() - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif() - else() - if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - # for ubuntu's libblas3gf and liblapack3gf packages - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) - endif() + if(_library MATCHES "^-Wl,--(start|end)-group$") + # Respect linker flags like --start/end-group (required by MKL) + set(${LIBRARIES} ${${LIBRARIES}} "${_library}") + else() + set(_combined_name ${_combined_name}_${_library}) + if(_libraries_work) + find_library(${_prefix}_${_library}_LIBRARY + NAMES ${_library} + PATHS ${_addlibdir} + PATH_SUFFIXES ${_subdirs} + ) + #message("DEBUG: find_library(${_library}) got ${${_prefix}_${_library}_LIBRARY}") + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS ${_libdir} - ) - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endforeach() if(_libraries_work) # Test this combination of libraries. - if(UNIX AND BLA_STATIC) - set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group" ${${LIBRARIES}} ${_blas} "-Wl,--end-group" ${_threadlibs}) - else() - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threadlibs}) - endif() + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threadlibs}) #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) @@ -246,11 +247,32 @@ if(BLAS_FOUND) set(_LIBRARIES LAPACK_LIBRARIES) set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) - # old + # old and new >= 10.3 list(APPEND LAPACK_SEARCH_LIBS "mkl_lapack") endif() + # MKL uses a multitude of partially platform-specific subdirectories: + if(BLA_VENDOR STREQUAL "Intel10_32") + set(LAPACK_mkl_ARCH_NAME "ia32") + else() + set(LAPACK_mkl_ARCH_NAME "intel64") + endif() + if(WIN32) + set(LAPACK_mkl_OS_NAME "win") + elseif(APPLE) + set(LAPACK_mkl_OS_NAME "mac") + else() + set(LAPACK_mkl_OS_NAME "lin") + endif() + if(DEFINED ENV{MKLROOT}) + set(LAPACK_mkl_MKLROOT "$ENV{MKLROOT}") + endif() + set(LAPACK_mkl_LIB_PATH_SUFFIXES + "compiler/lib" "compiler/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" + "mkl/lib" "mkl/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" + "lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}") + # First try empty lapack libs if(NOT ${_LIBRARIES}) check_lapack_libraries( @@ -259,20 +281,26 @@ if(BLAS_FOUND) ${LAPACK_mkl_SEARCH_SYMBOL} "" "" - "" + "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" + "${LAPACK_mkl_MKLROOT}" + "${LAPACK_mkl_LIB_PATH_SUFFIXES}" "${_BLAS_LIBRARIES}" ) endif() + # Then try the search libs foreach(IT ${LAPACK_SEARCH_LIBS}) + string(REPLACE " " ";" SEARCH_LIBS ${IT}) if(NOT ${_LIBRARIES}) check_lapack_libraries( ${_LIBRARIES} LAPACK ${LAPACK_mkl_SEARCH_SYMBOL} "" - "${IT}" + "${SEARCH_LIBS}" "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" + "${LAPACK_mkl_MKLROOT}" + "${LAPACK_mkl_LIB_PATH_SUFFIXES}" "${_BLAS_LIBRARIES}" ) endif() @@ -282,6 +310,10 @@ if(BLAS_FOUND) unset(LAPACK_mkl_SEARCH_SYMBOL) unset(LAPACK_mkl_LM) unset(LAPACK_mkl_LDL) + unset(LAPACK_mkl_MKLROOT) + unset(LAPACK_mkl_ARCH_NAME) + unset(LAPACK_mkl_OS_NAME) + unset(LAPACK_mkl_LIB_PATH_SUFFIXES) endif() endif() endif() @@ -296,6 +328,8 @@ if(BLAS_FOUND) "" "goto2" "" + "" + "" "${BLAS_LIBRARIES}" ) endif() @@ -311,6 +345,8 @@ if(BLAS_FOUND) "" "openblas" "" + "" + "" "${BLAS_LIBRARIES}" ) endif() @@ -326,6 +362,8 @@ if(BLAS_FOUND) "" "flame" "" + "" + "" "${BLAS_LIBRARIES}" ) endif() @@ -348,6 +386,8 @@ if(BLAS_FOUND) "" "Accelerate" "" + "" + "" "${BLAS_LIBRARIES}" ) endif() @@ -363,6 +403,8 @@ if(BLAS_FOUND) "" "vecLib" "" + "" + "" "${BLAS_LIBRARIES}" ) endif() @@ -380,6 +422,8 @@ if(BLAS_FOUND) "" "lapack" "" + "" + "" "${BLAS_LIBRARIES}" ) endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 74d779f..413b587 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 16) -set(CMake_VERSION_PATCH 20200128) +set(CMake_VERSION_PATCH 20200129) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 45e13bc..1f084f5 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2527,6 +2527,7 @@ void cmGlobalGenerator::AddGlobalTarget_RebuildCache( gti.PerConfig = false; cmCustomCommandLine singleLine; singleLine.push_back(cmSystemTools::GetCMakeCommand()); + singleLine.push_back("--regenerate-during-build"); singleLine.push_back("-S$(CMAKE_SOURCE_DIR)"); singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); gti.CommandLines.push_back(std::move(singleLine)); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 2dd89e3..d093c43 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -528,6 +528,19 @@ void cmGlobalNinjaGenerator::Generate() this->CloseRulesFileStream(); this->CloseBuildFileStreams(); +#ifdef _WIN32 + // The ninja tools will not be able to update metadata on Windows + // when we are re-generating inside an existing 'ninja' invocation + // because the outer tool has the files open for write. + if (!this->GetCMakeInstance()->GetRegenerateDuringBuild()) +#endif + { + this->CleanMetaData(); + } +} + +void cmGlobalNinjaGenerator::CleanMetaData() +{ auto run_ninja_tool = [this](std::vector<char const*> const& args) { std::vector<std::string> command; command.push_back(this->NinjaCommand); @@ -549,22 +562,33 @@ void cmGlobalNinjaGenerator::Generate() } }; + // Can the tools below expect 'build.ninja' to be loadable? + bool const expectBuildManifest = + !this->IsMultiConfig() && this->OutputPathPrefix.empty(); + + // Skip some ninja tools if they need 'build.ninja' but it is missing. + bool const missingBuildManifest = expectBuildManifest && + (this->NinjaSupportsCleanDeadTool || + this->NinjaSupportsUnconditionalRecompactTool) && + !cmSystemTools::FileExists("build.ninja"); + // The `cleandead` tool needs to know about all outputs in the build we just // wrote out. Ninja-Multi doesn't have a single `build.ninja` we can use that // is the union of all generated configurations, so we can't run it reliably // in that case. - if (this->NinjaSupportsCleanDeadTool && !this->IsMultiConfig()) { + if (this->NinjaSupportsCleanDeadTool && expectBuildManifest && + !missingBuildManifest) { run_ninja_tool({ "cleandead" }); } // The `recompact` tool loads the manifest. As above, we don't have a single // `build.ninja` to load for this in Ninja-Multi. This may be relaxed in the // future pending further investigation into how Ninja works upstream // (ninja#1721). - if (this->NinjaSupportsUnconditionalRecompactTool && - !this->IsMultiConfig()) { + if (this->NinjaSupportsUnconditionalRecompactTool && expectBuildManifest && + !missingBuildManifest) { run_ninja_tool({ "recompact" }); } - if (this->NinjaSupportsRestatTool) { + if (this->NinjaSupportsRestatTool && this->OutputPathPrefix.empty()) { // XXX(ninja): We only list `build.ninja` entry files here because CMake // *always* rewrites these files on a reconfigure. If CMake ever gets // smarter about this, all CMake-time created/edited files listed as @@ -1514,7 +1538,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) { cmNinjaRule rule("RERUN_CMAKE"); rule.Command = - cmStrCat(CMakeCmd(), " -S", + cmStrCat(CMakeCmd(), " --regenerate-during-build -S", lg->ConvertToOutputFormat(lg->GetSourceDirectory(), cmOutputConverter::SHELL), " -B", diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index d00a061..9d5521a 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -438,6 +438,7 @@ private: bool OpenRulesFileStream(); void CloseRulesFileStream(); + void CleanMetaData(); /// Write the common disclaimer text at the top of each build file. void WriteDisclaimer(std::ostream& os); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e43ee8a..b2e59bd 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -7,7 +7,6 @@ #include <algorithm> #include <cassert> #include <cctype> -#include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> @@ -334,7 +333,7 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const Json::StreamWriterBuilder builder; builder["indentation"] = ""; val["file"] = full_path; - val["line"] = static_cast<std::int64_t>(lff.Line); + val["line"] = static_cast<Json::Value::Int64>(lff.Line); val["cmd"] = lff.Name.Original; val["args"] = Json::Value(Json::arrayValue); for (std::string const& arg : args) { @@ -342,7 +341,7 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const } val["time"] = cmSystemTools::GetTime(); val["frame"] = - static_cast<std::uint64_t>(this->ExecutionStatusStack.size()); + static_cast<Json::Value::UInt64>(this->ExecutionStatusStack.size()); msg << Json::writeString(builder, val); #endif break; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 9e9c2b8..68f2c2f 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -135,7 +135,7 @@ public: std::unique_ptr<cmFunctionBlocker> RemoveFunctionBlocker(); /** - * Try running cmake and building a file. This is used for dynalically + * Try running cmake and building a file. This is used for dynamically * loaded commands, not as part of the usual build process. */ int TryCompile(const std::string& srcdir, const std::string& bindir, diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 721d535..8214c52 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -663,6 +663,8 @@ void cmake::SetArgs(const std::vector<std::string>& args) } else if ((i < args.size() - 1) && (arg.find("--check-stamp-list", 0) == 0)) { this->CheckStampList = args[++i]; + } else if (arg == "--regenerate-during-build") { + this->RegenerateDuringBuild = true; } #if defined(CMAKE_HAVE_VS_GENERATORS) else if ((i < args.size() - 1) && diff --git a/Source/cmake.h b/Source/cmake.h index c65b821..35425ec 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -547,6 +547,8 @@ public: } cmStateSnapshot GetCurrentSnapshot() const { return this->CurrentSnapshot; } + bool GetRegenerateDuringBuild() const { return this->RegenerateDuringBuild; } + protected: void RunCheckForUnusedVariables(); int HandleDeleteCacheVariables(const std::string& var); @@ -621,6 +623,7 @@ private: FileExtensions FortranFileExtensions; bool ClearBuildSystem = false; bool DebugTryCompile = false; + bool RegenerateDuringBuild = false; std::unique_ptr<cmFileTimeCache> FileTimeCache; std::string GraphVizFile; InstalledFilesMap InstalledFiles; diff --git a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake index 98274f0..5952279 100644 --- a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake @@ -1,5 +1,24 @@ include(RunCMake) +if(RunCMake_GENERATOR MATCHES "^Ninja") + # Detect ninja version so we know what tests can be supported. + execute_process( + COMMAND "${RunCMake_MAKE_PROGRAM}" --version + OUTPUT_VARIABLE ninja_out + ERROR_VARIABLE ninja_out + RESULT_VARIABLE ninja_res + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(ninja_res EQUAL 0 AND "x${ninja_out}" MATCHES "^x[0-9]+\\.[0-9]+") + set(ninja_version "${ninja_out}") + message(STATUS "ninja version: ${ninja_version}") + else() + message(FATAL_ERROR "'ninja --version' reported:\n${ninja_out}") + endif() +else() + set(ninja_version "") +endif() + run_cmake(CMP0037-OLD-space) run_cmake(CMP0037-NEW-space) run_cmake(CMP0037-WARN-space) @@ -9,8 +28,10 @@ if(NOT (WIN32 AND "${RunCMake_GENERATOR}" MATCHES "Make")) run_cmake(CMP0037-WARN-colon) endif() -run_cmake(CMP0037-WARN-reserved) -run_cmake(CMP0037-OLD-reserved) +if(NOT ninja_version VERSION_GREATER_EQUAL 1.10) + run_cmake(CMP0037-WARN-reserved) + run_cmake(CMP0037-OLD-reserved) +endif() run_cmake(CMP0037-NEW-reserved) run_cmake(NEW-cond) diff --git a/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake b/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake index 1e36e65..a96802a 100644 --- a/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake +++ b/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake @@ -1,3 +1,4 @@ +set_property(GLOBAL PROPERTY JOB_POOLS custom_command_pool=2 custom_target_pool=2) add_custom_command( OUTPUT hello.copy.c COMMAND "${CMAKE_COMMAND}" -E copy |