init cmake build system
parent
a8cf53d80e
commit
d61c9fed9f
@ -0,0 +1,7 @@
|
||||
function(CapitalizeString string output_variable)
|
||||
string(TOUPPER "${string}" _upper_string)
|
||||
string(TOLOWER "${string}" _lower_string)
|
||||
string(SUBSTRING "${_upper_string}" 0 1 _start)
|
||||
string(SUBSTRING "${_lower_string}" 1 -1 _end)
|
||||
set(${output_variable} "${_start}${_end}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
@ -0,0 +1,21 @@
|
||||
#--------------------------
|
||||
# Prohibit in-source builds
|
||||
#--------------------------
|
||||
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
message(FATAL_ERROR "ERROR! "
|
||||
"CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
" == CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"\nThis archive does not support in-source builds:\n"
|
||||
"You must now delete the CMakeCache.txt file and the CMakeFiles/ directory under "
|
||||
"the 'src' source directory or you will not be able to configure correctly!"
|
||||
"\nYou must now run something like:\n"
|
||||
" $ rm -r CMakeCache.txt CMakeFiles/"
|
||||
"\n"
|
||||
"Please create a directory outside the ${CMAKE_PROJECT_NAME} source tree and build under that outside directory "
|
||||
"in a manner such as\n"
|
||||
" $ mkdir build\n"
|
||||
" $ cd build\n"
|
||||
" $ CC=gcc FC=gfortran cmake -DBUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/install/dir /path/to/psblas3/src/dir \n"
|
||||
"\nsubstituting the appropriate syntax for your shell (the above line assumes the bash shell)."
|
||||
)
|
||||
endif()
|
||||
@ -0,0 +1,95 @@
|
||||
if (METIS_INCLUDES AND METIS_LIBRARIES)
|
||||
set(METIS_FIND_QUIETLY TRUE)
|
||||
endif (METIS_INCLUDES AND METIS_LIBRARIES)
|
||||
|
||||
if( DEFINED ENV{METISDIR} )
|
||||
if( NOT DEFINED METIS_ROOT )
|
||||
set(METIS_ROOT "$ENV{METISDIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if( (DEFINED ENV{METIS_ROOT}) OR (DEFINED METIS_ROOT) )
|
||||
if( NOT DEFINED METIS_ROOT)
|
||||
set(METIS_ROOT "$ENV{METIS_ROOT}")
|
||||
endif()
|
||||
set(METIS_HINTS "${METIS_ROOT}")
|
||||
endif()
|
||||
|
||||
find_path(METIS_INCLUDES
|
||||
NAMES
|
||||
metis.h
|
||||
HINTS
|
||||
${METIS_HINTS}
|
||||
PATHS
|
||||
"${INCLUDE_INSTALL_DIR}"
|
||||
/usr/local/opt
|
||||
/usr/local
|
||||
PATH_SUFFIXES
|
||||
include
|
||||
)
|
||||
|
||||
if(METIS_INCLUDES)
|
||||
foreach(include IN_LISTS METIS_INCLUDES)
|
||||
get_filename_component(mts_include_dir "${include}" DIRECTORY)
|
||||
get_filename_component(mts_abs_include_dir "${mts_include_dir}" ABSOLUTE)
|
||||
get_filename_component(new_mts_hint "${include_dir}/.." ABSOLUTE )
|
||||
list(APPEND METIS_HINTS "${new_mts_hint}")
|
||||
break()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(METIS_HINTS)
|
||||
list(REMOVE_DUPLICATES METIS_HINTS)
|
||||
endif()
|
||||
|
||||
macro(_metis_check_version)
|
||||
file(READ "${METIS_INCLUDES}/metis.h" _metis_version_header)
|
||||
|
||||
string(REGEX MATCH "define[ \t]+METIS_VER_MAJOR[ \t]+([0-9]+)" _metis_major_version_match "${_metis_version_header}")
|
||||
set(METIS_MAJOR_VERSION "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "define[ \t]+METIS_VER_MINOR[ \t]+([0-9]+)" _metis_minor_version_match "${_metis_version_header}")
|
||||
set(METIS_MINOR_VERSION "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "define[ \t]+METIS_VER_SUBMINOR[ \t]+([0-9]+)" _metis_subminor_version_match "${_metis_version_header}")
|
||||
set(METIS_SUBMINOR_VERSION "${CMAKE_MATCH_1}")
|
||||
if(NOT METIS_MAJOR_VERSION)
|
||||
message(STATUS "Could not determine Metis version. Assuming version 4.0.0")
|
||||
set(METIS_VERSION 4.0.0)
|
||||
else()
|
||||
set(METIS_VERSION ${METIS_MAJOR_VERSION}.${METIS_MINOR_VERSION}.${METIS_SUBMINOR_VERSION})
|
||||
endif()
|
||||
if(${METIS_VERSION} VERSION_LESS ${Metis_FIND_VERSION})
|
||||
set(METIS_VERSION_OK FALSE)
|
||||
else()
|
||||
set(METIS_VERSION_OK TRUE)
|
||||
endif()
|
||||
|
||||
if(NOT METIS_VERSION_OK)
|
||||
message(STATUS "Metis version ${METIS_VERSION} found in ${METIS_INCLUDES}, "
|
||||
"but at least version ${Metis_FIND_VERSION} is required")
|
||||
endif(NOT METIS_VERSION_OK)
|
||||
endmacro(_metis_check_version)
|
||||
|
||||
if(METIS_INCLUDES AND Metis_FIND_VERSION)
|
||||
_metis_check_version()
|
||||
else()
|
||||
set(METIS_VERSION_OK TRUE)
|
||||
endif()
|
||||
|
||||
|
||||
find_library(METIS_LIBRARIES metis
|
||||
HINTS
|
||||
${METIS_HINTS}
|
||||
PATHS
|
||||
"${LIB_INSTALL_DIR}"
|
||||
/usr/local/
|
||||
/usr/local/opt
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
lib64
|
||||
metis/lib)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(METIS DEFAULT_MSG
|
||||
METIS_INCLUDES METIS_LIBRARIES METIS_VERSION_OK)
|
||||
|
||||
mark_as_advanced(METIS_INCLUDES METIS_LIBRARIES)
|
||||
@ -0,0 +1,12 @@
|
||||
Mac users can use GPGTools - https://gpgtools.org
|
||||
Comment: Download Izaak Beekman's GPG public key from your
|
||||
Comment: trusted key server or from
|
||||
Comment: https://izaakbeekman.com/izaak.pubkey.txt
|
||||
Comment: Next add it to your GPG keyring, e.g.,
|
||||
Comment: `curl https://izaakbeekman.com/izaak.pubkey.txt | gpg --import`
|
||||
Comment: Make sure you have verified that the release archive's
|
||||
Comment: SHA256 checksum matches the provided
|
||||
Comment: psblas-@git_version@-SHA256.txt and ensure that this file
|
||||
Comment: and it's signature are in the same directory. Then
|
||||
Comment: verify with:
|
||||
Comment: `gpg --verify psblas-@git_version@-SHA256.txt.asc`
|
||||
@ -0,0 +1,3 @@
|
||||
# To verify cryptographic checksums `shasum -c psblas-@git_version@-SHA256.txt` on Mac OS X, or
|
||||
# `sha256sum -c psblas-@git_version@-SHA256.txt` on Linux.
|
||||
@sha256_checksum@
|
||||
@ -0,0 +1,11 @@
|
||||
# Config file for the installed package
|
||||
|
||||
set(amg4psblas_VERSION "@amg4psblas_VERSION@")
|
||||
|
||||
# Include directories
|
||||
set(amg4psblas_INCLUDE_DIRS "@CMAKE_INSTALL_INCLUDEDIR@")
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
# Provide the targets
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@CMAKE_PROJECT_NAME@Targets.cmake")
|
||||
@ -0,0 +1,79 @@
|
||||
# CMake file to be called in script mode (${CMAKE_COMMAND} -P <file>) to
|
||||
# Generate a source archive release asset from add_custom_command
|
||||
#
|
||||
# See SourceDistTarget.cmake
|
||||
|
||||
if(NOT CMAKE_ARGV3)
|
||||
message(FATAL_ERROR "Must pass the top level src dir to ${CMAKE_ARGV2} as the first argument")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_ARGV4)
|
||||
message(FATAL_ERROR "Must pass the top level src dir to ${CMAKE_ARGV2} as the second argument")
|
||||
endif()
|
||||
|
||||
find_package(Git)
|
||||
if(NOT GIT_FOUND)
|
||||
message( FATAL_ERROR "You can't create a source archive release asset without git!")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND "${GIT_EXECUTABLE}" describe --always
|
||||
RESULT_VARIABLE git_status
|
||||
OUTPUT_VARIABLE git_version
|
||||
WORKING_DIRECTORY "${CMAKE_ARGV3}"
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT (git_status STREQUAL "0"))
|
||||
message( FATAL_ERROR "git describe --always failed with exit status: ${git_status} and message:
|
||||
${git_version}")
|
||||
endif()
|
||||
|
||||
set(archive "AMG4PSBLAS-${git_version}")
|
||||
set(l_archive "AMG4PSBLAS-${git_version}")
|
||||
set(release_asset "${CMAKE_ARGV4}/${archive}.tar.gz")
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" archive "--prefix=${archive}/" -o "${release_asset}" "${git_version}"
|
||||
RESULT_VARIABLE git_status
|
||||
OUTPUT_VARIABLE git_output
|
||||
WORKING_DIRECTORY "${CMAKE_ARGV3}"
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(NOT (git_status STREQUAL "0"))
|
||||
message( FATAL_ERROR "git archive ... failed with exit status: ${git_status} and message:
|
||||
${git_output}")
|
||||
else()
|
||||
message( STATUS "Source code release asset created from `git archive`: ${release_asset}")
|
||||
endif()
|
||||
|
||||
file(SHA256 "${release_asset}" tarball_sha256)
|
||||
set(sha256_checksum "${tarball_sha256} ${archive}.tar.gz")
|
||||
configure_file("${CMAKE_ARGV3}/cmake/AMG4PSBLAS-VER-SHA256.txt.in"
|
||||
"${CMAKE_ARGV4}/${l_archive}-SHA256.txt"
|
||||
@ONLY)
|
||||
message( STATUS
|
||||
"SHA 256 checksum of release tarball written out as: ${CMAKE_ARGV4}/${l_archive}-SHA256.txt" )
|
||||
|
||||
find_program(GPG_EXECUTABLE
|
||||
gpg
|
||||
DOC "Location of GnuPG (gpg) executable")
|
||||
|
||||
if(GPG_EXECUTABLE)
|
||||
execute_process(
|
||||
COMMAND "${GPG_EXECUTABLE}" --armor --detach-sign --comment "@gpg_comment@" "${CMAKE_ARGV4}/${l_archive}-SHA256.txt"
|
||||
RESULT_VARIABLE gpg_status
|
||||
OUTPUT_VARIABLE gpg_output
|
||||
WORKING_DIRECTORY "${CMAKE_ARGV4}")
|
||||
if(NOT (gpg_status STREQUAL "0"))
|
||||
message( WARNING "GPG signing of ${CMAKE_ARGV4}/${l_archive}-SHA256.txt appears to have failed
|
||||
with status: ${gpg_status} and output: ${gpg_output}")
|
||||
else()
|
||||
configure_file("${CMAKE_ARGV3}/cmake/AMG4PSBLAS-VER-SHA256.txt.asc.in"
|
||||
"${CMAKE_ARGV4}/${l_archive}-GPG.comment"
|
||||
@ONLY)
|
||||
file(READ "${CMAKE_ARGV4}/${l_archive}-GPG.comment" gpg_comment)
|
||||
configure_file("${CMAKE_ARGV4}/${l_archive}-SHA256.txt.asc"
|
||||
"${CMAKE_ARGV4}/${l_archive}-SHA256.txt.asc.out"
|
||||
@ONLY)
|
||||
file(RENAME "${CMAKE_ARGV4}/${l_archive}-SHA256.txt.asc.out"
|
||||
"${CMAKE_ARGV4}/${l_archive}-SHA256.txt.asc")
|
||||
message(STATUS "GPG signed SHA256 checksum created: ${CMAKE_ARGV4}/${l_archive}-SHA256.txt.asc")
|
||||
endif()
|
||||
endif()
|
||||
@ -0,0 +1,16 @@
|
||||
# Config file for the INSTALLED package
|
||||
# Allow other CMake projects to find this package if it is installed
|
||||
# Requires the use of the standard CMake module CMakePackageConfigHelpers
|
||||
|
||||
set ( @CMAKE_PROJECT_NAME@_VERSION @VERSION@ )
|
||||
|
||||
###@COMPILER_CONSISTENCY_CHECK@
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
# Provide the targets
|
||||
set_and_check ( @PACKAGE_NAME@_CONFIG_INSTALL_DIR "@PACKAGE_EXPORT_INSTALL_DIR@" )
|
||||
include ( "${@PACKAGE_NAME@_CONFIG_INSTALL_DIR}/@PACKAGE_NAME@-targets.cmake" )
|
||||
|
||||
# Make the module files available via include
|
||||
set_and_check ( @CMAKE_PROJECT_NAME@_INCLUDE_DIRS "@PACKAGE_INSTALL_MOD_DIR@" )
|
||||
@ -0,0 +1,90 @@
|
||||
include(CMakeParseArguments)
|
||||
|
||||
# Function to parse version info from git and/or .VERSION file
|
||||
function(set_version)
|
||||
set(options "")
|
||||
set(oneValueArgs VERSION_VARIABLE GIT_DESCRIBE_VAR CUSTOM_VERSION_FILE CUSTOM_VERSION_REGEX )
|
||||
set(multiValueArgs "")
|
||||
cmake_parse_arguments(set_version "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
# Algorithm:
|
||||
# 1. Get first line of .VERSION file, which will be set via `git archive` so long as
|
||||
#
|
||||
# 2. If not a packaged release check if this is an active git repo
|
||||
# 3. Get version info from `git describe`
|
||||
# 4. First the most recent tag is fetched if available
|
||||
# 5. Then the full `git describe` output is fetched
|
||||
|
||||
|
||||
if(NOT set_version_CUSTOM_VERSION_REGEX)
|
||||
set(_VERSION_REGEX "[vV]*[0-9]+\\.[0-9]+\\.[0-9]+")
|
||||
else()
|
||||
set(_VERSION_REGEX ${set_version_CUSTOM_VERSION_REGEX})
|
||||
endif()
|
||||
if(NOT set_version_CUSTOM_VERSION_FILE)
|
||||
set(_VERSION_FILE "${CMAKE_SOURCE_DIR}/.VERSION")
|
||||
else()
|
||||
set(_VERSION_FILE "${set_version_CUSTOM_VERSION_FILE}")
|
||||
endif()
|
||||
|
||||
file(STRINGS "${_VERSION_FILE}" first_line
|
||||
LIMIT_COUNT 1
|
||||
)
|
||||
|
||||
string(REGEX MATCH ${_VERSION_REGEX}
|
||||
_package_version "${first_line}")
|
||||
|
||||
if((NOT (_package_version MATCHES ${_VERSION_REGEX})) AND (EXISTS "${CMAKE_SOURCE_DIR}/.git"))
|
||||
message( STATUS "Build from git repository detected")
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
set(GIT_FOUND "${GIT_FOUND}" PARENT_SCOPE)
|
||||
execute_process(COMMAND "${GIT_EXECUTABLE}" describe --abbrev=0
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE _git_status
|
||||
OUTPUT_VARIABLE _git_output
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if((_git_status STREQUAL "0") AND (_git_output MATCHES ${_VERSION_REGEX}))
|
||||
set(_package_version "${_git_output}")
|
||||
endif()
|
||||
execute_process(COMMAND "${GIT_EXECUTABLE}" describe --always
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE _git_status
|
||||
OUTPUT_VARIABLE _full_git_describe
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT (_git_status STREQUAL "0"))
|
||||
set(_full_git_describe NOTFOUND)
|
||||
endif()
|
||||
else()
|
||||
message( WARNING "Could not find git executable!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT (_package_version MATCHES ${_VERSION_REGEX}))
|
||||
message( WARNING "Could not extract version from git, falling back on ${_VERSION_FILE}.")
|
||||
file(STRINGS ".VERSION" _package_version
|
||||
REGEX ${_VERSION_REGEX}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT _full_git_describe)
|
||||
set(_full_git_describe ${_package_version})
|
||||
endif()
|
||||
|
||||
# Strip leading "v" character from package version tags so that
|
||||
# the version string can be passed to the CMake `project` command
|
||||
string(REPLACE "v" "" _package_version "${_package_version}")
|
||||
string(REPLACE "V" "" _package_version "${_package_version}")
|
||||
|
||||
if(set_version_VERSION_VARIABLE)
|
||||
set(${set_version_VERSION_VARIABLE} ${_package_version} PARENT_SCOPE)
|
||||
else()
|
||||
set(PROJECT_VERSION ${_package_version} PARENT_SCOPE)
|
||||
endif()
|
||||
if(set_version_GIT_DESCRIBE_VAR)
|
||||
set(${set_version_GIT_DESCRIBE_VAR} ${_full_git_describe} PARENT_SCOPE)
|
||||
else()
|
||||
set(FULL_GIT_DESCRIBE ${_full_git_describe} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
@ -0,0 +1,23 @@
|
||||
# Adapted from http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F May 1, 2014
|
||||
|
||||
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
|
||||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
|
||||
endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
|
||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
||||
foreach(file ${files})
|
||||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
|
||||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
exec_program(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
if(NOT "${rm_retval}" STREQUAL 0)
|
||||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
|
||||
endif(NOT "${rm_retval}" STREQUAL 0)
|
||||
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
||||
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
endforeach(file)
|
||||
Loading…
Reference in New Issue