Merge pull request #225 from robertodr/bare-cmake

Ensure that CMake and Python frontend script generate the same build system
This commit is contained in:
Radovan Bast 2018-03-01 11:37:14 +01:00 committed by GitHub
commit 945ba4e266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 200 additions and 29 deletions

View File

@ -1,19 +1,32 @@
with import <nixpkgs> {}; {
autocmakeEnv = stdenv.mkDerivation {
let
hostPkgs = import <nixpkgs> {};
nixpkgs = (hostPkgs.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs-channels";
rev = "nixos-unstable";
sha256 = "15fcl29a97f68j1pjywmrjm31rdh1a21jz9airlsbzpl4lc3zhfi";
});
in
with import nixpkgs {};
stdenv.mkDerivation {
name = "Autocmake";
buildInputs = [
atlas
ccache
clang
cmake
doxygen
gcc
gfortran
liblapack
openmpi
python35Packages.pep8
python35Packages.pytest
python35Packages.pyyaml
pipenv
python3Packages.pep8
python3Packages.pytest
python3Packages.pyyaml
zlib
];
};
}
src = null;
shellHook = ''
export NINJA_STATUS="[Built edge %f of %t in %e sec]"
SOURCE_DATE_EPOCH=$(date +%s)
'';
}

6
.envrc
View File

@ -1,7 +1 @@
use nix .default.nix
export SOURCE_DATE_EPOCH=$(date +%s)
dir_hash=autocmake-$(echo -n autocmake | shasum | cut -d ' ' -f 1)
direnv_layout_dir=$XDG_CACHE_HOME/direnv/layouts/$dir_hash
layout python `type -P python` --system-site-packages
pip install -r requirements.txt
export NINJA_STATUS="[Built edge %f of %t in %e sec]"

16
Pipfile Normal file
View File

@ -0,0 +1,16 @@
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
pycodestyle = "*"
pytest = "*"
PyYAML = "*"
[dev-packages]

92
Pipfile.lock generated Normal file
View File

@ -0,0 +1,92 @@
{
"_meta": {
"hash": {
"sha256": "256e12866f5cef6ea667f41ee4dcdf970e9c74c1f6e278241746d1c2858472f4"
},
"host-environment-markers": {
"implementation_name": "cpython",
"implementation_version": "3.6.4",
"os_name": "posix",
"platform_machine": "x86_64",
"platform_python_implementation": "CPython",
"platform_release": "4.9.75",
"platform_system": "Linux",
"platform_version": "#1-NixOS SMP Fri Jan 5 14:46:36 UTC 2018",
"python_full_version": "3.6.4",
"python_version": "3.6",
"sys_platform": "linux"
},
"pipfile-spec": 6,
"requires": {},
"sources": [
{
"name": "pypi",
"url": "https://pypi.python.org/simple",
"verify_ssl": true
}
]
},
"default": {
"attrs": {
"hashes": [
"sha256:a17a9573a6f475c99b551c0e0a812707ddda1ec9653bed04c13841404ed6f450",
"sha256:1c7960ccfd6a005cd9f7ba884e6316b5e430a3f1a6c37c5f87d8b43f83b54ec9"
],
"version": "==17.4.0"
},
"pluggy": {
"hashes": [
"sha256:7f8ae7f5bdf75671a718d2daf0a64b7885f74510bcd98b1a0bb420eb9a9d0cff"
],
"version": "==0.6.0"
},
"py": {
"hashes": [
"sha256:8cca5c229d225f8c1e3085be4fcf306090b00850fefad892f9d96c7b6e2f310f",
"sha256:ca18943e28235417756316bfada6cd96b23ce60dd532642690dcfdaba988a76d"
],
"version": "==1.5.2"
},
"pycodestyle": {
"hashes": [
"sha256:6c4245ade1edfad79c3446fadfc96b0de2759662dc29d07d80a6f27ad1ca6ba9",
"sha256:682256a5b318149ca0d2a9185d365d8864a768a28db66a84a2ea946bcc426766"
],
"version": "==2.3.1"
},
"pytest": {
"hashes": [
"sha256:b84878865558194630c6147f44bdaef27222a9f153bbd4a08908b16bf285e0b1",
"sha256:53548280ede7818f4dc2ad96608b9f08ae2cc2ca3874f2ceb6f97e3583f25bc4"
],
"version": "==3.3.2"
},
"pyyaml": {
"hashes": [
"sha256:3262c96a1ca437e7e4763e2843746588a965426550f3797a79fca9c6199c431f",
"sha256:16b20e970597e051997d90dc2cddc713a2876c47e3d92d59ee198700c5427736",
"sha256:e863072cdf4c72eebf179342c94e6989c67185842d9997960b3e69290b2fa269",
"sha256:bc6bced57f826ca7cb5125a10b23fd0f2fff3b7c4701d64c439a300ce665fff8",
"sha256:c01b880ec30b5a6e6aa67b09a2fe3fb30473008c85cd6a67359a1b15ed6d83a4",
"sha256:827dc04b8fa7d07c44de11fabbc888e627fa8293b695e0f99cb544fdfa1bf0d1",
"sha256:592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab",
"sha256:5f84523c076ad14ff5e6c037fe1c89a7f73a3e04cf0377cb4d017014976433f3",
"sha256:0c507b7f74b3d2dd4d1322ec8a94794927305ab4cebbe89cc47fe5e81541e6e8",
"sha256:b4c423ab23291d3945ac61346feeb9a0dc4184999ede5e7c43e1ffb975130ae6",
"sha256:ca233c64c6e40eaa6c66ef97058cdc80e8d0157a443655baa1b2966e812807ca",
"sha256:4474f8ea030b5127225b8894d626bb66c01cda098d47a2b0d3429b6700af9fd8",
"sha256:326420cbb492172dec84b0f65c80942de6cedb5233c413dd824483989c000608",
"sha256:5ac82e411044fb129bae5cfbeb3ba626acb2af31a8d17d175004b70862a741a7"
],
"version": "==3.12"
},
"six": {
"hashes": [
"sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb",
"sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9"
],
"version": "==1.11.0"
}
},
"develop": {}
}

