From 4fe07a2a3efbc2605e87f1fe66d30601106981d7 Mon Sep 17 00:00:00 2001 From: Reinhold Gschweicher Date: Tue, 23 Jan 2024 08:31:59 +0100 Subject: [PATCH] cmake: unify indent using 4 spaces for all our cmake files Unify the indent used to 4 spaces (just my personal preference) Also update the repo url from google code to github. --- CMakeLists.txt | 528 +++++++++--------- SuiteSparse/CHOLMOD/CMakeLists.txt | 26 +- SuiteSparse/CMakeLists.txt | 62 +- SuiteSparse/KLU/CMakeLists.txt | 2 +- SuiteSparse/SPQR/CMakeLists.txt | 96 ++-- SuiteSparse/SuiteSparse_config/CMakeLists.txt | 7 +- SuiteSparse/UMFPACK/CMakeLists.txt | 5 +- 7 files changed, 377 insertions(+), 349 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f4c68644..9f154e6ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # ----------------------------------------------------------------- # CMake build system for SuiteSparse -# http://code.google.com/p/suitesparse-metis-for-windows/ +# https://github.com/jlblancoc/suitesparse-metis-for-windows # Created by Jose Luis Blanco (University of Almeria) 2013-2014 # Updated by jesnault (jerome.esnault@inria.fr) 2014-01-21 # ----------------------------------------------------------------- @@ -13,7 +13,7 @@ option(WITH_OPENBLAS "Build with OpenBLAS instead of generic BLAS/LAPACK" OFF) option(WITH_MKL "Build with MKL instead of generic BLAS/LAPACK" OFF) if(NOT ${CMAKE_VERSION} VERSION_LESS "3.12.0") - cmake_policy(SET CMP0074 NEW) # Use PKG_ROOT variables. + cmake_policy(SET CMP0074 NEW) # Use PKG_ROOT variables. endif() include(cmake/HunterGate.cmake) @@ -27,29 +27,29 @@ project(SuiteSparseProject) # https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD.html string(COMPARE EQUAL "${CMAKE_CXX_STANDARD}" "" no_cmake_cxx_standard_set) + if(no_cmake_cxx_standard_set) - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_CXX_EXTENSIONS OFF) - message(STATUS "Using default C++ standard ${CMAKE_CXX_STANDARD}") + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) + message(STATUS "Using default C++ standard ${CMAKE_CXX_STANDARD}") else() - message(STATUS "Using user specified C++ standard ${CMAKE_CXX_STANDARD}") + message(STATUS "Using user specified C++ standard ${CMAKE_CXX_STANDARD}") endif() include(checkGetSuiteSparse.cmake) if(BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() - -set(LIBRARY_OUTPUT_PATH ${${PROJECT_NAME}_BINARY_DIR}/lib CACHE PATH "Output directory for libraries" ) -set(EXECUTABLE_OUTPUT_PATH ${${PROJECT_NAME}_BINARY_DIR}/bin CACHE PATH "Output directory for applications" ) +set(LIBRARY_OUTPUT_PATH ${${PROJECT_NAME}_BINARY_DIR}/lib CACHE PATH "Output directory for libraries") +set(EXECUTABLE_OUTPUT_PATH ${${PROJECT_NAME}_BINARY_DIR}/bin CACHE PATH "Output directory for applications") # Override "CMAKE_INSTALL_PREFIX", on Windows if not set: -if(WIN32 AND (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)) - set(CMAKE_INSTALL_PREFIX "${${PROJECT_NAME}_BINARY_DIR}/install" CACHE PATH "Prefix prepended to install directories" FORCE) - message(STATUS "Setting default CMAKE_INSTALL_PREFIX to: ${CMAKE_INSTALL_PREFIX}") +if(WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${${PROJECT_NAME}_BINARY_DIR}/install" CACHE PATH "Prefix prepended to install directories" FORCE) + message(STATUS "Setting default CMAKE_INSTALL_PREFIX to: ${CMAKE_INSTALL_PREFIX}") else() # pass user defined install prefix to SuiteSparse message(STATUS "Using user defined CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") @@ -57,33 +57,35 @@ endif() # allow creating DLLs in Windows without touching the source code: if(NOT ${CMAKE_VERSION} VERSION_LESS "3.4.0" AND WIN32) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() -## get CMAKE_INSTALL_BINDIR and CMAKE_INSTALL_LIBDIR +# # get CMAKE_INSTALL_BINDIR and CMAKE_INSTALL_LIBDIR include(GNUInstallDirs) if(CMAKE_SIZEOF_VOID_P MATCHES "8") - set(SUITESPARSE_LIB_POSTFIX "64") + set(SUITESPARSE_LIB_POSTFIX "64") else() - set(SUITESPARSE_LIB_POSTFIX "") + set(SUITESPARSE_LIB_POSTFIX "") endif() -## get POSTFIX for lib install dir +# # get POSTFIX for lib install dir set(LIB_POSTFIX "${SUITESPARSE_LIB_POSTFIX}" CACHE STRING "suffix for 32/64 inst dir placement") mark_as_advanced(LIB_POSTFIX) # We want libraries to be named "libXXX" and "libXXXd" in all compilers: # ------------------------------------------------------------------------ -set(CMAKE_DEBUG_POSTFIX "d") +set(CMAKE_DEBUG_POSTFIX "d") + if(MSVC) - set(SP_LIB_PREFIX "lib") # Libs are: "libXXX" + set(SP_LIB_PREFIX "lib") # Libs are: "libXXX" endif(MSVC) -## check if we can build metis +# # check if we can build metis set(BUILD_METIS_DEFAULT ON) + if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/SuiteSparse/CHOLMOD/SuiteSparse_metis/CMakeLists.txt") - set(BUILD_METIS_DEFAULT OFF) + set(BUILD_METIS_DEFAULT OFF) endif() set(WITH_CUDA OFF CACHE BOOL "Build with CUDA support") @@ -91,277 +93,301 @@ set(WITH_CUDA OFF CACHE BOOL "Build with CUDA support") set(BUILD_METIS ${BUILD_METIS_DEFAULT} CACHE BOOL "Build METIS for partitioning?") if(BUILD_METIS) - set(METIS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/SuiteSparse/CHOLMOD/SuiteSparse_metis") - # extract METIS version string from metis.h header - set(_METIS_VERSION_HEADER ${METIS_DIR}/include/metis.h) - file(READ ${_METIS_VERSION_HEADER} _METIS_VERSION_CONTENTS) - string(REGEX REPLACE ".*#define METIS_VER_MAJOR[ \t]+([0-9]+).*" "\\1" - METIS_VERSION_MAJOR "${_METIS_VERSION_CONTENTS}") - string(REGEX REPLACE ".*#define METIS_VER_MINOR[ \t]+([0-9]+).*" "\\1" - METIS_VERSION_MINOR "${_METIS_VERSION_CONTENTS}") - string(REGEX REPLACE ".*#define METIS_VER_SUBMINOR[ \t]+([0-9]+).*" "\\1" - METIS_VERSION_PATCH "${_METIS_VERSION_CONTENTS}") - # combine in one variable later passed to generated cmake config file - set(SuiteSparse_METIS_VERSION - ${METIS_VERSION_MAJOR}.${METIS_VERSION_MINOR}.${METIS_VERSION_PATCH}) - message(STATUS "METIS: building with SuiteSparse_METIS_VERSION '${SuiteSparse_METIS_VERSION}'") - # some sanity checks if we managed to extract METIS version numbers - if ("${METIS_VERSION_MAJOR}" STREQUAL "") - message(FATAL_ERROR "METIS: error extracting METIS_VER_MAJOR from metis.h file at '${_METIS_VERSION_HEADER}'") - endif() - if ("${METIS_VERSION_MINOR}" STREQUAL "") - message(FATAL_ERROR "METIS: error extracting METIS_VER_MINOR from metis.h file at '${_METIS_VERSION_HEADER}'") - endif() - if ("${METIS_VERSION_PATCH}" STREQUAL "") - message(FATAL_ERROR "METIS: error extracting METIS_VER_PATCH from metis.h file at '${_METIS_VERSION_HEADER}'") - endif() + set(METIS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/SuiteSparse/CHOLMOD/SuiteSparse_metis") + + # extract METIS version string from metis.h header + set(_METIS_VERSION_HEADER ${METIS_DIR}/include/metis.h) + file(READ ${_METIS_VERSION_HEADER} _METIS_VERSION_CONTENTS) + string(REGEX REPLACE ".*#define METIS_VER_MAJOR[ \t]+([0-9]+).*" "\\1" + METIS_VERSION_MAJOR "${_METIS_VERSION_CONTENTS}") + string(REGEX REPLACE ".*#define METIS_VER_MINOR[ \t]+([0-9]+).*" "\\1" + METIS_VERSION_MINOR "${_METIS_VERSION_CONTENTS}") + string(REGEX REPLACE ".*#define METIS_VER_SUBMINOR[ \t]+([0-9]+).*" "\\1" + METIS_VERSION_PATCH "${_METIS_VERSION_CONTENTS}") + + # combine in one variable later passed to generated cmake config file + set(SuiteSparse_METIS_VERSION + ${METIS_VERSION_MAJOR}.${METIS_VERSION_MINOR}.${METIS_VERSION_PATCH}) + message(STATUS "METIS: building with SuiteSparse_METIS_VERSION '${SuiteSparse_METIS_VERSION}'") + + # some sanity checks if we managed to extract METIS version numbers + if("${METIS_VERSION_MAJOR}" STREQUAL "") + message(FATAL_ERROR "METIS: error extracting METIS_VER_MAJOR from metis.h file at '${_METIS_VERSION_HEADER}'") + endif() + if("${METIS_VERSION_MINOR}" STREQUAL "") + message(FATAL_ERROR "METIS: error extracting METIS_VER_MINOR from metis.h file at '${_METIS_VERSION_HEADER}'") + endif() + + if("${METIS_VERSION_PATCH}" STREQUAL "") + message(FATAL_ERROR "METIS: error extracting METIS_VER_PATCH from metis.h file at '${_METIS_VERSION_HEADER}'") + endif() endif(BUILD_METIS) +# # For EXPORT only : +# # Previous version of cmake (>2.8.12) doesn't auto take into account external lib (here I mean blas and lapack) we need to link to for our current target we want to export. +# # Or at least we need to investigate how to do with previous version. +# # This may cause some trouble in case you want to build in static mode and then use it into another custom project. +# # You will need to manually link your target into your custom project to the correct dependencies link interfaces. +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" GREATER 2.8.11) # # (policies introduced both in 2.8.12) + set(EXPORT_USE_INTERFACE_LINK_LIBRARIES ON CACHE BOOL "") + mark_as_advanced(EXPORT_USE_INTERFACE_LINK_LIBRARIES) + + if(EXPORT_USE_INTERFACE_LINK_LIBRARIES) + cmake_policy(SET CMP0023 NEW) # # just for respecting the new target_link_libraries(...) signature procedure + cmake_policy(SET CMP0022 NEW) # # use INTERFACE_LINK_LIBRARIES property for in-build targets and ignore old properties (IMPORTED_)?LINK_INTERFACE_LIBRARIES(_)? -## For EXPORT only : -## Previous version of cmake (>2.8.12) doesn't auto take into account external lib (here I mean blas and lapack) we need to link to for our current target we want to export. -## Or at least we need to investigate how to do with previous version. -## This may cause some trouble in case you want to build in static mode and then use it into another custom project. -## You will need to manually link your target into your custom project to the correct dependencies link interfaces. -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" GREATER 2.8.11) ## (policies introduced both in 2.8.12) - set(EXPORT_USE_INTERFACE_LINK_LIBRARIES ON CACHE BOOL "") - mark_as_advanced(EXPORT_USE_INTERFACE_LINK_LIBRARIES) - if(EXPORT_USE_INTERFACE_LINK_LIBRARIES) - cmake_policy(SET CMP0023 NEW) ## just for respecting the new target_link_libraries(...) signature procedure - cmake_policy(SET CMP0022 NEW) ## use INTERFACE_LINK_LIBRARIES property for in-build targets and ignore old properties (IMPORTED_)?LINK_INTERFACE_LIBRARIES(_)? - ## Here, next version of cmake 2.8.12 auto take into account the link interface dependencies (see generated cmake/SuiteSparse-config*.cmake into your install dir) - endif() + # # Here, next version of cmake 2.8.12 auto take into account the link interface dependencies (see generated cmake/SuiteSparse-config*.cmake into your install dir) + endif() endif() -## install_suitesparse_project(targetName headersList) -## factorise the way we will install all projects (part of the suitesparse project) -## is the target of the current project you build -## is the list of all public headers the project use and have to be known by other projects -## example of use: -## file(GLOB LIBHDRS "Include/*.h") -## add_library( ...) -## install_suitesparse_project( "${LIBHDRS}") +# # install_suitesparse_project(targetName headersList) +# # factorise the way we will install all projects (part of the suitesparse project) +# # is the target of the current project you build +# # is the list of all public headers the project use and have to be known by other projects +# # example of use: +# # file(GLOB LIBHDRS "Include/*.h") +# # add_library( ...) +# # install_suitesparse_project( "${LIBHDRS}") macro(install_suitesparse_project targetName headersList) + # # set position independend code for GCC, Clang static (and shared?) libs + if(NOT MINGW AND NOT MSVC) + target_compile_options(${targetName} PRIVATE "-fPIC") + endif() - ## set position independend code for GCC, Clang static (and shared?) libs - if (NOT MINGW AND NOT MSVC) - target_compile_options(${targetName} PRIVATE "-fPIC") - endif() - - ## set include dir for install target - target_include_directories(${targetName} PUBLIC - $ - $ - ) - - set_target_properties(${targetName} PROPERTIES PUBLIC_HEADER "${headersList}") - install(TARGETS ${targetName} - EXPORT SuiteSparseTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION include/suitesparse - ) + # # set include dir for install target + target_include_directories(${targetName} PUBLIC + $ + $ + ) + + set_target_properties(${targetName} PROPERTIES PUBLIC_HEADER "${headersList}") + install(TARGETS ${targetName} + EXPORT SuiteSparseTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION include/suitesparse + ) endmacro() -## declare_suitesparse_library(targetName srcsList headersList) -## Example of use: See SuiteSparse/*/CMakeLists.txt +# # declare_suitesparse_library(targetName srcsList headersList) +# # Example of use: See SuiteSparse/*/CMakeLists.txt macro(declare_suitesparse_library targetName srcsList headersList) + # # following args are optional + include(CMakeParseArguments) + cmake_parse_arguments(dsl "" "" "TARGET_PRIVATE_LINK;TARGET_PUBLIC_LINK" ${ARGN}) - ## following args are optional - include(CMakeParseArguments) - cmake_parse_arguments(dsl "" "" "TARGET_PRIVATE_LINK;TARGET_PUBLIC_LINK" ${ARGN} ) - - if(NOT dsl_TARGET_PRIVATE_LINK) - set(dsl_TARGET_PRIVATE_LINK "") - endif() - if(NOT dsl_TARGET_PUBLIC_LINK) - set(dsl_TARGET_PUBLIC_LINK "") - endif() - if(WITH_CUDA) - find_package(CUDA) - endif() - if(${CUDA_FOUND}) - include_directories(${CUDA_INCLUDE_DIRS}) - include_directories(${SuiteSparse_GPUQREngine_INCLUDE}) - include_directories(${SuiteSparse_GPURuntime_INCLUDE}) - CUDA_ADD_LIBRARY(${targetName} ${srcsList} ${headersList}) - else(${CUDA_FOUND}) - add_library(${targetName} ${srcsList} ${headersList}) - endif(${CUDA_FOUND}) - set_target_properties(${targetName} PROPERTIES - OUTPUT_NAME ${SP_LIB_PREFIX}${targetName} - ) - - target_link_libraries(${targetName} - ${dsl_TARGET_PUBLIC_LINK} suitesparseconfig ## suitesparseconfig is used for every projects (embedded into cmake build) - ${dsl_TARGET_PRIVATE_LINK} ## external required libs - ) - - if (WITH_TBB) - target_link_libraries(${targetName} ${dsl_TARGET_PRIVATE_LINK} tbb) - target_compile_definitions(${targetName} PRIVATE HAVE_TBB) - endif() - - install_suitesparse_project(${targetName} "${headersList}") + if(NOT dsl_TARGET_PRIVATE_LINK) + set(dsl_TARGET_PRIVATE_LINK "") + endif() + + if(NOT dsl_TARGET_PUBLIC_LINK) + set(dsl_TARGET_PUBLIC_LINK "") + endif() + + if(WITH_CUDA) + find_package(CUDA) + endif() + + if(${CUDA_FOUND}) + include_directories(${CUDA_INCLUDE_DIRS}) + include_directories(${SuiteSparse_GPUQREngine_INCLUDE}) + include_directories(${SuiteSparse_GPURuntime_INCLUDE}) + CUDA_ADD_LIBRARY(${targetName} ${srcsList} ${headersList}) + else(${CUDA_FOUND}) + add_library(${targetName} ${srcsList} ${headersList}) + endif(${CUDA_FOUND}) + + set_target_properties(${targetName} PROPERTIES + OUTPUT_NAME ${SP_LIB_PREFIX}${targetName} + ) + + target_link_libraries(${targetName} + ${dsl_TARGET_PUBLIC_LINK} suitesparseconfig # # suitesparseconfig is used for every projects (embedded into cmake build) + ${dsl_TARGET_PRIVATE_LINK} # # external required libs + ) + + if(WITH_TBB) + target_link_libraries(${targetName} ${dsl_TARGET_PRIVATE_LINK} tbb) + target_compile_definitions(${targetName} PRIVATE HAVE_TBB) + endif() + + install_suitesparse_project(${targetName} "${headersList}") endmacro() # Example of usage: -# REMOVE_MATCHING_FILES_FROM_LIST(".*_LIN.cpp" my_srcs) +# REMOVE_MATCHING_FILES_FROM_LIST(".*_LIN.cpp" my_srcs) macro(REMOVE_MATCHING_FILES_FROM_LIST match_expr lst_files) - set(lst_files_aux "") - foreach(FIL ${${lst_files}}) - if(NOT ${FIL} MATCHES "${match_expr}") - set(lst_files_aux "${lst_files_aux}" "${FIL}") - endif(NOT ${FIL} MATCHES "${match_expr}") - endforeach(FIL) - set(${lst_files} ${lst_files_aux}) + set(lst_files_aux "") + + foreach(FIL ${${lst_files}}) + if(NOT ${FIL} MATCHES "${match_expr}") + set(lst_files_aux "${lst_files_aux}" "${FIL}") + endif(NOT ${FIL} MATCHES "${match_expr}") + endforeach(FIL) + + set(${lst_files} ${lst_files_aux}) endmacro(REMOVE_MATCHING_FILES_FROM_LIST) if(WITH_CUDA) - find_package(cuda) - if(${CUDA_FOUND}) - add_definitions(-DGPU_BLAS) - endif(${CUDA_FOUND}) + find_package(cuda) + + if(${CUDA_FOUND}) + add_definitions(-DGPU_BLAS) + endif(${CUDA_FOUND}) endif() -if (WITH_OPENBLAS) - # Starting with OpenBLAS v0.3.21 a f2c-converted copy of LAPACK 3.9.0 - # is included and used if no fortran compiler is available. This - # means we can compile OpenBLAS to provide BLAS and LAPACK functionality - # with a regular C++ compiler like MSVC or GCC. This includes compiling - # everything as a static library. If that library is later used to compile - # an executable the executable can run without any external dependencies - # (like fortran runtimes or lapack dlls) - # When building OpenBLAS be sure to use 'BUILD_WITHOUT_LAPACK=NO' and - # mabye with 'NOFORTAN=1' to get a pure C++ OpenBLAS library (with the - # benefits described above) - hunter_add_package(OpenBLAS) - set(BLA_VENDOR OpenBLAS) - find_package(OpenBLAS CONFIG) - if (OpenBLAS_FOUND) - message(STATUS "Found OpenBLAS ${OpenBLAS_VERSION}") - else() - message(STATUS "Looking for OpenBLAS") +if(WITH_OPENBLAS) + # Starting with OpenBLAS v0.3.21 a f2c-converted copy of LAPACK 3.9.0 + # is included and used if no fortran compiler is available. This + # means we can compile OpenBLAS to provide BLAS and LAPACK functionality + # with a regular C++ compiler like MSVC or GCC. This includes compiling + # everything as a static library. If that library is later used to compile + # an executable the executable can run without any external dependencies + # (like fortran runtimes or lapack dlls) + # When building OpenBLAS be sure to use 'BUILD_WITHOUT_LAPACK=NO' and + # mabye with 'NOFORTAN=1' to get a pure C++ OpenBLAS library (with the + # benefits described above) + hunter_add_package(OpenBLAS) + set(BLA_VENDOR OpenBLAS) + find_package(OpenBLAS CONFIG) + + if(OpenBLAS_FOUND) + message(STATUS "Found OpenBLAS ${OpenBLAS_VERSION}") + else() + message(STATUS "Looking for OpenBLAS") + find_package(BLAS REQUIRED) + message(STATUS "Found OpenBLAS in ${BLAS_LIBRARIES}") + endif() + + if(TARGET OpenBLAS::OpenBLAS) + message(STATUS "found OpenBLAS config file, linking target OpenBLAS::OpenBLAS") + set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS OpenBLAS::OpenBLAS) + else() + message(STATUS "found OpenBLAS, linking target BLAS::BLAS") + set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS BLAS::BLAS) + endif() +elseif(WITH_MKL) + hunter_add_package(mkl) + set(BLA_VENDOR "Intel10_64lp") find_package(BLAS REQUIRED) - message(STATUS "Found OpenBLAS in ${BLAS_LIBRARIES}") - endif() - if (TARGET OpenBLAS::OpenBLAS) - message(STATUS "found OpenBLAS config file, linking target OpenBLAS::OpenBLAS") - set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS OpenBLAS::OpenBLAS) - else() - message(STATUS "found OpenBLAS, linking target BLAS::BLAS") - set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS BLAS::BLAS) - endif() -elseif (WITH_MKL) - hunter_add_package(mkl) - set(BLA_VENDOR "Intel10_64lp") - find_package(BLAS REQUIRED) - find_package(LAPACK REQUIRED) - set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) - # for suitesparse-config file set method used to find LAPACK (and BLAS) - set(SuiteSparse_LAPACK_used_CONFIG NO) -else() - hunter_add_package(LAPACK) # only in effect if HUNTER_ENABLED is set - # prefer LAPACK config file - if (WIN32) - set(LAPACK_DIR "lapack_windows/x64/" CACHE PATH "LAPACK directory" ) - endif() - - find_package(LAPACK CONFIG) - if (LAPACK_FOUND AND TARGET blas AND TARGET lapack) - message(STATUS "found lapack and blas config file. Linking targets lapack and blas") - message(STATUS "- LAPACK_CONFIG: ${LAPACK_CONFIG}") - set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS lapack blas) + find_package(LAPACK REQUIRED) + set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) + # for suitesparse-config file set method used to find LAPACK (and BLAS) - set(SuiteSparse_LAPACK_used_CONFIG YES) - else() - # missing config file or targets, try BLAS and LAPACK - find_package(BLAS) - find_package(LAPACK) - if (BLAS_FOUND AND LAPACK_FOUND) - message(STATUS "found lapack and blas config file. Linking targets lapack and blas") - message(STATUS "- LAPACK_LIBRARIES: ${LAPACK_LIBRARIES}") - message(STATUS "- BLAS_LIBRARIES: ${BLAS_LIBRARIES}") - set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) - # for suitesparse-config file set method used to find LAPACK (and BLAS) - set(SuiteSparse_LAPACK_used_CONFIG NO) - else () # LAPACK is not found - message(FATAL_ERROR "lapack not found") + set(SuiteSparse_LAPACK_used_CONFIG NO) +else() + hunter_add_package(LAPACK) # only in effect if HUNTER_ENABLED is set + + # prefer LAPACK config file + if(WIN32) + set(LAPACK_DIR "lapack_windows/x64/" CACHE PATH "LAPACK directory") + endif() + + find_package(LAPACK CONFIG) + + if(LAPACK_FOUND AND TARGET blas AND TARGET lapack) + message(STATUS "found lapack and blas config file. Linking targets lapack and blas") + message(STATUS "- LAPACK_CONFIG: ${LAPACK_CONFIG}") + set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS lapack blas) + + # for suitesparse-config file set method used to find LAPACK (and BLAS) + set(SuiteSparse_LAPACK_used_CONFIG YES) + else() + # missing config file or targets, try BLAS and LAPACK + find_package(BLAS) + find_package(LAPACK) + + if(BLAS_FOUND AND LAPACK_FOUND) + message(STATUS "found lapack and blas config file. Linking targets lapack and blas") + message(STATUS "- LAPACK_LIBRARIES: ${LAPACK_LIBRARIES}") + message(STATUS "- BLAS_LIBRARIES: ${BLAS_LIBRARIES}") + set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) + + # for suitesparse-config file set method used to find LAPACK (and BLAS) + set(SuiteSparse_LAPACK_used_CONFIG NO) + else() # LAPACK is not found + message(FATAL_ERROR "lapack not found") + endif() endif() - endif() endif() add_subdirectory(SuiteSparse) macro(get_SuiteSparse_Version) - set(_SuiteSparse_VERSION_FILE - "${CMAKE_SOURCE_DIR}/SuiteSparse/SuiteSparse_config/SuiteSparse_config.h") - if(NOT EXISTS ${_SuiteSparse_VERSION_FILE}) - message(FATAL_ERROR - "Could not find file: ${_SuiteSparse_VERSION_FILE} containing version " - "information for >= v4 SuiteSparse installs.") - endif() - - file(READ ${_SuiteSparse_VERSION_FILE} SUITESPARSE_CONFIG_CONTENTS) - - string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION[ ]+[0-9]+" - SuiteSparse_VERSION_MAJOR "${SUITESPARSE_CONFIG_CONTENTS}") - string(REGEX REPLACE "#define SUITESPARSE_MAIN_VERSION[ ]+([0-9]+)" "\\1" - SuiteSparse_VERSION_MAJOR "${SuiteSparse_VERSION_MAJOR}") - - string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION[ ]+[0-9]+" - SuiteSparse_VERSION_MINOR "${SUITESPARSE_CONFIG_CONTENTS}") - string(REGEX REPLACE "#define SUITESPARSE_SUB_VERSION[ ]+([0-9]+)" "\\1" - SuiteSparse_VERSION_MINOR "${SuiteSparse_VERSION_MINOR}") - - string(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION[ ]+[0-9]+" - SuiteSparse_VERSION_PATCH "${SUITESPARSE_CONFIG_CONTENTS}") - string(REGEX REPLACE "#define SUITESPARSE_SUBSUB_VERSION[ ]+([0-9]+)" "\\1" - SuiteSparse_VERSION_PATCH "${SuiteSparse_VERSION_PATCH}") - - # set version string - set(SuiteSparse_VERSION - "${SuiteSparse_VERSION_MAJOR}.${SuiteSparse_VERSION_MINOR}.${SuiteSparse_VERSION_PATCH}") - message(STATUS "Extracted SuiteSparse version: ${SuiteSparse_VERSION}") + set(_SuiteSparse_VERSION_FILE + "${CMAKE_SOURCE_DIR}/SuiteSparse/SuiteSparse_config/SuiteSparse_config.h") + + if(NOT EXISTS ${_SuiteSparse_VERSION_FILE}) + message(FATAL_ERROR + "Could not find file: ${_SuiteSparse_VERSION_FILE} containing version " + "information for >= v4 SuiteSparse installs.") + endif() + + file(READ ${_SuiteSparse_VERSION_FILE} SUITESPARSE_CONFIG_CONTENTS) + + string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION[ ]+[0-9]+" + SuiteSparse_VERSION_MAJOR "${SUITESPARSE_CONFIG_CONTENTS}") + string(REGEX REPLACE "#define SUITESPARSE_MAIN_VERSION[ ]+([0-9]+)" "\\1" + SuiteSparse_VERSION_MAJOR "${SuiteSparse_VERSION_MAJOR}") + + string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION[ ]+[0-9]+" + SuiteSparse_VERSION_MINOR "${SUITESPARSE_CONFIG_CONTENTS}") + string(REGEX REPLACE "#define SUITESPARSE_SUB_VERSION[ ]+([0-9]+)" "\\1" + SuiteSparse_VERSION_MINOR "${SuiteSparse_VERSION_MINOR}") + + string(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION[ ]+[0-9]+" + SuiteSparse_VERSION_PATCH "${SUITESPARSE_CONFIG_CONTENTS}") + string(REGEX REPLACE "#define SUITESPARSE_SUBSUB_VERSION[ ]+([0-9]+)" "\\1" + SuiteSparse_VERSION_PATCH "${SuiteSparse_VERSION_PATCH}") + + # set version string + set(SuiteSparse_VERSION + "${SuiteSparse_VERSION_MAJOR}.${SuiteSparse_VERSION_MINOR}.${SuiteSparse_VERSION_PATCH}") + message(STATUS "Extracted SuiteSparse version: ${SuiteSparse_VERSION}") endmacro() # get SuiteSparse version get_SuiteSparse_Version() set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/suitesparse-${SuiteSparse_VERSION}) -## create targets file + +# # create targets file export(EXPORT SuiteSparseTargets - FILE "${CMAKE_CURRENT_BINARY_DIR}/suitesparse/suitesparse-targets.cmake" - NAMESPACE SuiteSparse:: + FILE "${CMAKE_CURRENT_BINARY_DIR}/suitesparse/suitesparse-targets.cmake" + NAMESPACE SuiteSparse:: ) -## create config file + +# # create config file configure_file(cmake/SuiteSparse-config-install.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/suitesparse/suitesparse-config.cmake" - @ONLY + "${CMAKE_CURRENT_BINARY_DIR}/suitesparse/suitesparse-config.cmake" + @ONLY ) -## do the EXPORT for allowing other project to easily use suitesparse with cmake + +# # do the EXPORT for allowing other project to easily use suitesparse with cmake install(EXPORT SuiteSparseTargets - FILE - SuiteSparse-targets.cmake - NAMESPACE - SuiteSparse:: - DESTINATION - ${ConfigPackageLocation} + FILE + SuiteSparse-targets.cmake + NAMESPACE + SuiteSparse:: + DESTINATION + ${ConfigPackageLocation} ) -## write config-version file + +# # write config-version file include(CMakePackageConfigHelpers) write_basic_package_version_file( - "${CMAKE_BINARY_DIR}/suitesparse/suitesparse-config-version.cmake" - VERSION ${SuiteSparse_VERSION} - COMPATIBILITY SameMajorVersion + "${CMAKE_BINARY_DIR}/suitesparse/suitesparse-config-version.cmake" + VERSION ${SuiteSparse_VERSION} + COMPATIBILITY SameMajorVersion ) -## install config and config-version file + +# # install config and config-version file install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/suitesparse/suitesparse-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/suitesparse/suitesparse-config-version.cmake" - DESTINATION - ${ConfigPackageLocation} + FILES + "${CMAKE_CURRENT_BINARY_DIR}/suitesparse/suitesparse-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/suitesparse/suitesparse-config-version.cmake" + DESTINATION + ${ConfigPackageLocation} ) diff --git a/SuiteSparse/CHOLMOD/CMakeLists.txt b/SuiteSparse/CHOLMOD/CMakeLists.txt index 0b0a5c86e..4afe7a791 100644 --- a/SuiteSparse/CHOLMOD/CMakeLists.txt +++ b/SuiteSparse/CHOLMOD/CMakeLists.txt @@ -9,21 +9,23 @@ include_directories("${CCOLAMD_SOURCE_DIR}/Include") # Headers: file(GLOB LIBHDRS "${CHOLMOD_SOURCE_DIR}/Include/*.h") -file ( GLOB CHOLMOD_SOURCES +file(GLOB CHOLMOD_SOURCES "Check/cholmod_*.c" "Cholesky/cholmod_*.c" "Utility/cholmod_*.c" "MatrixOps/cholmod_*.c" "Modify/cholmod_*.c" "Partition/cholmod_*.c" - "Supernodal/cholmod_*.c" ) + "Supernodal/cholmod_*.c" +) + +include(CheckTypeSize) +check_type_size("ssize_t" SSIZE_T) -include ( CheckTypeSize ) -check_type_size ( "ssize_t" SSIZE_T ) -if ( NOT HAVE_SSIZE_T ) +if(NOT HAVE_SSIZE_T) # #include and ssize_t not defined (typically on Windows) - add_compile_definitions ( NO_SSIZE_T ) -endif ( ) + add_compile_definitions(NO_SSIZE_T) +endif() # METIS and the Partition module: if(BUILD_METIS) @@ -35,22 +37,24 @@ if(BUILD_METIS) include_directories("${CMAKE_CURRENT_BINARY_DIR}") # include for modified metis.h include_directories("${CMAKE_CURRENT_BINARY_DIR}/SuiteSparse_metis/include") - #includes to make metis-wrapper work + # includes to make metis-wrapper work include_directories("${CHOLMOD_SOURCE_DIR}") include_directories("${CHOLMOD_SOURCE_DIR}/SuiteSparse_metis/GKlib") + # add metis-wrapper to compiled files set(LIBHDRS ${LIBHDRS} "${CHOLMOD_SOURCE_DIR}/Partition/cholmod_metis_wrapper.h") - file ( GLOB CHOLMOD_SOURCES_PARTITION "Partition/cholmod_*.c") + file(GLOB CHOLMOD_SOURCES_PARTITION "Partition/cholmod_*.c") list(APPEND CHOLMOD_SOURCES ${CHOLMOD_SOURCES_PARTITION}) else() add_compile_definitions(NPARTITION) endif() + include_directories("${CHOLMOD_SOURCE_DIR}/Include") declare_suitesparse_library(cholmod "${CHOLMOD_SOURCES}" "${LIBHDRS}" TARGET_PRIVATE_LINK ${SuiteSparse_LINKER_LAPACK_BLAS_LIBS} - TARGET_PUBLIC_LINK amd camd colamd ccolamd + TARGET_PUBLIC_LINK amd camd colamd ccolamd ) if(WITH_CUDA) - target_link_libraries(cholmod ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES}) + target_link_libraries(cholmod ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES}) endif(WITH_CUDA) diff --git a/SuiteSparse/CMakeLists.txt b/SuiteSparse/CMakeLists.txt index caf7d56e1..b52f6b36f 100644 --- a/SuiteSparse/CMakeLists.txt +++ b/SuiteSparse/CMakeLists.txt @@ -2,13 +2,14 @@ project(SuiteSparse) # Set optimized building: if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") - # only optimize for native processer when NOT cross compiling - if(NOT CMAKE_CROSSCOMPILING) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=native") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=native") - endif(NOT CMAKE_CROSSCOMPILING) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") + + # only optimize for native processer when NOT cross compiling + if(NOT CMAKE_CROSSCOMPILING) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=native") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=native") + endif(NOT CMAKE_CROSSCOMPILING) endif(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug") # Global flags: @@ -17,40 +18,39 @@ if(NOT BUILD_METIS) endif() # Used even for MSVC, so blas function names have the final "_" -if (MSVC) - add_definitions(-D__MINGW32__) +if(MSVC) + add_definitions(-D__MINGW32__) endif(MSVC) - -include_directories(".") # Needed for "SourceWrappers/*.c" files +include_directories(".") # Needed for "SourceWrappers/*.c" files set(suitesparseconfig_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/SuiteSparse_config) # Needed by all subprojects if(WITH_CUDA) - set(SUBPROJECTS_TO_ADD - ${SUBPROJECTS_TO_ADD} - SuiteSparse_GPURuntime - GPUQREngine - ) + set(SUBPROJECTS_TO_ADD + ${SUBPROJECTS_TO_ADD} + SuiteSparse_GPURuntime + GPUQREngine + ) endif() set(SUBPROJECTS_TO_ADD - ${SUBPROJECTS_TO_ADD} - SuiteSparse_config - AMD - BTF - CAMD - CCOLAMD - COLAMD - CHOLMOD - CXSparse - KLU - LDL - UMFPACK - SPQR - #CACHE STRING "list of all sub-directories to add to cmake build" + ${SUBPROJECTS_TO_ADD} + SuiteSparse_config + AMD + BTF + CAMD + CCOLAMD + COLAMD + CHOLMOD + CXSparse + KLU + LDL + UMFPACK + SPQR + # CACHE STRING "list of all sub-directories to add to cmake build" ) foreach(subdir ${SUBPROJECTS_TO_ADD}) - add_subdirectory(${subdir}) + add_subdirectory(${subdir}) endforeach() diff --git a/SuiteSparse/KLU/CMakeLists.txt b/SuiteSparse/KLU/CMakeLists.txt index a589fc7d0..a9dee23c4 100644 --- a/SuiteSparse/KLU/CMakeLists.txt +++ b/SuiteSparse/KLU/CMakeLists.txt @@ -10,5 +10,5 @@ file(GLOB LIBHDRS "Include/*.h") file(GLOB LIBSRCS "SourceWrappers/*.c") declare_suitesparse_library(klu "${LIBSRCS}" "${LIBHDRS}" - TARGET_PUBLIC_LINK amd colamd btf + TARGET_PUBLIC_LINK amd colamd btf ) diff --git a/SuiteSparse/SPQR/CMakeLists.txt b/SuiteSparse/SPQR/CMakeLists.txt index 018480e4a..e5618a74f 100644 --- a/SuiteSparse/SPQR/CMakeLists.txt +++ b/SuiteSparse/SPQR/CMakeLists.txt @@ -5,58 +5,58 @@ include_directories("${SPQR_SOURCE_DIR}/Include") include_directories("${CHOLMOD_SOURCE_DIR}/Include") file(GLOB LIBHDRS "Include/*.h*") # .h & .hpp -set(LIBSRCS - Source/spqr_1colamd.cpp - Source/spqr_1factor.cpp - Source/spqr_1fixed.cpp - Source/spqr_analyze.cpp - Source/spqr_append.cpp - Source/spqr_assemble.cpp - Source/spqr_cholmod_wrappers.cpp - Source/spqr_cpack.cpp - Source/spqr_csize.cpp - Source/spqr_cumsum.cpp - Source/spqr_debug.cpp - Source/spqr_factorize.cpp - Source/spqr_fcsize.cpp - Source/spqr_freefac.cpp - Source/spqr_freenum.cpp - Source/spqr_freesym.cpp - Source/spqr_front.cpp - Source/spqr_fsize.cpp - Source/spqr_happly.cpp - Source/spqr_happly_work.cpp - Source/spqr_hpinv.cpp - Source/spqr_kernel.cpp - Source/spqr_larftb.cpp - Source/spqr_maxcolnorm.cpp - Source/spqr_panel.cpp - Source/spqr_parallel.cpp - Source/spqr_rconvert.cpp - Source/spqr_rcount.cpp - Source/spqr_rhpack.cpp - Source/spqr_rmap.cpp - Source/spqr_rsolve.cpp - Source/spqr_shift.cpp - Source/spqr_stranspose1.cpp - Source/spqr_stranspose2.cpp - Source/spqr_tol.cpp - Source/spqr_trapezoidal.cpp - Source/spqr_type.cpp - Source/SuiteSparseQR_C.cpp - Source/SuiteSparseQR.cpp - Source/SuiteSparseQR_expert.cpp - Source/SuiteSparseQR_qmult.cpp - SPQRGPU/spqrgpu_buildAssemblyMaps.cpp - SPQRGPU/spqrgpu_computeFrontStaging.cpp - SPQRGPU/spqrgpu_kernel.cpp +set(LIBSRCS + Source/spqr_1colamd.cpp + Source/spqr_1factor.cpp + Source/spqr_1fixed.cpp + Source/spqr_analyze.cpp + Source/spqr_append.cpp + Source/spqr_assemble.cpp + Source/spqr_cholmod_wrappers.cpp + Source/spqr_cpack.cpp + Source/spqr_csize.cpp + Source/spqr_cumsum.cpp + Source/spqr_debug.cpp + Source/spqr_factorize.cpp + Source/spqr_fcsize.cpp + Source/spqr_freefac.cpp + Source/spqr_freenum.cpp + Source/spqr_freesym.cpp + Source/spqr_front.cpp + Source/spqr_fsize.cpp + Source/spqr_happly.cpp + Source/spqr_happly_work.cpp + Source/spqr_hpinv.cpp + Source/spqr_kernel.cpp + Source/spqr_larftb.cpp + Source/spqr_maxcolnorm.cpp + Source/spqr_panel.cpp + Source/spqr_parallel.cpp + Source/spqr_rconvert.cpp + Source/spqr_rcount.cpp + Source/spqr_rhpack.cpp + Source/spqr_rmap.cpp + Source/spqr_rsolve.cpp + Source/spqr_shift.cpp + Source/spqr_stranspose1.cpp + Source/spqr_stranspose2.cpp + Source/spqr_tol.cpp + Source/spqr_trapezoidal.cpp + Source/spqr_type.cpp + Source/SuiteSparseQR_C.cpp + Source/SuiteSparseQR.cpp + Source/SuiteSparseQR_expert.cpp + Source/SuiteSparseQR_qmult.cpp + SPQRGPU/spqrgpu_buildAssemblyMaps.cpp + SPQRGPU/spqrgpu_computeFrontStaging.cpp + SPQRGPU/spqrgpu_kernel.cpp ) declare_suitesparse_library(spqr "${LIBSRCS}" "${LIBHDRS}" - TARGET_PRIVATE_LINK ${SuiteSparse_LINKER_LAPACK_BLAS_LIBS} - TARGET_PUBLIC_LINK camd ccolamd cholmod + TARGET_PRIVATE_LINK ${SuiteSparse_LINKER_LAPACK_BLAS_LIBS} + TARGET_PUBLIC_LINK camd ccolamd cholmod ) if(WITH_CUDA) - target_link_libraries(spqr GPUQREngine ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES}) + target_link_libraries(spqr GPUQREngine ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES}) endif(WITH_CUDA) diff --git a/SuiteSparse/SuiteSparse_config/CMakeLists.txt b/SuiteSparse/SuiteSparse_config/CMakeLists.txt index 2ec1a424e..3e06b906d 100644 --- a/SuiteSparse/SuiteSparse_config/CMakeLists.txt +++ b/SuiteSparse/SuiteSparse_config/CMakeLists.txt @@ -3,10 +3,9 @@ project(suitesparseconfig) include_directories("${suitesparseconfig_SOURCE_DIR}") add_library(suitesparseconfig STATIC - SuiteSparse_config.c - SuiteSparse_config.h - ) + SuiteSparse_config.c + SuiteSparse_config.h +) target_compile_definitions(suitesparseconfig PUBLIC NTIMER) install_suitesparse_project(suitesparseconfig "SuiteSparse_config.h") - diff --git a/SuiteSparse/UMFPACK/CMakeLists.txt b/SuiteSparse/UMFPACK/CMakeLists.txt index 611c617e5..9f3326e05 100644 --- a/SuiteSparse/UMFPACK/CMakeLists.txt +++ b/SuiteSparse/UMFPACK/CMakeLists.txt @@ -10,7 +10,6 @@ file(GLOB LIBHDRS "${UMFPACK_SOURCE_DIR}/Include/*.h") file(GLOB LIBSRCS "${UMFPACK_SOURCE_DIR}/SourceWrappers/*.c") declare_suitesparse_library(umfpack "${LIBSRCS}" "${LIBHDRS}" - TARGET_PRIVATE_LINK ${SuiteSparse_LINKER_LAPACK_BLAS_LIBS} - TARGET_PUBLIC_LINK amd camd colamd ccolamd cholmod ${SuiteSparse_LINKER_PUBLIC_LIBS} + TARGET_PRIVATE_LINK ${SuiteSparse_LINKER_LAPACK_BLAS_LIBS} + TARGET_PUBLIC_LINK amd camd colamd ccolamd cholmod ${SuiteSparse_LINKER_PUBLIC_LIBS} ) -