Merge pull request #221 from robertodr/bare-cmake

Get setup to reproduce use of bare CMake
This commit is contained in:
Radovan Bast 2017-12-08 20:01:35 +01:00 committed by GitHub
commit 2e587b5b39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 34 additions and 41 deletions

19
.default.nix Normal file
View File

@ -0,0 +1,19 @@
with import <nixpkgs> {}; {
autocmakeEnv = stdenv.mkDerivation {
name = "Autocmake";
buildInputs = [
atlas
ccache
clang
cmake
doxygen
gfortran
liblapack
openmpi
python35Packages.pep8
python35Packages.pytest
python35Packages.pyyaml
zlib
];
};
}

7
.envrc Normal file
View File

@ -0,0 +1,7 @@
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]"

1
.gitignore vendored
View File

@ -10,6 +10,7 @@ test/*/cmake/update.py
test/*/cmake/autocmake/
test/*/cmake/downloaded/
test/*/setup
test/*/cmake_output
# generated by doc/extract_rst.py
doc/module-reference.rst

View File

@ -48,34 +48,6 @@ def setup_build_path(build_path):
os.makedirs(build_path, 0o755)
def test_adapt_cmake_command_to_platform():
cmake_command = "FC=foo CC=bar CXX=RABOOF cmake -DTHIS -DTHAT='this and that cmake' .."
res = adapt_cmake_command_to_platform(cmake_command, 'linux')
assert res == cmake_command
res = adapt_cmake_command_to_platform(cmake_command, 'win32')
assert res == "set FC=foo && set CC=bar && set CXX=RABOOF && cmake -DTHIS -DTHAT='this and that cmake' .."
cmake_command = "cmake -DTHIS -DTHAT='this and that cmake' .."
res = adapt_cmake_command_to_platform(cmake_command, 'linux')
assert res == cmake_command
res = adapt_cmake_command_to_platform(cmake_command, 'win32')
assert res == cmake_command
def adapt_cmake_command_to_platform(cmake_command, platform):
"""
Adapt CMake command to MS Windows platform.
"""
if platform == 'win32':
pos = cmake_command.find('cmake')
s = ['set {0} &&'.format(e) for e in cmake_command[:pos].split()]
s.append(cmake_command[pos:])
return ' '.join(s)
else:
return cmake_command
def run_cmake(command, build_path, default_build_path):
"""
Execute CMake command.
@ -84,7 +56,6 @@ def run_cmake(command, build_path, default_build_path):
from shutil import rmtree
topdir = os.getcwd()
os.chdir(build_path)
p = Popen(command,
shell=True,
stdin=PIPE,
@ -164,8 +135,7 @@ def configure(root_directory, build_path, cmake_command, only_show):
if not only_show:
setup_build_path(build_path)
cmake_command = adapt_cmake_command_to_platform(cmake_command, sys.platform)
cmake_command += ' -B' + build_path
print('{0}\n'.format(cmake_command))
if only_show:
sys.exit(0)

View File

@ -20,7 +20,7 @@ def gen_cmake_command(config):
s.append(' command.append({0})'.format(definition))
s.append(" command.append('-DCMAKE_BUILD_TYPE={0}'.format(arguments['--type']))")
s.append(" command.append('-G \"{0}\"'.format(arguments['--generator']))")
s.append(" command.append('-G\"{0}\"'.format(arguments['--generator']))")
s.append(" if arguments['--cmake-options'] != \"''\":")
s.append(" command.append(arguments['--cmake-options'])")
s.append(" if arguments['--prefix']:")
@ -110,7 +110,7 @@ def gen_setup(config, default_build_type, relative_path, setup_script_name):
s.append("build_path = arguments['<builddir>']")
s.append("\n")
s.append("# create cmake command")
s.append("cmake_command = '{0} {1}'.format(gen_cmake_command(options, arguments), root_directory)")
s.append("cmake_command = '{0} -H{1}'.format(gen_cmake_command(options, arguments), root_directory)")
s.append("\n")
s.append("# run cmake")
s.append("configure.configure(root_directory, build_path, cmake_command, arguments['--show'])")

View File

@ -25,8 +25,7 @@
# docopt:
# - "--cc=<CC> C compiler [default: gcc]."
# - "--extra-cc-flags=<EXTRA_CFLAGS> Extra C compiler flags [default: '']."
# export: "'CC={0}'.format(arguments['--cc'])"
# define: "'-DEXTRA_CFLAGS=\"{0}\"'.format(arguments['--extra-cc-flags'])"
# define: "'-DCMAKE_C_COMPILER={0} -DEXTRA_CFLAGS=\"{1}\"'.format(arguments['--cc'], arguments['--extra-cc-flags'])"
if(NOT DEFINED CMAKE_C_COMPILER_ID)
message(FATAL_ERROR "CMAKE_C_COMPILER_ID variable is not defined!")

View File

@ -25,8 +25,7 @@
# docopt:
# - "--cxx=<CXX> C++ compiler [default: g++]."
# - "--extra-cxx-flags=<EXTRA_CXXFLAGS> Extra C++ compiler flags [default: '']."
# export: "'CXX={0}'.format(arguments['--cxx'])"
# define: "'-DEXTRA_CXXFLAGS=\"{0}\"'.format(arguments['--extra-cxx-flags'])"
# define: "'-DCMAKE_CXX_COMPILER={0} -DEXTRA_CXXFLAGS=\"{1}\"'.format(arguments['--cxx'], arguments['--extra-cxx-flags'])"
if(NOT DEFINED CMAKE_CXX_COMPILER_ID)
message(FATAL_ERROR "CMAKE_CXX_COMPILER_ID variable is not defined!")

View File

@ -29,8 +29,7 @@
# docopt:
# - "--fc=<FC> Fortran compiler [default: gfortran]."
# - "--extra-fc-flags=<EXTRA_FCFLAGS> Extra Fortran compiler flags [default: '']."
# export: "'FC={0}'.format(arguments['--fc'])"
# define: "'-DEXTRA_FCFLAGS=\"{0}\"'.format(arguments['--extra-fc-flags'])"
# define: "'-DCMAKE_Fortran_COMPILER={0} -DEXTRA_FCFLAGS=\"{1}\"'.format(arguments['--fc'], arguments['--extra-fc-flags'])"
set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules)
include_directories(${PROJECT_BINARY_DIR}/modules)

View File

@ -35,9 +35,8 @@
# - "--fc=<FC> Fortran compiler [default: gfortran]."
# - "--extra-fc-flags=<EXTRA_FCFLAGS> Extra Fortran compiler flags [default: '']."
# - "--fc-support=<FC_SUPPORT> Toggle Fortran language support (ON/OFF) [default: ON]."
# export: "'FC={0}'.format(arguments['--fc'])"
# define:
# - "'-DEXTRA_FCFLAGS=\"{0}\"'.format(arguments['--extra-fc-flags'])"
# - "'-DCMAKE_Fortran_COMPILER={0} -DEXTRA_FCFLAGS=\"{1}\"'.format(arguments['--fc'], arguments['--extra-fc-flags'])"
# - "'-DENABLE_FC_SUPPORT={0}'.format(arguments['--fc-support'])"
option(ENABLE_FC_SUPPORT "Enable Fortran language support" ON)