View File

@ -45,6 +45,43 @@ def autogenerated_notice():
return '\n'.join(s)
def gen_cmake_options_wrappers():
s = """\n# Options handling utilities
include(CMakeDependentOption)
# Macro for printing an option in a consistent manner
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
# Syntax: print_option(<option to print> <was specified>)
macro(print_option variable default)
if(NOT DEFINED ${variable} OR "${${variable}}" STREQUAL "")
message(STATUS "Setting (unspecified) option ${variable}: ${default}")
else()
message(STATUS "Setting option ${variable}: ${${variable}}")
endif()
endmacro()
# Wraps an option with default ON/OFF. Adds nice messaging to option()
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
# Syntax: option_with_print(<option name> <description> <default value>)
macro(option_with_print variable msge default)
print_option(${variable} ${default})
option(${variable} ${msge} ${default})
endmacro(option_with_print)
# Wraps an option with a default other than ON/OFF and prints it
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
# NOTE: Can\'t combine with above b/c CMake handles ON/OFF options specially
# NOTE2: CMake variables are always defined so need to further check for if
# they are the NULL string. This is also why weneed the force
# Syntax: option_with_default(<option name> <description> <default value>)
macro(option_with_default variable msge default)
print_option(${variable} "${default}")
if(NOT DEFINED ${variable} OR "${${variable}}" STREQUAL "")
set(${variable} "${default}" CACHE STRING ${msge} FORCE)
endif()
endmacro(option_with_default)"""
return s
def gen_setup(config, default_build_type, relative_path, setup_script_name):
"""
Generate setup script.
@ -148,6 +185,8 @@ def gen_cmakelists(project_name, project_language, min_cmake_version, default_bu
s.append(' set(CMAKE_BUILD_TYPE "{0}")'.format(_build_type))
s.append('endif()')
s.append(gen_cmake_options_wrappers())
if len(modules) > 0:
s.append('\n# directories which hold included cmake modules')

View File

@ -46,6 +46,8 @@
# - "--blas=<BLAS> Detect and link BLAS library (auto or off) [default: auto]."
# - "--lapack=<LAPACK> Detect and link LAPACK library (auto or off) [default: auto]."
# - "--mkl=<MKL> Pass MKL flag to the Intel compiler and linker and skip BLAS/LAPACK detection (sequential, parallel, cluster, or off) [default: off]."
# - "--scalapack=<SCALAPACK_LIBRARIES> Link line for ScaLAPACK libraries [default: ]"
# - "--blacs=<BLACS_IMPLEMENTATION> Implementation of BLACS for MKL ScaLAPACK (openmpi, intelmpi, sgimpt) [default: openmpi]"
# define:
# - "'-DENABLE_BLAS={0}'.format(arguments['--blas'])"
# - "'-DENABLE_LAPACK={0}'.format(arguments['--lapack'])"
@ -53,8 +55,19 @@
# - "'-DMATH_LIB_SEARCH_ORDER=\"MKL;ESSL;OPENBLAS;ATLAS;ACML;SYSTEM_NATIVE\"'"
# - "'-DBLAS_LANG=Fortran'"
# - "'-DLAPACK_LANG=Fortran'"
# - "'-DSCALAPACK_LIBRARIES=\"{0}\"'.format(arguments['--scalapack'])"
# - "'-DBLACS_IMPLEMENTATION=\"{0}\"'.format(arguments['--blacs'])"
# warning: "the math_libs.cmake module is deprecated and will be removed in future versions"
option_with_default(ENABLE_BLAS "Enable BLAS autodetection" "auto")
option_with_default(ENABLE_LAPACK "Enable LAPACK autodetection" "auto")
option_with_default(MKL_FLAG "MKL flag for the Intel compiler and linker. Skips BLAS/LAPACK autodetection" "off")
option_with_default(MATH_LIB_SEARCH_ORDER "Search order for autodetection of math libraries" "MKL;ESSL;OPENBLAS;ATLAS;ACML;SYSTEM_NATIVE")
option_with_default(BLAS_LANG "Linker language for BLAS detection" "Fortran")
option_with_default(LAPACK_LANG "Linker language for LAPACK detection" "Fortran")
option_with_default(SCALAPACK_LIBRARIES "Link line for ScaLAPACK libraries" "")
option_with_default(BLACS_IMPLEMENTATION "Implementation of BLACS for MKL ScaLAPACK" "openmpi")
#-------------------------------------------------------------------------------
# ENABLE_STATIC_LINKING
@ -197,7 +210,7 @@ if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
endif()
endif()
if(ENABLE_SCALAPACK)
if(ENABLE_SCALAPACK AND NOT SCALAPACK_LIBRARIES)
set(_scalapack_lib mkl_scalapack${_lib_suffix})
if(${BLACS_IMPLEMENTATION} STREQUAL "intelmpi")
set(_blacs_lib mkl_blacs_intelmpi${_lib_suffix})
@ -211,6 +224,7 @@ if(ENABLE_SCALAPACK)
else()
set(_scalapack_lib)
set(_blacs_lib)
set(BLACS_IMPLEMENTATION)
endif()
# MKL 10.0.1.014
@ -432,7 +446,7 @@ foreach(_service BLAS LAPACK)
endif()
endforeach()
if(NOT MKL_FLAG STREQUAL "off")
if(MKL_FLAG AND NOT MKL_FLAG STREQUAL "off")
set(EXTERNAL_LIBS ${EXTERNAL_LIBS} -mkl=${MKL_FLAG})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mkl=${MKL_FLAG}")
message(STATUS "User set explicit MKL flag which is passed to the compiler and linker: -mkl=${MKL_FLAG}")
@ -495,12 +509,21 @@ foreach(_service BLAS LAPACK)
endforeach()
# first lapack, then blas as lapack might need blas routine
set(MATH_LIBS
${MATH_LIBS}
${LAPACK_LIBRARIES}
${BLAS_LIBRARIES}
CACHE STRING "Math libraries"
)
if(SCALAPACK_LIBRARIES)
list(APPEND MATH_LIBS
${MATH_LIBS}
${SCALAPACK_LIBRARIES}
${LAPACK_LIBRARIES}
${BLAS_LIBRARIES}
)
else()
list(APPEND MATH_LIBS
${MATH_LIBS}
${LAPACK_LIBRARIES}
${BLAS_LIBRARIES}
)
endif()
set(MATH_LIBS ${MATH_LIBS} CACHE STRING "Math libraries")
# further adaptation for the static linking
if (ENABLE_STATIC_LINKING)
@ -519,9 +542,3 @@ if (ENABLE_STATIC_LINKING)
set(MATH_LIBS ${MATH_LIBS} -ldl)
endif()
endif()
if(MATH_LIB_SEARCH_ORDER)
# this print is here to avoid warning about MATH_LIB_SEARCH_ORDER which
# might be set but never used
message(STATUS "MATH_LIB_SEARCH_ORDER set to ${MATH_LIB_SEARCH_ORDER}")
endif()