Compare commits
234 Commits
stable-0.x
...
master
Author | SHA1 | Date | |
---|---|---|---|
a52e38cfad | |||
d734efee26 | |||
1ad82d5c4b | |||
9d2c6f31db | |||
b5218d50f6 | |||
fc5ab3f9c6 | |||
901c3e55cd | |||
a2037a5341 | |||
|
85a4d068b7 | ||
|
32f4562704 | ||
|
09b2ebf8db | ||
|
7f674e7892 | ||
|
09b13e5747 | ||
|
92291cb7d6 | ||
|
8c0222a87f | ||
|
d2890239d0 | ||
|
979453c610 | ||
|
839beaafd5 | ||
|
f7229c4644 | ||
|
0e63ae446f | ||
|
137c55c853 | ||
|
30e231950b | ||
|
8aa2c35793 | ||
|
9919281d98 | ||
|
e12b47e287 | ||
|
ebf3264642 | ||
|
fa53033962 | ||
|
fe28e29c0d | ||
|
3d031770d4 | ||
|
1926b3774b | ||
|
9729c77307 | ||
|
ba9c9fa329 | ||
|
44763b3ccd | ||
|
1cd15647dd | ||
|
22ef2b17da | ||
|
e9eba12bdd | ||
|
dd806dadfd | ||
|
2127b9e815 | ||
|
3e81a75b0c | ||
|
028f0f58c2 | ||
|
f6bcd9ff27 | ||
|
bedf21f4b8 | ||
|
d400ae9d26 | ||
|
b7cf89b6b6 | ||
|
16ee5b6de6 | ||
|
945ba4e266 | ||
|
0f3ee1a883 | ||
|
eee3ef90e1 | ||
|
46e404f572 | ||
|
da6c5c0024 | ||
|
30d0bb1e44 | ||
|
8c65823d91 | ||
|
9a071ff9a3 | ||
|
9953b6559d | ||
|
2e587b5b39 | ||
|
0a8e7eb325 | ||
|
7161d75691 | ||
|
65df3eae5e | ||
|
ba4aba5948 | ||
|
d0e9e82195 | ||
|
9b2f742a24 | ||
|
0f01fe476d | ||
|
dd2d7465f3 | ||
|
a457b749d3 | ||
|
c86e684227 | ||
|
f1f2afa6fa | ||
|
37d02eebcd | ||
|
5c004ce96a | ||
|
37a29068fa | ||
|
13b331e54a | ||
|
43d2bcde1f | ||
|
d2a121b1cd | ||
|
c40f7b9033 | ||
|
58a29ed461 | ||
|
7f21bfc10e | ||
|
8386baed11 | ||
|
2f8ee1cd51 | ||
|
3c89372485 | ||
|
5b01a62751 | ||
|
c4cbe7c858 | ||
|
d33dac0c0f | ||
|
a66ef00e8b | ||
|
af1cfe760e | ||
|
5c4a515a31 | ||
|
4ecba13766 | ||
|
98ba4cf3b2 | ||
|
28b9ba022c | ||
|
3349ddbe1d | ||
|
e607ebe284 | ||
|
5a10a3f23d | ||
|
c4e5c3130c | ||
|
011669838e | ||
|
d081364685 | ||
|
8fd3640685 | ||
|
2e92a8f876 | ||
|
dffc84c013 | ||
|
9006d96b1b | ||
|
5829a5991a | ||
|
53a6f3f715 | ||
|
5dc60d3a3c | ||
|
0f47558e3a | ||
|
7a9736d4df | ||
|
c79cbda4bd | ||
|
319ce56308 | ||
|
88ca810194 | ||
|
a5d8d51880 | ||
|
1d286edf2a | ||
|
e7b28d04dc | ||
|
bffe5a5848 | ||
|
7bdf85dcc6 | ||
|
b89977a037 | ||
|
893c9bd80c | ||
|
588f26a5bc | ||
|
0eb3a8e56c | ||
|
f614025183 | ||
|
f33a74df5a | ||
|
fe0c1f69ec | ||
|
caf8d639a0 | ||
|
310add559b | ||
|
4efb243161 | ||
|
331b81bf32 | ||
|
45a4a0022f | ||
|
8ba73f5a1d | ||
|
08d0a6837b | ||
|
2374f5bbed | ||
|
69927f195d | ||
|
8ddd1a5f05 | ||
|
d9287cf2a5 | ||
|
5dba22b8e7 | ||
|
0da60d43eb | ||
|
6353a2e440 | ||
|
003cff2dff | ||
|
33ed130d39 | ||
|
dfd6e41946 | ||
|
7c5f82bc8a | ||
|
808d094420 | ||
|
0f86f0bea9 | ||
|
49d1652c98 | ||
|
2dd36eb15d | ||
|
d08cd10e33 | ||
|
a9ceb81f39 | ||
|
9c9f001e57 | ||
|
be5d760555 | ||
|
7a9af28fca | ||
|
3200b0022d | ||
|
28547c43f7 | ||
|
5a93ad7485 | ||
|
0a62067a6b | ||
|
f4889cf134 | ||
|
8b055107ca | ||
|
0c42f1a9af | ||
|
5b04d7a8a4 | ||
|
6cf25bbd2b | ||
|
24d235ac1a | ||
|
ca8a86aa61 | ||
|
42e5192dc9 | ||
|
931ab9b444 | ||
|
8af4e033d9 | ||
|
bfeef557e7 | ||
|
6896da511c | ||
|
30ced00c4f | ||
|
37d430c0fd | ||
|
ee07ecb83e | ||
|
4d005acaa0 | ||
|
28582ceba7 | ||
|
939de1edb0 | ||
|
ed4dcbb138 | ||
|
5d70c2f2cc | ||
|
23de8f4703 | ||
|
d1545b9379 | ||
|
84b0e7c93c | ||
|
369e0a4937 | ||
|
648bc2c20d | ||
|
61ad3d7359 | ||
|
a32c9d6f46 | ||
|
9531ac499e | ||
|
e2ae1fac50 | ||
|
5dc2bb2880 | ||
|
d0dc52c7a9 | ||
|
51cdb55c53 | ||
|
ac03dc7998 | ||
|
5b7ad87479 | ||
|
0c6976a70d | ||
|
4eb5dee936 | ||
|
d09aa22623 | ||
|
104f64cb1c | ||
|
83c0c3fabd | ||
|
45fc08f37b | ||
|
91c79f9d3c | ||
|
ebc1ecc127 | ||
|
f447153eeb | ||
|
90b89354db | ||
|
24ff4c430e | ||
|
bcafc815fc | ||
|
d5e44a5bce | ||
|
e0b81c5516 | ||
|
0d500bc838 | ||
|
88ddf9a1d1 | ||
|
1b0f664735 | ||
|
8d7a0dc79c | ||
|
07d431607f | ||
|
f4112a758a | ||
|
923116a113 | ||
|
d7df341793 | ||
|
3565e2d885 | ||
|
7def4fa318 | ||
|
c2fb14b22e | ||
|
e36af9059b | ||
|
2dff967497 | ||
|
f2ef8bf393 | ||
|
1a2bd4507b | ||
|
9e63f3e042 | ||
|
e2fee84581 | ||
|
3a5192eed8 | ||
|
ffacd0378b | ||
|
1543af1a3e | ||
|
653a4fafcb | ||
|
cfb842e7bb | ||
|
cc6b374b93 | ||
|
2d858a2a5a | ||
|
4e0d0730d8 | ||
|
4e8a1dbac6 | ||
|
950ff76bd5 | ||
|
4a20af4af9 | ||
|
edf1245760 | ||
|
e784ff88e0 | ||
|
806564e2e8 | ||
|
6926c30b3c | ||
|
69478cb27e | ||
|
4ef972dbd2 | ||
|
777a57908c | ||
|
ae2863cf1b | ||
|
5615da7c78 | ||
|
5be6e66038 |
32
.default.nix
Normal file
32
.default.nix
Normal file
@ -0,0 +1,32 @@
|
||||
let
|
||||
hostPkgs = import <nixpkgs> {};
|
||||
nixpkgs = (hostPkgs.fetchFromGitHub {
|
||||
owner = "NixOS";
|
||||
repo = "nixpkgs-channels";
|
||||
rev = "nixos-unstable";
|
||||
sha256 = "1rc1pjnvfi194gka45zc1nivzsncc819kvxlfv277l2c8ryhgbpc";
|
||||
});
|
||||
in
|
||||
with import nixpkgs {};
|
||||
stdenv.mkDerivation {
|
||||
name = "Autocmake";
|
||||
buildInputs = [
|
||||
ccache
|
||||
cmake
|
||||
doxygen
|
||||
gcc
|
||||
gfortran
|
||||
liblapack
|
||||
openmpi
|
||||
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
.gitignore
vendored
6
.gitignore
vendored
@ -7,9 +7,13 @@ __pycache__/
|
||||
test/*/CMakeLists.txt
|
||||
test/*/build*/
|
||||
test/*/cmake/update.py
|
||||
test/*/cmake/lib/
|
||||
test/*/cmake/autocmake/
|
||||
test/*/cmake/downloaded/
|
||||
test/*/setup
|
||||
test/*/cmake_output
|
||||
|
||||
# generated by doc/extract_rst.py
|
||||
doc/module-reference.rst
|
||||
.idea/
|
||||
/tmp/
|
||||
_build
|
||||
|
49
.travis.yml
49
.travis.yml
@ -5,6 +5,29 @@ matrix:
|
||||
include:
|
||||
|
||||
- os: linux
|
||||
python: 2.7
|
||||
compiler: gcc
|
||||
env: SOURCES=ubuntu-toolchain-r-test
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
# compilers
|
||||
- g++
|
||||
- gfortran
|
||||
# math libraries
|
||||
- libblas-dev
|
||||
- liblapack-dev
|
||||
- libatlas-base-dev
|
||||
# mpi
|
||||
- openmpi-bin
|
||||
- libopenmpi-dev
|
||||
# python library, development version
|
||||
- libpython2.7
|
||||
|
||||
- os: linux
|
||||
python: 3.5
|
||||
compiler: gcc
|
||||
env: SOURCES=ubuntu-toolchain-r-test
|
||||
addons:
|
||||
@ -15,7 +38,6 @@ matrix:
|
||||
# compilers
|
||||
- g++
|
||||
- gfortran
|
||||
- cmake
|
||||
# math libraries
|
||||
- libblas-dev
|
||||
- liblapack-dev
|
||||
@ -25,35 +47,36 @@ matrix:
|
||||
- libopenmpi-dev
|
||||
# python library, development version
|
||||
- libpython2.7
|
||||
# boost
|
||||
- libboost-all-dev
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode6.4
|
||||
osx_image: xcode11
|
||||
compiler: gcc
|
||||
env: SOURCES=homebrew
|
||||
env:
|
||||
- SOURCES=homebrew
|
||||
|
||||
install:
|
||||
- |
|
||||
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
|
||||
brew install cmake boost python gcc open-mpi
|
||||
brew update &> /dev/null
|
||||
pip install virtualenv
|
||||
elif [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
|
||||
pip install --user virtualenv
|
||||
mkdir -p $HOME/dependencies/cmake
|
||||
curl -Ls https://cmake.org/files/v3.8/cmake-3.8.0-Linux-x86_64.tar.gz | tar -xz -C $HOME/dependencies/cmake --strip-components=1
|
||||
export PATH=$HOME/dependencies/cmake/bin${PATH:+:$PATH}
|
||||
fi
|
||||
- cmake --version
|
||||
- virtualenv venv
|
||||
- source venv/bin/activate
|
||||
- pip install pep8 pytest
|
||||
- pip install -r requirements.txt
|
||||
|
||||
script:
|
||||
# pep8 tests
|
||||
- pep8 --ignore=E501 update.py
|
||||
- pep8 --ignore=E501 test/test.py
|
||||
- pep8 --ignore=E501 lib/config.py
|
||||
# pycodestyle tests
|
||||
- pycodestyle --ignore E501 update.py
|
||||
- pycodestyle --ignore E501,E265,E741 autocmake --exclude autocmake/external/docopt.py
|
||||
# unit tests
|
||||
- py.test -vv update.py
|
||||
- py.test -vv autocmake/*
|
||||
- py.test -vv test/test.py
|
||||
- py.test -vv lib/config.py
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
@ -1,13 +1,14 @@
|
||||
# Authors
|
||||
|
||||
- Jonas Juselius
|
||||
- Radovan Bast
|
||||
- Roberto Di Remigio
|
||||
- Jonas Juselius
|
||||
|
||||
# Contributors
|
||||
|
||||
- Miroslav Ilias (Windows, portability, earliest adopter testing and feedback, math library testing)
|
||||
- Ivan Hrasko (Windows, Appveyor testing)
|
||||
- Dan Jonsson (idea for configuration file approach)
|
||||
- Roberto Di Remigio (design ideas and testing, OS X testing, Boost)
|
||||
- Dan Jonsson (idea for configuration file approach which preceded YAML solution)
|
||||
|
||||
For a list of all the contributions see https://github.com/coderefinery/autocmake/contributors.
|
||||
For a list of all the contributions,
|
||||
see https://github.com/dev-cafe/autocmake/contributors.
|
||||
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2015-2016 by Radovan Bast, Jonas Juselius, and contributors.
|
||||
Copyright (c) 2015-2017 by Radovan Bast, Roberto Di Remigio, Jonas Juselius, and contributors.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
30
README.md
30
README.md
@ -1,22 +1,34 @@
|
||||
[](https://travis-ci.org/coderefinery/autocmake/builds)
|
||||
[](http://autocmake.readthedocs.org)
|
||||
[](../stable-0.x/LICENSE)
|
||||
[](https://travis-ci.org/dev-cafe/autocmake/builds)
|
||||
[](http://autocmake.readthedocs.org)
|
||||
[](LICENSE)
|
||||
[](https://zenodo.org/badge/latestdoi/36069881)
|
||||
|
||||
|
||||
# Autocmake
|
||||

|
||||
|
||||
A CMake plugin composer.
|
||||
Licensed under [BSD-3](../stable-0.x/LICENSE).
|
||||
Licensed under [BSD-3](LICENSE).
|
||||
See http://autocmake.org.
|
||||
|
||||
|
||||
### Projects using Autocmake
|
||||
## Documentation
|
||||
|
||||
- [Numgrid](https://github.com/dftlibs/numgrid/)
|
||||
- [XCint](https://github.com/dftlibs/xcint/)
|
||||
- [Latest stable code](http://autocmake.readthedocs.io/en/stable-0.x/) (stable-0.x branch)
|
||||
- [Bleeding edge code](http://autocmake.readthedocs.io/en/latest/) (master branch)
|
||||
|
||||
|
||||
## Projects using Autocmake
|
||||
|
||||
- [Numgrid](https://github.com/dftlibs/numgrid)
|
||||
- [XCint](https://github.com/dftlibs/xcint)
|
||||
- [DIRAC](http://diracprogram.org)
|
||||
- [mathlib-tester](https://github.com/miroi/mathlibs-tester)
|
||||
- [Fortran Input Reader](https://github.com/miroi/fortran_input_reader)
|
||||
- [PCMSolver](https://github.com/PCMSolver/pcmsolver)
|
||||
- GRASP: General-purpose Relativistic Atomic Structure Program
|
||||
- [MRChem](https://github.com/MRChemSoft/mrchem)
|
||||
- [ReSpect](http://rel-qchem.sav.sk)
|
||||
- [Flanders](https://github.com/bast/flanders)
|
||||
- [Polygons](https://github.com/bast/polygons)
|
||||
- [GIMIC](https://github.com/qmcurrents/gimic)
|
||||
|
||||
If you use Autocmake, please link to your project via a pull request.
|
||||
|
1
autocmake/__init__.py
Normal file
1
autocmake/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
__version__ = '1.0.0'
|
@ -18,7 +18,8 @@ def check_cmake_exists(cmake_command):
|
||||
"""
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
p = Popen('{0} --version'.format(cmake_command),
|
||||
p = Popen(
|
||||
'{0} --version'.format(cmake_command),
|
||||
shell=True,
|
||||
stdin=PIPE,
|
||||
stdout=PIPE)
|
||||
@ -41,77 +42,76 @@ def setup_build_path(build_path):
|
||||
fname = os.path.join(build_path, 'CMakeCache.txt')
|
||||
if os.path.exists(fname):
|
||||
sys.stderr.write('aborting setup\n')
|
||||
sys.stderr.write('build directory {0} which contains CMakeCache.txt already exists\n'.format(build_path))
|
||||
sys.stderr.write('remove the build directory and then rerun setup\n')
|
||||
sys.stderr.write(
|
||||
'build directory {0} which contains CMakeCache.txt already exists\n'.
|
||||
format(build_path))
|
||||
sys.stderr.write(
|
||||
'remove the build directory and then rerun setup\n')
|
||||
sys.exit(1)
|
||||
else:
|
||||
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):
|
||||
def add_quotes_to_argv(argv, arguments):
|
||||
"""
|
||||
Adapt CMake command to MS Windows platform.
|
||||
This function tries to solve this problem:
|
||||
https://stackoverflow.com/questions/19120247/python-sys-argv-to-preserve-or
|
||||
|
||||
The problem is that sys.argv has been stripped of quotes by the shell but
|
||||
docopt's arguments contains quotes.
|
||||
|
||||
So what we do is cycle through all docopt arguments: if they are also
|
||||
present in sys.argv and contain spaces, we add quotes.
|
||||
"""
|
||||
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
|
||||
setup_command = ' '.join(argv[:])
|
||||
|
||||
for k, v in arguments.items():
|
||||
if isinstance(v, str):
|
||||
if ' ' in v:
|
||||
if v in setup_command:
|
||||
setup_command = setup_command.replace(v, '"{}"'.format(v))
|
||||
|
||||
return setup_command
|
||||
|
||||
|
||||
def run_cmake(command, build_path, default_build_path):
|
||||
def run_cmake(command, build_path, default_build_path, arguments):
|
||||
"""
|
||||
Execute CMake command.
|
||||
"""
|
||||
from subprocess import Popen, PIPE
|
||||
from shutil import rmtree
|
||||
|
||||
topdir = os.getcwd()
|
||||
os.chdir(build_path)
|
||||
p = Popen(command,
|
||||
shell=True,
|
||||
stdin=PIPE,
|
||||
stdout=PIPE,
|
||||
stderr=PIPE)
|
||||
p = Popen(command, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||
stdout_coded, stderr_coded = p.communicate()
|
||||
stdout = stdout_coded.decode('UTF-8')
|
||||
stderr = stderr_coded.decode('UTF-8')
|
||||
if stderr:
|
||||
sys.stderr.write(stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# print cmake output to screen
|
||||
print(stdout)
|
||||
|
||||
if stderr:
|
||||
# we write out stderr but we do not stop yet
|
||||
# this is because CMake warnings are sent to stderr
|
||||
# and they might be benign
|
||||
sys.stderr.write(stderr)
|
||||
|
||||
# write cmake output to file
|
||||
with open('cmake_output', 'w') as f:
|
||||
with open(os.path.join(build_path, 'cmake_output'), 'w') as f:
|
||||
f.write(stdout)
|
||||
|
||||
# change directory and return
|
||||
os.chdir(topdir)
|
||||
if 'Configuring incomplete' in stdout:
|
||||
# configuration was not successful
|
||||
if (build_path == default_build_path):
|
||||
# remove build_path iff not set by the user
|
||||
# otherwise removal can be dangerous
|
||||
rmtree(default_build_path)
|
||||
else:
|
||||
# configuration was successful
|
||||
save_setup_command(sys.argv, build_path)
|
||||
|
||||
# to figure out whether configuration was a success
|
||||
# we check for 3 sentences that should be part of stdout
|
||||
configuring_done = '-- Configuring done' in stdout
|
||||
generating_done = '-- Generating done' in stdout
|
||||
build_files_written = '-- Build files have been written to' in stdout
|
||||
configuration_successful = configuring_done and generating_done and build_files_written
|
||||
|
||||
if configuration_successful:
|
||||
setup_command = add_quotes_to_argv(sys.argv, arguments)
|
||||
save_setup_command(setup_command, build_path)
|
||||
print_build_help(build_path, default_build_path)
|
||||
|
||||
|
||||
@ -128,16 +128,16 @@ def print_build_help(build_path, default_build_path):
|
||||
print(' $ make')
|
||||
|
||||
|
||||
def save_setup_command(argv, build_path):
|
||||
def save_setup_command(setup_command, build_path):
|
||||
"""
|
||||
Save setup command to a file.
|
||||
"""
|
||||
file_name = os.path.join(build_path, 'setup_command')
|
||||
with open(file_name, 'w') as f:
|
||||
f.write(' '.join(argv[:]) + '\n')
|
||||
f.write(setup_command + '\n')
|
||||
|
||||
|
||||
def configure(root_directory, build_path, cmake_command, only_show):
|
||||
def configure(root_directory, build_path, cmake_command, arguments):
|
||||
"""
|
||||
Main configure function.
|
||||
"""
|
||||
@ -149,13 +149,12 @@ def configure(root_directory, build_path, cmake_command, only_show):
|
||||
# deal with build path
|
||||
if build_path is None:
|
||||
build_path = default_build_path
|
||||
if not only_show:
|
||||
if not arguments['--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:
|
||||
if arguments['--show']:
|
||||
sys.exit(0)
|
||||
|
||||
run_cmake(cmake_command, build_path, default_build_path)
|
||||
run_cmake(cmake_command, build_path, default_build_path, arguments)
|
1
autocmake/external/__init__.py
vendored
Normal file
1
autocmake/external/__init__.py
vendored
Normal file
@ -0,0 +1 @@
|
||||
# empty - this line is here to avoid problem when fetching empty files from web
|
46
autocmake/extract.py
Normal file
46
autocmake/extract.py
Normal file
@ -0,0 +1,46 @@
|
||||
def extract_list(config, section):
|
||||
from collections.abc import Iterable
|
||||
l = []
|
||||
if 'modules' in config:
|
||||
for module in config['modules']:
|
||||
for k, v in module.items():
|
||||
for x in v:
|
||||
if section in x:
|
||||
if isinstance(x[section], Iterable) and not isinstance(x[section], str):
|
||||
for y in x[section]:
|
||||
l.append(y)
|
||||
else:
|
||||
l.append(x[section])
|
||||
return l
|
||||
|
||||
|
||||
def to_d(l):
|
||||
"""
|
||||
Converts list of dicts to dict.
|
||||
"""
|
||||
_d = {}
|
||||
for x in l:
|
||||
for k, v in x.items():
|
||||
_d[k] = v
|
||||
return _d
|
||||
|
||||
|
||||
def test_to_d():
|
||||
l = [{'a': 'b'}, {'c': 'd'}]
|
||||
d = {'a': 'b', 'c': 'd'}
|
||||
assert to_d(l) == d
|
||||
|
||||
|
||||
def to_l(x):
|
||||
"""
|
||||
Converts list of dicts to dict.
|
||||
"""
|
||||
if isinstance(x, str):
|
||||
return [x]
|
||||
else:
|
||||
return x
|
||||
|
||||
|
||||
def test_to_l():
|
||||
assert to_l('foo') == ['foo']
|
||||
assert to_l(['foo', 'bar']) == ['foo', 'bar']
|
212
autocmake/generate.py
Normal file
212
autocmake/generate.py
Normal file
@ -0,0 +1,212 @@
|
||||
def gen_cmake_command(config):
|
||||
"""
|
||||
Generate CMake command.
|
||||
"""
|
||||
from autocmake.extract import extract_list
|
||||
|
||||
s = []
|
||||
s.append("\n\ndef gen_cmake_command(options, arguments):")
|
||||
s.append(' """')
|
||||
s.append(" Generate CMake command based on options and arguments.")
|
||||
s.append(' """')
|
||||
s.append(" command = []")
|
||||
|
||||
for env in config['export']:
|
||||
s.append(' command.append({0})'.format(env))
|
||||
|
||||
s.append(" command.append(arguments['--cmake-executable'])")
|
||||
|
||||
for definition in config['define']:
|
||||
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(" if arguments['--cmake-options'] != \"''\":")
|
||||
s.append(" command.append(arguments['--cmake-options'])")
|
||||
s.append(" if arguments['--prefix']:")
|
||||
s.append(" command.append('-DCMAKE_INSTALL_PREFIX=\"{0}\"'.format(arguments['--prefix']))")
|
||||
|
||||
s.append("\n return ' '.join(command)")
|
||||
|
||||
return '\n'.join(s)
|
||||
|
||||
|
||||
def autogenerated_notice():
|
||||
from datetime import date
|
||||
from . import __version__
|
||||
|
||||
current_year = date.today().year
|
||||
year_range = '2015-{0}'.format(current_year)
|
||||
|
||||
s = []
|
||||
s.append('# This file is autogenerated by Autocmake v{0} http://autocmake.org'.format(__version__))
|
||||
s.append('# Copyright (c) {0} by Radovan Bast, Roberto Di Remigio, Jonas Juselius, and contributors.'.format(year_range))
|
||||
|
||||
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()
|
||||
|
||||
# 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 we need 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()"""
|
||||
return s
|
||||
|
||||
|
||||
def gen_setup(config, default_build_type, relative_path, setup_script_name):
|
||||
"""
|
||||
Generate setup script.
|
||||
"""
|
||||
from autocmake.extract import extract_list
|
||||
|
||||
s = []
|
||||
s.append('#!/usr/bin/env python')
|
||||
s.append('\n{0}'.format(autogenerated_notice()))
|
||||
s.append('\nimport os')
|
||||
s.append('import sys')
|
||||
s.append('assert sys.version_info >= (2, 6), \'Python >= 2.6 is required\'')
|
||||
|
||||
s.append("\nsys.path.insert(0, '{0}')".format(relative_path))
|
||||
|
||||
s.append('from autocmake import configure')
|
||||
s.append('from autocmake.external import docopt')
|
||||
|
||||
s.append('\n\noptions = """')
|
||||
s.append('Usage:')
|
||||
s.append(' ./{0} [options] [<builddir>]'.format(setup_script_name))
|
||||
s.append(' ./{0} (-h | --help)'.format(setup_script_name))
|
||||
s.append('\nOptions:')
|
||||
|
||||
options = []
|
||||
|
||||
for opt in config['docopt']:
|
||||
first = opt.split()[0].strip()
|
||||
rest = ' '.join(opt.split()[1:]).strip()
|
||||
options.append([first, rest])
|
||||
|
||||
options.append(['--type=<TYPE>', 'Set the CMake build type (debug, release, relwithdebinfo, minsizerel) [default: {0}].'.format(default_build_type)])
|
||||
options.append(['--generator=<STRING>', 'Set the CMake build system generator [default: Unix Makefiles].'])
|
||||
options.append(['--show', 'Show CMake command and exit.'])
|
||||
options.append(['--cmake-executable=<CMAKE_EXECUTABLE>', 'Set the CMake executable [default: cmake].'])
|
||||
options.append(['--cmake-options=<STRING>', "Define options to CMake [default: '']."])
|
||||
options.append(['--prefix=<PATH>', 'Set the install path for make install.'])
|
||||
options.append(['<builddir>', 'Build directory.'])
|
||||
options.append(['-h --help', 'Show this screen.'])
|
||||
|
||||
s.append(align_options(options))
|
||||
|
||||
s.append('"""')
|
||||
|
||||
s.append(gen_cmake_command(config))
|
||||
|
||||
s.append("\n")
|
||||
s.append("# parse command line args")
|
||||
s.append("try:")
|
||||
s.append(" arguments = docopt.docopt(options, argv=None)")
|
||||
s.append("except docopt.DocoptExit:")
|
||||
s.append(r" sys.stderr.write('ERROR: bad input to {0}\n'.format(sys.argv[0]))")
|
||||
s.append(" sys.stderr.write(options)")
|
||||
s.append(" sys.exit(-1)")
|
||||
s.append("\n")
|
||||
s.append("# use extensions to validate/post-process args")
|
||||
s.append("if configure.module_exists('extensions'):")
|
||||
s.append(" import extensions")
|
||||
s.append(" arguments = extensions.postprocess_args(sys.argv, arguments)")
|
||||
s.append("\n")
|
||||
s.append("root_directory = os.path.dirname(os.path.realpath(__file__))")
|
||||
s.append("\n")
|
||||
s.append("build_path = arguments['<builddir>']")
|
||||
s.append("\n")
|
||||
s.append("# create cmake command")
|
||||
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)")
|
||||
|
||||
return s
|
||||
|
||||
|
||||
def gen_cmakelists(project_name, project_language, min_cmake_version, default_build_type, relative_path, modules):
|
||||
"""
|
||||
Generate CMakeLists.txt.
|
||||
"""
|
||||
import os
|
||||
|
||||
s = []
|
||||
|
||||
s.append(autogenerated_notice())
|
||||
|
||||
s.append('\n# set minimum cmake version')
|
||||
s.append('cmake_minimum_required(VERSION {0} FATAL_ERROR)'.format(min_cmake_version))
|
||||
|
||||
s.append('\n# project name')
|
||||
s.append('project({0} LANGUAGES {1})'.format(project_name, project_language))
|
||||
|
||||
s.append('\n# do not rebuild if rules (compiler flags) change')
|
||||
s.append('set(CMAKE_SKIP_RULE_DEPENDENCY TRUE)')
|
||||
|
||||
build_type_capitalized = {'debug': 'Debug',
|
||||
'release': 'Release',
|
||||
'relwithdebinfo': 'RelWithDebInfo',
|
||||
'minsizerel': 'MinSizeRel'}
|
||||
|
||||
_build_type = build_type_capitalized[default_build_type]
|
||||
s.append('\n# if CMAKE_BUILD_TYPE undefined, we set it to {0}'.format(_build_type))
|
||||
s.append('if(NOT CMAKE_BUILD_TYPE)')
|
||||
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# included cmake modules')
|
||||
for module in modules:
|
||||
s.append('include({0})'.format(os.path.join('${PROJECT_SOURCE_DIR}',
|
||||
relative_path,
|
||||
module.path,
|
||||
module.name)))
|
||||
|
||||
return s
|
||||
|
||||
|
||||
def align_options(options):
|
||||
"""
|
||||
Indents flags and aligns help texts.
|
||||
"""
|
||||
l = 0
|
||||
for opt in options:
|
||||
if len(opt[0]) > l:
|
||||
l = len(opt[0])
|
||||
s = []
|
||||
for opt in options:
|
||||
s.append(' {0}{1} {2}'.format(opt[0], ' ' * (l - len(opt[0])), opt[1]))
|
||||
return '\n'.join(s)
|
66
autocmake/interpolate.py
Normal file
66
autocmake/interpolate.py
Normal file
@ -0,0 +1,66 @@
|
||||
def replace(s, d):
|
||||
from re import findall
|
||||
|
||||
if isinstance(s, str):
|
||||
for var in findall(r"%\(([A-Za-z0-9_]*)\)", s):
|
||||
s = s.replace("%({0})".format(var), str(d[var]))
|
||||
return s
|
||||
|
||||
|
||||
def test_replace():
|
||||
assert replace('hey %(foo) ho %(bar)',
|
||||
{'foo': 'hey', 'bar': 'ho'}) == 'hey hey ho ho'
|
||||
|
||||
|
||||
def interpolate(d, d_map):
|
||||
from collections.abc import Mapping, Iterable
|
||||
from copy import copy
|
||||
|
||||
for k, v in d.items():
|
||||
if isinstance(v, Mapping):
|
||||
d[k] = interpolate(d[k], d_map)
|
||||
elif isinstance(v, Iterable) and not isinstance(v, str):
|
||||
l = []
|
||||
for x in v:
|
||||
if isinstance(x, Mapping):
|
||||
l.append(interpolate(x, d_map))
|
||||
else:
|
||||
l.append(replace(x, d_map))
|
||||
d[k] = copy(l)
|
||||
else:
|
||||
d[k] = replace(d[k], d_map)
|
||||
return d
|
||||
|
||||
|
||||
def test_interpolate():
|
||||
d = {'foo': 'hey',
|
||||
'bar': 'ho',
|
||||
'one': 'hey %(foo) ho %(bar)',
|
||||
'two': {'one': 'hey %(foo) ho %(bar)',
|
||||
'two': 'raboof'}}
|
||||
d_interpolated = {'foo': 'hey',
|
||||
'bar': 'ho',
|
||||
'one': 'hey hey ho ho',
|
||||
'two': {'one': 'hey hey ho ho',
|
||||
'two': 'raboof'}}
|
||||
assert interpolate(d, d) == d_interpolated
|
||||
|
||||
|
||||
def test_interpolate_int():
|
||||
d = {'foo': 1,
|
||||
'bar': 2,
|
||||
'one': 'hey %(foo) ho %(bar)',
|
||||
'two': {'one': 'hey %(foo) ho %(bar)',
|
||||
'two': 'raboof'}}
|
||||
d_interpolated = {'foo': 1,
|
||||
'bar': 2,
|
||||
'one': 'hey 1 ho 2',
|
||||
'two': {'one': 'hey 1 ho 2',
|
||||
'two': 'raboof'}}
|
||||
assert interpolate(d, d) == d_interpolated
|
||||
|
||||
|
||||
def test_interpolate_nested():
|
||||
d2 = {'modules': [{'fc': [{'source': '%(url_root)fc_optional.cmake'}]}], 'url_root': 'downloaded/downloaded_'}
|
||||
d2_interpolated = {'modules': [{'fc': [{'source': 'downloaded/downloaded_fc_optional.cmake'}]}], 'url_root': 'downloaded/downloaded_'}
|
||||
assert interpolate(d2, d2) == d2_interpolated
|
127
autocmake/parse_rst.py
Normal file
127
autocmake/parse_rst.py
Normal file
@ -0,0 +1,127 @@
|
||||
def parse_cmake_module(s_in, overrides={}):
|
||||
import sys
|
||||
from collections.abc import Mapping, Iterable
|
||||
from collections import defaultdict
|
||||
from autocmake.parse_yaml import parse_yaml
|
||||
from io import StringIO
|
||||
|
||||
parsed_config = defaultdict(lambda: None)
|
||||
|
||||
if 'autocmake.yml configuration::' not in s_in:
|
||||
return parsed_config
|
||||
|
||||
s_out = []
|
||||
is_rst_line = False
|
||||
for line in s_in.split('\n'):
|
||||
if is_rst_line:
|
||||
if len(line) > 0:
|
||||
if line[0] != '#':
|
||||
is_rst_line = False
|
||||
else:
|
||||
is_rst_line = False
|
||||
if is_rst_line:
|
||||
s_out.append(line[2:])
|
||||
if '#.rst:' in line:
|
||||
is_rst_line = True
|
||||
|
||||
autocmake_entry = '\n'.join(s_out).split('autocmake.yml configuration::')[1]
|
||||
autocmake_entry = autocmake_entry.replace('\n ', '\n')
|
||||
|
||||
buf = StringIO(autocmake_entry)
|
||||
config = parse_yaml(buf, overrides)
|
||||
|
||||
for k, v in config.items():
|
||||
if isinstance(v, Iterable) and not isinstance(v, str):
|
||||
parsed_config[k] = [x for x in config[k]]
|
||||
else:
|
||||
parsed_config[k] = [config[k]]
|
||||
|
||||
return parsed_config
|
||||
|
||||
|
||||
def test_parse_cmake_module():
|
||||
|
||||
s = r'''#.rst:
|
||||
#
|
||||
# Foo ...
|
||||
#
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# 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'])"
|
||||
|
||||
enable_language(CXX)
|
||||
|
||||
if(NOT DEFINED CMAKE_C_COMPILER_ID)
|
||||
message(FATAL_ERROR "CMAKE_C_COMPILER_ID variable is not defined!")
|
||||
endif()'''
|
||||
|
||||
parsed_config = parse_cmake_module(s)
|
||||
assert parsed_config['docopt'] == ["--cxx=<CXX> C++ compiler [default: g++].", "--extra-cxx-flags=<EXTRA_CXXFLAGS> Extra C++ compiler flags [default: '']."]
|
||||
|
||||
|
||||
def test_parse_cmake_module_no_key():
|
||||
|
||||
s = '''#.rst:
|
||||
#
|
||||
# Foo ...
|
||||
#
|
||||
# Bar ...
|
||||
|
||||
enable_language(CXX)
|
||||
|
||||
if(NOT DEFINED CMAKE_C_COMPILER_ID)
|
||||
message(FATAL_ERROR "CMAKE_C_COMPILER_ID variable is not defined!")
|
||||
endif()'''
|
||||
|
||||
parsed_config = parse_cmake_module(s)
|
||||
assert parsed_config['docopt'] is None
|
||||
|
||||
|
||||
def test_parse_cmake_module_interpolate():
|
||||
|
||||
s = r'''#.rst:
|
||||
#
|
||||
# Foo ...
|
||||
#
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# major: 1
|
||||
# minor: 2
|
||||
# patch: 3
|
||||
# a: v%(major)
|
||||
# b: v%(minor)
|
||||
# c: v%(patch)
|
||||
|
||||
enable_language(CXX)'''
|
||||
|
||||
parsed_config = parse_cmake_module(s)
|
||||
assert parsed_config['a'] == ['v1']
|
||||
assert parsed_config['b'] == ['v2']
|
||||
assert parsed_config['c'] == ['v3']
|
||||
|
||||
|
||||
def test_parse_cmake_module_overrides():
|
||||
|
||||
s = r'''#.rst:
|
||||
#
|
||||
# Foo ...
|
||||
#
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# major: 1
|
||||
# minor: 2
|
||||
# patch: 3
|
||||
# a: v%(major)
|
||||
# b: v%(minor)
|
||||
# c: v%(patch)
|
||||
|
||||
enable_language(CXX)'''
|
||||
|
||||
parsed_config = parse_cmake_module(s, {'minor': 4})
|
||||
assert parsed_config['a'] == ['v1']
|
||||
assert parsed_config['b'] == ['v4']
|
||||
assert parsed_config['c'] == ['v3']
|
30
autocmake/parse_yaml.py
Normal file
30
autocmake/parse_yaml.py
Normal file
@ -0,0 +1,30 @@
|
||||
def parse_yaml(stream, overrides={}):
|
||||
import yaml
|
||||
import sys
|
||||
from autocmake.interpolate import interpolate
|
||||
|
||||
try:
|
||||
config = yaml.load(stream, yaml.SafeLoader)
|
||||
except yaml.YAMLError as exc:
|
||||
print(exc)
|
||||
sys.exit(-1)
|
||||
|
||||
for k in config:
|
||||
if k in overrides:
|
||||
config[k] = overrides[k]
|
||||
|
||||
config = interpolate(config, config)
|
||||
return config
|
||||
|
||||
|
||||
def test_parse_yaml():
|
||||
text = """foo: bar
|
||||
this: that
|
||||
var: '%(foo)'
|
||||
list:
|
||||
- a: '%(foo)'
|
||||
- b: '%(foo)'
|
||||
- c: '%(foo)'"""
|
||||
|
||||
assert parse_yaml(text) == {'foo': 'bar', 'this': 'that', 'var': 'bar',
|
||||
'list': [{'a': 'bar'}, {'b': 'bar'}, {'c': 'bar'}]}
|
@ -1,6 +1,6 @@
|
||||
if(NOT DEFINED ENV{CFLAGS})
|
||||
if(CMAKE_C_COMPILER_ID MATCHES Clang)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
|
||||
endif()
|
||||
|
@ -1,6 +1,6 @@
|
||||
if(NOT DEFINED ENV{CXXFLAGS})
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
|
||||
endif()
|
||||
|
@ -1,6 +1,6 @@
|
||||
if(NOT DEFINED ENV{CFLAGS})
|
||||
if(CMAKE_C_COMPILER_ID MATCHES GNU)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
|
||||
endif()
|
||||
|
@ -1,7 +1,7 @@
|
||||
if(NOT DEFINED ENV{CXXFLAGS})
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
|
||||
endif()
|
||||
endif()
|
||||
|
@ -1,6 +1,6 @@
|
||||
if(NOT DEFINED ENV{FCFLAGS})
|
||||
if(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall -Wextra")
|
||||
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-all-loops")
|
||||
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -fbacktrace")
|
||||
endif()
|
||||
|
@ -1,6 +1,6 @@
|
||||
if(NOT DEFINED ENV{CFLAGS})
|
||||
if(CMAKE_C_COMPILER_ID MATCHES Intel)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
|
||||
endif()
|
||||
|
@ -1,6 +1,6 @@
|
||||
if(NOT DEFINED ENV{CXXFLAGS})
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
|
||||
endif()
|
||||
|
20
doc/Makefile
Normal file
20
doc/Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line, and also
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
SOURCEDIR = .
|
||||
BUILDDIR = _build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
301
doc/conf.py
301
doc/conf.py
@ -1,289 +1,48 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# Autocmake documentation build configuration file, created by
|
||||
# sphinx-quickstart on Mon Jun 1 16:41:30 2015.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
# For the full list of built-in configuration values, see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
import sys
|
||||
import os
|
||||
import shlex
|
||||
import time
|
||||
|
||||
sys.path.append(os.path.relpath(os.path.abspath('.')))
|
||||
sys.path.insert(0, os.path.abspath("."))
|
||||
import extract_rst
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
sys.path.insert(0, os.path.abspath(".."))
|
||||
from autocmake import __version__ as _version
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
# -- Project information -----------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
project = "Autocmake"
|
||||
copyright = f'2015-{time.strftime("%Y")}, Radovan Bast, Roberto Di Remigio, Jonas Juselius, and contributors'
|
||||
author = "Radovan Bast, Roberto Di Remigio, Jonas Juselius, and contributors"
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.todo',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'Autocmake'
|
||||
copyright = u'2015-2016, Radovan Bast, Jonas Juselius, and contributors'
|
||||
author = u'Radovan Bast, Jonas Juselius, and contributors'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.5'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.5.0'
|
||||
release = _version
|
||||
# The short X.Y version.
|
||||
version = ".".join(release.split(".")[0:2])
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
# -- General configuration ---------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||
#keep_warnings = False
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
extensions = [
|
||||
"sphinx.ext.todo",
|
||||
]
|
||||
todo_include_todos = True
|
||||
|
||||
templates_path = ["_templates"]
|
||||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
||||
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
root_doc = "index"
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
# directly to the root of the documentation.
|
||||
#html_extra_path = []
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# Language to be used for generating the HTML full-text search index.
|
||||
# Sphinx supports the following languages:
|
||||
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
|
||||
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
|
||||
#html_search_language = 'en'
|
||||
|
||||
# A dictionary with options for the search language support, empty by default.
|
||||
# Now only 'ja' uses this config value
|
||||
#html_search_options = {'type': 'default'}
|
||||
|
||||
# The name of a javascript file (relative to the configuration directory) that
|
||||
# implements a search results scorer. If empty, the default will be used.
|
||||
#html_search_scorer = 'scorer.js'
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'Autocmakedoc'
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'Autocmake.tex', u'Autocmake Documentation',
|
||||
u'Radovan Bast and Jonas Juselius', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'autocmake', u'Autocmake Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'Autocmake', u'Autocmake Documentation',
|
||||
author, 'Autocmake', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#texinfo_no_detailmenu = False
|
||||
html_theme = "classic"
|
||||
html_theme_options = {"body_max_width": "none", "sidebarwidth": "16%"}
|
||||
html_static_path = ["_static"]
|
||||
html_sidebars = {"**": ["globaltoc.html", "sourcelink.html", "searchbox.html"]}
|
||||
|
@ -9,12 +9,12 @@ This documentation is refreshed upon each push to the central repository.
|
||||
|
||||
The module reference documentation is generated from the module sources using
|
||||
``#.rst:`` tags (compare for instance
|
||||
http://autocmake.readthedocs.org/en/latest/module-reference.html#cc-cmake with
|
||||
https://github.com/coderefinery/autocmake/blob/stable-0.x/modules/cc.cmake).
|
||||
http://autocmake.readthedocs.io/en/latest/module-reference.html#cc-cmake with
|
||||
https://github.com/dev-cafe/autocmake/blob/master/modules/cc.cmake).
|
||||
|
||||
Please note that the lines following ``# autocmake.cfg configuration::`` are
|
||||
understood by the ``update.py`` script to infer autocmake.cfg code from the
|
||||
Please note that the lines following ``# autocmake.yml configuration::`` are
|
||||
understood by the ``update.py`` script to infer autocmake.yml code from the
|
||||
documentation. As an example consider
|
||||
https://github.com/coderefinery/autocmake/blob/stable-0.x/modules/cc.cmake#L20-L25.
|
||||
https://github.com/dev-cafe/autocmake/blob/master/modules/cc.cmake#L20-L26.
|
||||
Here, ``update.py`` will infer the configurations for ``docopt``, ``export``,
|
||||
and ``define``.
|
||||
|
@ -5,12 +5,16 @@ Testing Autocmake
|
||||
|
||||
You will need to install `pytest <http://pytest.org/>`__.
|
||||
|
||||
Check also the `Travis <https://github.com/coderefinery/autocmake/blob/stable-0.x/.travis.yml>`__
|
||||
Check also the `Travis <https://github.com/dev-cafe/autocmake/blob/master/.travis.yml>`__
|
||||
build and test recipe for other requirements.
|
||||
|
||||
Your contributions and changes should preserve the test set. You can run locally all tests with::
|
||||
Your contributions and changes should preserve the test set and be PEP8 conform.
|
||||
You can run locally all tests with::
|
||||
|
||||
$ py.test test/test.py
|
||||
$ pycodestyle --ignore E501 update.py
|
||||
$ pycodestyle --ignore E501,E265 autocmake
|
||||
$ py.test -vv autocmake/*
|
||||
$ py.test -vv test/test.py
|
||||
|
||||
You can also select individual tests, for example those with ``fc_blas`` string in the name::
|
||||
|
||||
@ -19,5 +23,5 @@ You can also select individual tests, for example those with ``fc_blas`` string
|
||||
For more options, see the ``py.test`` flags.
|
||||
|
||||
This test set is run upon each push to the central repository.
|
||||
See also the `Travis <https://travis-ci.org/coderefinery/autocmake/builds>`__
|
||||
See also the `Travis <https://travis-ci.org/dev-cafe/autocmake/builds>`__
|
||||
build and test history.
|
||||
|
@ -12,47 +12,47 @@ infrastructure files which will be needed to build the project::
|
||||
|
||||
$ mkdir cmake # does not have to be called "cmake" - take the name you prefer
|
||||
$ cd cmake
|
||||
$ wget https://github.com/coderefinery/autocmake/raw/stable-0.x/update.py
|
||||
$ wget https://github.com/dev-cafe/autocmake/raw/master/update.py
|
||||
$ virtualenv venv
|
||||
$ source venv/bin/activate
|
||||
$ pip install pyyaml
|
||||
$ python update.py --self
|
||||
|
||||
On the MS Windows system, you can use the PowerShell wget-replacement::
|
||||
|
||||
$ Invoke-WebRequest https://github.com/coderefinery/autocmake/raw/stable-0.x/update.py -OutFile update.py
|
||||
$ Invoke-WebRequest https://github.com/dev-cafe/autocmake/raw/master/update.py -OutFile update.py
|
||||
|
||||
This creates (or updates) the following files (an existing ``autocmake.cfg`` is
|
||||
This creates (or updates) the following files (an existing ``autocmake.yml`` is
|
||||
not overwritten by the script)::
|
||||
|
||||
cmake/
|
||||
autocmake.cfg # edit this file
|
||||
autocmake.yml # edit this file
|
||||
update.py # no need to edit
|
||||
lib/
|
||||
config.py # no need to edit
|
||||
docopt/
|
||||
docopt.py # no need to edit
|
||||
autocmake/ # no need to edit
|
||||
... # no need to edit
|
||||
|
||||
Note that all other listed files are overwritten (use version control).
|
||||
Note that ``update.py`` and files under ``autocmake/``
|
||||
are overwritten (use version control).
|
||||
|
||||
|
||||
Generating the CMake infrastructure
|
||||
-----------------------------------
|
||||
|
||||
Now customize ``autocmake.cfg`` to your needs
|
||||
(see :ref:`autocmake_cfg`)
|
||||
Now customize ``autocmake.yml`` to your needs
|
||||
(see :ref:`autocmake_yml`)
|
||||
and then run the ``update.py`` script which
|
||||
creates ``CMakeLists.txt`` and a setup script in the target path::
|
||||
|
||||
$ python update.py ..
|
||||
|
||||
The script also downloads external CMake modules specified in ``autocmake.cfg`` to a directory
|
||||
The script also downloads external CMake modules specified in ``autocmake.yml`` to a directory
|
||||
called ``downloaded/``::
|
||||
|
||||
cmake/
|
||||
autocmake.cfg # edit this file
|
||||
autocmake.yml # edit this file
|
||||
update.py # no need to edit
|
||||
lib/
|
||||
config.py # no need to edit
|
||||
docopt/
|
||||
docopt.py # no need to edit
|
||||
autocmake/ # no need to edit
|
||||
... # no need to edit
|
||||
downloaded/ # contains CMake modules fetched from the web
|
||||
|
||||
|
||||
|
@ -1,99 +1,86 @@
|
||||
|
||||
.. _autocmake_cfg:
|
||||
.. _autocmake_yml:
|
||||
|
||||
Configuring autocmake.cfg
|
||||
Configuring autocmake.yml
|
||||
=========================
|
||||
|
||||
The script ``autocmake.cfg`` is the high level place where you configure
|
||||
The script ``autocmake.yml`` is the high level place where you configure
|
||||
your project. Here is an example. We will discuss it in detail further
|
||||
below::
|
||||
|
||||
[project]
|
||||
name: numgrid
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[fc]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/fc.cmake
|
||||
min_cmake_version: 3.1
|
||||
|
||||
[cc]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/cc.cmake
|
||||
default_build_type: release
|
||||
|
||||
[cxx]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/cxx.cmake
|
||||
language:
|
||||
- Fortran
|
||||
- C
|
||||
- CXX
|
||||
|
||||
[flags]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/compilers/GNU.CXX.cmake
|
||||
https://github.com/coderefinery/autocmake/raw/stable-0.x/compilers/Intel.CXX.cmake
|
||||
url_root: https://github.com/dev-cafe/autocmake/raw/master/
|
||||
|
||||
[rpath]
|
||||
source: custom/rpath.cmake
|
||||
|
||||
[definitions]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/definitions.cmake
|
||||
|
||||
[coverage]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/code_coverage.cmake
|
||||
|
||||
[safeguards]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/safeguards.cmake
|
||||
|
||||
[default_build_paths]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/default_build_paths.cmake
|
||||
|
||||
[src]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/src.cmake
|
||||
|
||||
[googletest]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/googletest.cmake
|
||||
|
||||
[custom]
|
||||
source: custom/api.cmake
|
||||
custom/test.cmake
|
||||
modules:
|
||||
- compilers:
|
||||
- source:
|
||||
- '%(url_root)modules/fc.cmake'
|
||||
- '%(url_root)modules/cc.cmake'
|
||||
- '%(url_root)modules/cxx.cmake'
|
||||
- flags:
|
||||
- source:
|
||||
- '%(url_root)compilers/GNU.CXX.cmake'
|
||||
- '%(url_root)compilers/Intel.CXX.cmake'
|
||||
- 'compilers/Clang.CXX.cmake'
|
||||
- plugins:
|
||||
- source:
|
||||
- '%(url_root)modules/ccache.cmake'
|
||||
- 'custom/rpath.cmake'
|
||||
- '%(url_root)modules/definitions.cmake'
|
||||
- '%(url_root)modules/code_coverage.cmake'
|
||||
- '%(url_root)modules/safeguards.cmake'
|
||||
- '%(url_root)modules/default_build_paths.cmake'
|
||||
- '%(url_root)modules/src.cmake'
|
||||
- '%(url_root)modules/googletest.cmake'
|
||||
- 'custom/api.cmake'
|
||||
- 'custom/test.cmake'
|
||||
|
||||
|
||||
Name and order of sections
|
||||
--------------------------
|
||||
|
||||
We see that the configuration file has sections.
|
||||
The only section where the name matters is ``[project]``::
|
||||
First we define the project name (here "numgrid"). This section has to be there
|
||||
and it has to be called "project" (but it does not have to be on top).
|
||||
|
||||
[project]
|
||||
name: numgrid
|
||||
min_cmake_version: 2.8
|
||||
We also have to define ``min_cmake_version`` as well as set the supported language(s).
|
||||
|
||||
This is where we define the project name (here "numgrid"). This section has to
|
||||
be there and it has to be called "project" (but it does not have to be on top).
|
||||
The definition ``url_root`` is an interpolation (see :ref:`interpolation`) and
|
||||
we use it to avoid retyping the same line over and over and to be able to
|
||||
change it in one place. The explicit name "url_root" has no special meaning to
|
||||
Autocmake and we could have chosen a different name.
|
||||
|
||||
The names of the other sections do not matter to Autocmake. You could name them like this::
|
||||
The section ``modules`` is a list of CMake plugins. The names of the list
|
||||
elements (here "compilers", "flags", and "plugins") does not matter to
|
||||
Autocmake. We could have called them "one", "two", and "whatever", but it would
|
||||
not make much sense. It is better to choose names that are meaningful to you
|
||||
and readers of your code.
|
||||
|
||||
[project]
|
||||
name: numgrid
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[one]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/fc.cmake
|
||||
|
||||
[two]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/cc.cmake
|
||||
|
||||
[whatever]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/cxx.cmake
|
||||
|
||||
But it would not make much sense. It is better to choose names that are
|
||||
meaningful to you.
|
||||
|
||||
The order of the sections does matter and the sections will be processed in the
|
||||
exact order as you specify them in ``autocmake.cfg``.
|
||||
The order of the elements under ``modules`` does matter and the list will be
|
||||
processed in the exact order as you specify them in ``autocmake.yml``.
|
||||
|
||||
|
||||
Minimal example
|
||||
---------------
|
||||
|
||||
As a minimal example we take an ``autocmake.cfg`` which only contains::
|
||||
As a minimal example we take an ``autocmake.yml`` which only contains::
|
||||
|
||||
[project]
|
||||
name: minime
|
||||
min_cmake_version: 2.8
|
||||
min_cmake_version: 3.1
|
||||
language: C
|
||||
|
||||
If you don't have the ``update.py`` script yet, you need to fetch it from the web::
|
||||
|
||||
$ wget https://github.com/dev-cafe/autocmake/raw/master/update.py
|
||||
|
||||
First we make sure that the ``update.py`` script is up-to-date and that it has access
|
||||
to all libraries it needs::
|
||||
@ -101,15 +88,22 @@ to all libraries it needs::
|
||||
$ python update.py --self
|
||||
|
||||
- creating .gitignore
|
||||
- fetching lib/config.py
|
||||
- fetching lib/docopt/docopt.py
|
||||
- fetching autocmake/configure.py
|
||||
- fetching autocmake/__init__.py
|
||||
- fetching autocmake/external/docopt.py
|
||||
- fetching autocmake/external/__init__.py
|
||||
- fetching autocmake/generate.py
|
||||
- fetching autocmake/extract.py
|
||||
- fetching autocmake/interpolate.py
|
||||
- fetching autocmake/parse_rst.py
|
||||
- fetching autocmake/parse_yaml.py
|
||||
- fetching update.py
|
||||
|
||||
Good. Now we can generate ``CMakeLists.txt`` and the setup script::
|
||||
|
||||
$ python update ..
|
||||
$ python update.py ..
|
||||
|
||||
- parsing autocmake.cfg
|
||||
- parsing autocmake.yml
|
||||
- generating CMakeLists.txt
|
||||
- generating setup script
|
||||
|
||||
@ -119,7 +113,7 @@ Excellent. Here is the generated ``CMakeLists.txt``::
|
||||
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
||||
|
||||
# project name
|
||||
project(minime)
|
||||
project(minime C)
|
||||
|
||||
# do not rebuild if rules (compiler flags) change
|
||||
set(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
|
||||
@ -129,8 +123,6 @@ Excellent. Here is the generated ``CMakeLists.txt``::
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
endif()
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/downloaded)
|
||||
|
||||
This is the very bare minimum. Every Autocmake project will have at least these
|
||||
settings.
|
||||
|
||||
@ -147,38 +139,38 @@ the following default options::
|
||||
--show Show CMake command and exit.
|
||||
--cmake-executable=<CMAKE_EXECUTABLE> Set the CMake executable [default: cmake].
|
||||
--cmake-options=<STRING> Define options to CMake [default: ''].
|
||||
--prefix=<PATH> Set the install path for make install.
|
||||
<builddir> Build directory.
|
||||
-h --help Show this screen.
|
||||
|
||||
That's not too bad although currently we cannot do much with this since there
|
||||
are no sources listed, no targets, hence nothing to build. We need to flesh out
|
||||
``CMakeLists.txt`` by extending ``autocmake.cfg``
|
||||
and this is what we will do in the next section.
|
||||
``CMakeLists.txt`` by extending ``autocmake.yml`` and this is what we will do
|
||||
in the next section.
|
||||
|
||||
|
||||
Assembling CMake plugins
|
||||
------------------------
|
||||
|
||||
The preferred way to extend ``CMakeLists.txt`` is by editing ``autocmake.cfg``
|
||||
The preferred way to extend ``CMakeLists.txt`` is by editing ``autocmake.yml``
|
||||
and using the ``source`` option::
|
||||
|
||||
[fc]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/fc.cmake
|
||||
- compilers:
|
||||
- source:
|
||||
- '%(url_root)modules/fc.cmake'
|
||||
- '%(url_root)modules/cc.cmake'
|
||||
- '%(url_root)modules/cxx.cmake'
|
||||
|
||||
This will download ``fc.cmake`` and include it in ``CMakeLists.txt``.
|
||||
This will download ``fc.cmake``, ``cc.cmake``, and ``cxx.cmake``, and include
|
||||
them in ``CMakeLists.txt``, in this order.
|
||||
|
||||
You can also include local CMake modules, e.g.::
|
||||
|
||||
[rpath]
|
||||
source: custom/rpath.cmake
|
||||
- source:
|
||||
- 'custom/rpath.cmake'
|
||||
|
||||
It is also OK to include several modules at once::
|
||||
|
||||
[flags]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/compilers/GNU.CXX.cmake
|
||||
https://github.com/coderefinery/autocmake/raw/stable-0.x/compilers/Intel.CXX.cmake
|
||||
|
||||
The modules will be included in the same order as they appear in ``autocmake.cfg``.
|
||||
It is also OK to include several modules at once as we have seen above. The
|
||||
modules will be included in the same order as they appear in ``autocmake.yml``.
|
||||
|
||||
|
||||
Fetching files without including them in CMakeLists.txt
|
||||
@ -187,9 +179,9 @@ Fetching files without including them in CMakeLists.txt
|
||||
Sometimes you want to fetch a file without including it in ``CMakeLists.txt``.
|
||||
This can be done with the ``fetch`` option. This is for instance done by the
|
||||
``git_info.cmake`` module (see
|
||||
https://github.com/coderefinery/autocmake/blob/stable-0.x/modules/git_info/git_info.cmake#L10-L11).
|
||||
https://github.com/dev-cafe/autocmake/blob/master/modules/git_info/git_info.cmake#L10-L13).
|
||||
|
||||
If ``fetch`` is invoked in ``autocmake.cfg``, then the fetched file is placed
|
||||
If ``fetch`` is invoked in ``autocmake.yml``, then the fetched file is placed
|
||||
under ``downloaded/``. If ``fetch`` is invoked from within a CMake module
|
||||
documentation (see below), then the fetched file is placed into the same
|
||||
directory as the CMake module file which fetches it.
|
||||
@ -199,11 +191,11 @@ Generating setup options
|
||||
------------------------
|
||||
|
||||
Options for the setup script can be generated with the ``docopt``
|
||||
option. As an example, the following ``autocmake.cfg`` snippet will add a
|
||||
option. As an example, the following ``autocmake.yml`` snippet will add a
|
||||
``--something`` flag::
|
||||
|
||||
[my_section]
|
||||
docopt: --something Enable something [default: False].
|
||||
- my_section:
|
||||
- docopt: "--something Enable something [default: False]."
|
||||
|
||||
|
||||
Setting CMake options
|
||||
@ -213,9 +205,9 @@ Configure-time CMake options can be generated with the ``define`` option.
|
||||
Consider the following example which toggles the CMake variable
|
||||
``ENABLE_SOMETHING``::
|
||||
|
||||
[my_section]
|
||||
docopt: --something Enable something [default: False].
|
||||
define: '-DENABLE_SOMETHING={0}'.format(arguments['--something'])
|
||||
- my_section:
|
||||
- docopt: "--something Enable something [default: False]."
|
||||
- define: "'-DENABLE_SOMETHING={0}'.format(arguments['--enable-something'])"
|
||||
|
||||
|
||||
Setting environment variables
|
||||
@ -224,33 +216,23 @@ Setting environment variables
|
||||
You can export environment variables at configure-time using the ``export``
|
||||
option. Consider the following example::
|
||||
|
||||
[cc]
|
||||
docopt: --cc=<CC> C compiler [default: gcc].
|
||||
--extra-cc-flags=<EXTRA_CFLAGS> Extra C compiler flags [default: ''].
|
||||
export: 'CC=%s' % arguments['--cc']
|
||||
define: '-DEXTRA_CFLAGS="%s"' % arguments['--extra-cc-flags']
|
||||
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'])"
|
||||
|
||||
|
||||
Auto-generating configurations from the documentation
|
||||
-----------------------------------------------------
|
||||
|
||||
To avoid a boring re-typing of boilerplate ``autocmake.cfg`` code it is possible
|
||||
To avoid a boring re-typing of boilerplate ``autocmake.yml`` code it is possible
|
||||
to auto-generate configurations from the documentation. This is the case
|
||||
for many core modules which come with own options once you have sourced them.
|
||||
|
||||
The lines following ``# autocmake.cfg configuration::`` are
|
||||
understood by the ``update.py`` script to infer ``autocmake.cfg`` code from the
|
||||
The lines following ``# autocmake.yml configuration::`` are
|
||||
understood by the ``update.py`` script to infer ``autocmake.yml`` code from the
|
||||
documentation. As an example consider
|
||||
https://github.com/coderefinery/autocmake/blob/stable-0.x/modules/cc.cmake#L20-L25.
|
||||
https://github.com/dev-cafe/autocmake/blob/master/modules/cc.cmake#L20-L26.
|
||||
Here, ``update.py`` will infer the configurations for ``docopt``, ``export``,
|
||||
and ``define``.
|
||||
|
||||
|
||||
Overriding documented configurations
|
||||
------------------------------------
|
||||
|
||||
Configurable documented defaults can be achieved using interpolations. See for
|
||||
instance
|
||||
https://github.com/coderefinery/autocmake/blob/stable-0.x/modules/boost/boost.cmake#L33-L36.
|
||||
These can be modified within ``autocmake.cfg`` with a dictionary, e.g.:
|
||||
https://github.com/coderefinery/autocmake/blob/stable-0.x/test/boost_libs/cmake/autocmake.cfg#L9
|
||||
|
@ -3,7 +3,7 @@
|
||||
Customizing CMake modules
|
||||
=========================
|
||||
|
||||
The ``update.py`` script assembles modules listed in ``autocmake.cfg`` into
|
||||
The ``update.py`` script assembles modules listed in ``autocmake.yml`` into
|
||||
``CMakeLists.txt``. Those that are fetched from the web are placed inside
|
||||
``downloaded/``. You have several options to customize downloaded CMake
|
||||
modules:
|
||||
@ -22,7 +22,7 @@ Adapt local copies of CMake modules
|
||||
|
||||
A slightly better solution is to download the CMake modules that you wish you customize
|
||||
to a separate directory (e.g. ``custom/``) and source the customized CMake
|
||||
modules in ``autocmake.cfg``. Alternatively you can serve your custom modules
|
||||
modules in ``autocmake.yml``. Alternatively you can serve your custom modules
|
||||
from your own http server.
|
||||
|
||||
|
||||
@ -34,19 +34,30 @@ the branched customized versions. This will make it easier for you
|
||||
to stay up-to-date with upstream development.
|
||||
|
||||
|
||||
Overriding defaults
|
||||
Overriding settings
|
||||
-------------------
|
||||
|
||||
Some modules use interpolations to set defaults, see for instance
|
||||
https://github.com/coderefinery/autocmake/blob/stable-0.x/modules/boost/boost.cmake#L33-L36.
|
||||
These can be modified within ``autocmake.cfg``, e.g.:
|
||||
https://github.com/coderefinery/autocmake/blob/stable-0.x/test/boost_libs/cmake/autocmake.cfg#L9
|
||||
If you source a module which contains directives such as
|
||||
``define``,
|
||||
``docopt``,
|
||||
``export``, or
|
||||
``fetch``, and you wish to modify those,
|
||||
then you can override these settings in ``autocmake.yml``.
|
||||
Settings in ``autocmake.yml`` take precedence over
|
||||
settings imported by a sourced module.
|
||||
|
||||
As an example consider the Boost module which defines and uses
|
||||
interpolation variables ``major``, ``minor``, ``patch``, and ``components``, see
|
||||
https://github.com/dev-cafe/autocmake/blob/master/modules/boost/boost.cmake#L52-L55.
|
||||
|
||||
The recommended way to customize these is in ``autocmake.yml``, e.g.:
|
||||
https://github.com/dev-cafe/autocmake/blob/master/test/boost_libs/cmake/autocmake.yml#L12-L17.
|
||||
|
||||
|
||||
Create own CMake modules
|
||||
------------------------
|
||||
|
||||
Of course you can also create own modules and source them in ``autocmake.cfg``.
|
||||
Of course you can also create own modules and source them in ``autocmake.yml``.
|
||||
|
||||
|
||||
Contribute customizations to the "standard library"
|
||||
@ -54,5 +65,5 @@ Contribute customizations to the "standard library"
|
||||
|
||||
If you think that your customization will be useful for other users as well,
|
||||
you may consider contributing the changes directly to
|
||||
https://github.com/coderefinery/autocmake/. We very much encourage such
|
||||
https://github.com/dev-cafe/autocmake/. We very much encourage such
|
||||
contributions. But we also strive for generality and portability.
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
|
||||
Example Hello World project
|
||||
Example hello world project
|
||||
===========================
|
||||
|
||||
This is a brief example for the busy and impatient programmer. For a longer
|
||||
tour please see :ref:`autocmake_cfg`.
|
||||
tour please see :ref:`autocmake_yml`.
|
||||
|
||||
We start with a mixed Fortran-C project with the following sources::
|
||||
|
||||
@ -23,40 +23,53 @@ there. This is not necessary for Autocmake but it is a generally good practice::
|
||||
|
||||
Now we create ``cmake/`` and fetch ``update.py``::
|
||||
|
||||
$ mkdir cmake
|
||||
$ cd cmake/
|
||||
$ wget https://raw.githubusercontent.com/coderefinery/autocmake/stable-0.x/update.py
|
||||
$ mkdir cmake # does not have to be called "cmake" - take the name you prefer
|
||||
$ cd cmake
|
||||
$ wget https://github.com/dev-cafe/autocmake/raw/master/update.py
|
||||
$ python update.py --self
|
||||
|
||||
Now from top-level our file tree looks like this::
|
||||
|
||||
.
|
||||
|-- cmake
|
||||
| |-- autocmake.cfg
|
||||
| |-- lib
|
||||
| | |-- config.py
|
||||
| | `-- docopt
|
||||
| | `-- docopt.py
|
||||
| |-- autocmake
|
||||
| | |-- __init__.py
|
||||
| | |-- configure.py
|
||||
| | |-- external
|
||||
| | | |-- __init__.py
|
||||
| | | `-- docopt.py
|
||||
| | |-- extract.py
|
||||
| | |-- generate.py
|
||||
| | |-- interpolate.py
|
||||
| | |-- parse_rst.py
|
||||
| | `-- parse_yaml.py
|
||||
| |-- autocmake.yml
|
||||
| `-- update.py
|
||||
`-- src
|
||||
|-- feature1.F90
|
||||
|-- feature2.c
|
||||
`-- main.F90
|
||||
|
||||
Now we edit ``cmake/autocmake.cfg`` to look like this::
|
||||
Now we edit ``cmake/autocmake.yml`` to look like this::
|
||||
|
||||
[project]
|
||||
name: hello
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[fc]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/fc.cmake
|
||||
min_cmake_version: 3.1
|
||||
|
||||
[cc]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/cc.cmake
|
||||
language:
|
||||
- Fortran
|
||||
- C
|
||||
|
||||
[src]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/src.cmake
|
||||
url_root: https://github.com/dev-cafe/autocmake/raw/master/
|
||||
|
||||
modules:
|
||||
- compilers:
|
||||
- source:
|
||||
- '%(url_root)modules/fc.cmake'
|
||||
- '%(url_root)modules/cc.cmake'
|
||||
- src_support:
|
||||
- source:
|
||||
- '%(url_root)modules/src.cmake'
|
||||
|
||||
What we have specified here is the project name and that we wish Fortran and C
|
||||
support. The ``src.cmake`` module tells CMake to include a ``src/CMakeLists.txt``.
|
||||
@ -76,20 +89,32 @@ Now we have everything to generate ``CMakeLists.txt`` and a setup script::
|
||||
$ cd cmake
|
||||
$ python update ..
|
||||
|
||||
- parsing autocmake.yml
|
||||
- assembling modules: [##############################] (3/3)
|
||||
- generating CMakeLists.txt
|
||||
- generating setup script
|
||||
|
||||
And this is what we got::
|
||||
|
||||
.
|
||||
|-- CMakeLists.txt
|
||||
|-- cmake
|
||||
| |-- autocmake.cfg
|
||||
| |-- autocmake
|
||||
| | |-- __init__.py
|
||||
| | |-- configure.py
|
||||
| | |-- external
|
||||
| | | |-- __init__.py
|
||||
| | | `-- docopt.py
|
||||
| | |-- extract.py
|
||||
| | |-- generate.py
|
||||
| | |-- interpolate.py
|
||||
| | |-- parse_rst.py
|
||||
| | `-- parse_yaml.py
|
||||
| |-- autocmake.yml
|
||||
| |-- downloaded
|
||||
| | |-- autocmake_cc.cmake
|
||||
| | |-- autocmake_fc.cmake
|
||||
| | `-- autocmake_src.cmake
|
||||
| |-- lib
|
||||
| | |-- config.py
|
||||
| | `-- docopt
|
||||
| | `-- docopt.py
|
||||
| `-- update.py
|
||||
|-- setup
|
||||
`-- src
|
||||
@ -100,12 +125,12 @@ And this is what we got::
|
||||
|
||||
Now we are ready to build::
|
||||
|
||||
$ python setup --fc=gfortran --cc=gcc
|
||||
$ ./setup --fc=gfortran --cc=gcc
|
||||
|
||||
FC=gfortran CC=gcc cmake -DEXTRA_FCFLAGS="''" -DENABLE_FC_SUPPORT="ON" -DEXTRA_CFLAGS="''" -DCMAKE_BUILD_TYPE=release -G "Unix Makefiles" None /home/user/example
|
||||
FC=gfortran CC=gcc cmake -DEXTRA_FCFLAGS="''" -DEXTRA_CFLAGS="''" -DCMAKE_BUILD_TYPE=release -G "Unix Makefiles" /home/user/hello
|
||||
|
||||
-- The C compiler identification is GNU 4.9.2
|
||||
-- The CXX compiler identification is GNU 4.9.2
|
||||
-- The C compiler identification is GNU 6.1.1
|
||||
-- The CXX compiler identification is GNU 6.1.1
|
||||
-- Check for working C compiler: /usr/bin/gcc
|
||||
-- Check for working C compiler: /usr/bin/gcc -- works
|
||||
-- Detecting C compiler ABI info
|
||||
@ -118,7 +143,7 @@ Now we are ready to build::
|
||||
-- Detecting CXX compiler ABI info - done
|
||||
-- Detecting CXX compile features
|
||||
-- Detecting CXX compile features - done
|
||||
-- The Fortran compiler identification is GNU 4.9.2
|
||||
-- The Fortran compiler identification is GNU 6.1.1
|
||||
-- Check for working Fortran compiler: /usr/bin/gfortran
|
||||
-- Check for working Fortran compiler: /usr/bin/gfortran -- works
|
||||
-- Detecting Fortran compiler ABI info
|
||||
@ -127,14 +152,14 @@ Now we are ready to build::
|
||||
-- Checking whether /usr/bin/gfortran supports Fortran 90 -- yes
|
||||
-- Configuring done
|
||||
-- Generating done
|
||||
-- Build files have been written to: /home/user/example/build
|
||||
-- Build files have been written to: /home/user/hello/build
|
||||
|
||||
configure step is done
|
||||
now you need to compile the sources:
|
||||
$ cd build
|
||||
$ make
|
||||
|
||||
$ cd build/
|
||||
$ cd build
|
||||
$ make
|
||||
|
||||
Scanning dependencies of target hello.x
|
||||
|
@ -4,6 +4,18 @@ FAQ for developers
|
||||
==================
|
||||
|
||||
|
||||
Which files do I need to edit?
|
||||
------------------------------
|
||||
|
||||
Let us start with files which you normally never edit: ``CMakeLists.txt`` and
|
||||
``setup`` - these are generated based on ``autocmake.yml``. Have a look in
|
||||
``autocmake.yml`` and you will see all CMake files which are assembled into
|
||||
``CMakeLists.txt``. You can edit those files. If you change the order of files
|
||||
listed in ``autocmake.yml`` or if you add or remove CMake modules, then you
|
||||
need to rerun the ``update.py`` script to refresh ``CMakeLists.txt`` and
|
||||
``setup``.
|
||||
|
||||
|
||||
Autocmake does not do feature X - I really need feature X and a setup flag --X
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
@ -19,18 +31,22 @@ naming)::
|
||||
|
||||
cmake/custom/my_feature.cmake
|
||||
|
||||
And include this feature to the main ``CMakeLists.txt`` in ``autocmake.cfg``::
|
||||
And include this feature to the main ``CMakeLists.txt`` in ``autocmake.yml``
|
||||
under the ``modules`` section::
|
||||
|
||||
[my_feature]
|
||||
source: custom/my_feature.cmake
|
||||
modules:
|
||||
- my_feature:
|
||||
- source:
|
||||
- custom/my_feature.cmake
|
||||
|
||||
Now your code is included in the main ``CMakeLists.txt``. Perhaps you also
|
||||
want a setup script flag to toggle the feature::
|
||||
|
||||
[my_feature]
|
||||
source: custom/my_feature.cmake
|
||||
docopt: --my-feature Enable my feature [default: False].
|
||||
define: '-DENABLE_MY_FEATURE={0}'.format(arguments['--my-feature'])
|
||||
- my_feature:
|
||||
- docopt: "--enable-my-feature Enable my feature [default: False]."
|
||||
- define: "'-DENABLE_MY_FEATURE={0}'.format(arguments['--enable-my-feature'])"
|
||||
- source:
|
||||
- custom/my_feature.cmake
|
||||
|
||||
Implement your ideas, test them, and share them. If your module is portable,
|
||||
good code quality, and of general interest, you can suggest it to be part of
|
||||
@ -43,20 +59,33 @@ How can I get a setup flag --X that toggles a CMake variable?
|
||||
The following will add a ``--something`` flag which toggles the CMake variable
|
||||
``ENABLE_SOMETHING``::
|
||||
|
||||
[my_section]
|
||||
docopt: --something Enable something [default: False].
|
||||
define: '-DENABLE_SOMETHING={0}'.format(arguments['--something'])
|
||||
- my_section:
|
||||
- docopt: "--something Enable something [default: False]."
|
||||
- define: "'-DENABLE_SOMETHING={0}'.format(arguments['--enable-something'])"
|
||||
|
||||
|
||||
Can I change the name of the setup script?
|
||||
------------------------------------------
|
||||
|
||||
Yes you can do that in ``autocmake.cfg``. Here we for instance change the name to "configure"::
|
||||
Yes you can do that in ``autocmake.yml``. Here we for instance change the name to "configure":
|
||||
|
||||
.. code-block:: yaml
|
||||
:emphasize-lines: 4
|
||||
|
||||
[project]
|
||||
name: myproject
|
||||
min_cmake_version: 2.8
|
||||
min_cmake_version: 3.1
|
||||
default_build_type: release
|
||||
setup_script: configure
|
||||
language:
|
||||
- Fortran
|
||||
- C
|
||||
- CXX
|
||||
|
||||
|
||||
Can I prevent Autocmake from creating any front-end setup script?
|
||||
-----------------------------------------------------------------
|
||||
|
||||
Yes, with ``setup_script: None``.
|
||||
|
||||
|
||||
In CMake I can do feature X - can I do that also with Autocmake?
|
||||
@ -70,12 +99,13 @@ realized in Autocmake.
|
||||
Should I include and track also files generated by Autocmake in my repository?
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
Yes, you probably want to do that. Autocmake generates a number of files which
|
||||
in principle could be generated at configure- or build-time. However, you
|
||||
probably do not want the users of your code to run any Autocmake scripts like
|
||||
``update.py`` to generate the files they need to build the project. The users
|
||||
of your code will run ``setup`` directly and expect everything to just work
|
||||
(TM).
|
||||
Yes, you probably want to do that. Autocmake downloads and generates a number
|
||||
of files which in principle could be generated at configure- or build-time.
|
||||
However, you probably do not want the users of your code to run any Autocmake
|
||||
scripts like ``update.py`` to generate the files they need to build the
|
||||
project. The users of your code will run ``setup`` directly and typically expect
|
||||
everything to just work (TM). Note also that the users of your code will
|
||||
not need to install the pyyaml package.
|
||||
|
||||
|
||||
The update.py script is overwriting my CMakeLists.txt and setup, isn't this bad?
|
||||
@ -93,7 +123,7 @@ But I need to manually edit and customize CMakeLists.txt and setup every time I
|
||||
-----------------------------------------------------------------------------------------------
|
||||
|
||||
You typically never need to manually edit and customize ``CMakeLists.txt`` and
|
||||
``setup`` directly. You can introduce customizations in ``autocmake.cfg``
|
||||
``setup`` directly. You can introduce customizations in ``autocmake.yml``
|
||||
which get assembled into the front-end scripts.
|
||||
|
||||
|
||||
@ -101,19 +131,21 @@ Where is a good place to list my sources and targets?
|
||||
-----------------------------------------------------
|
||||
|
||||
As mentioned above ``CMakeLists.txt`` is not a good place because this file is
|
||||
generated from ``autocmake.cfg`` and your modifications would become
|
||||
generated from ``autocmake.yml`` and your modifications would become
|
||||
overwritten at some point. A good standard is to organize your sources under
|
||||
``src/`` and to list your sources and targets in ``src/CMakeLists.txt``. You
|
||||
can include the latter in ``autocmake.cfg`` using::
|
||||
can include the latter in ``autocmake.yml`` using::
|
||||
|
||||
[src]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/src.cmake
|
||||
- my_sources:
|
||||
- source:
|
||||
- https://github.com/dev-cafe/autocmake/raw/master/modules/src.cmake
|
||||
|
||||
If you really don't like to do it this way, you can describe your sources and
|
||||
If you really do not like to do it this way, you can describe your sources and
|
||||
targets in a custom module in a local file and include it like this::
|
||||
|
||||
[my_sources]
|
||||
source: custom/my_sources.cmake
|
||||
- my_sources:
|
||||
- source:
|
||||
- custom/my_sources.cmake
|
||||
|
||||
|
||||
How can I do some more sophisticated validation of setup flags?
|
||||
@ -121,7 +153,7 @@ How can I do some more sophisticated validation of setup flags?
|
||||
|
||||
Sometimes you need to do more sophisticated validation and post-processing
|
||||
of setup flags. This can be done by placing a module called ``extensions.py``
|
||||
under ``cmake/`` (or wherever you have ``autocmake.cfg``).
|
||||
under ``cmake/`` (or wherever you have ``autocmake.yml``).
|
||||
This file should implement a function with the following signature:
|
||||
|
||||
.. code-block:: python
|
||||
@ -135,5 +167,37 @@ This file should implement a function with the following signature:
|
||||
return arguments
|
||||
|
||||
In this function you can do any validation and post-processing you like.
|
||||
This function is run after the flags are parsed and before the ``CMake`` command
|
||||
This function is run after the flags are parsed and before the CMake command
|
||||
is run.
|
||||
|
||||
Example for a validation of MPI flags to the setup script:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import sys
|
||||
|
||||
def contains_flag(sys_argv, flag):
|
||||
return (any(x for x in sys_argv if x.startswith('--{0}='.format(flag))))
|
||||
|
||||
def postprocess_args(sys_argv, arguments):
|
||||
|
||||
# if --mpi is selected and compilers are not selected
|
||||
# then compilers default to mpif90, mpicc, and mpicxx
|
||||
if arguments['--mpi']:
|
||||
if not contains_flag(sys_argv, 'fc') and not contains_flag(sys_argv, 'cc') and not contains_flag(sys_argv, 'cxx'):
|
||||
arguments['--fc'] = 'mpif90'
|
||||
arguments['--cc'] = 'mpicc'
|
||||
arguments['--cxx'] = 'mpicxx'
|
||||
|
||||
# if one of the compilers contains "mpi" and --mpi is not selected, it is probably a user error
|
||||
# in this case stop the configuration
|
||||
asking_for_mpi_compiler = False
|
||||
for flag in ['fc', 'cc', 'cxx']:
|
||||
if contains_flag(sys_argv, 'fc'):
|
||||
if 'mpi' in arguments['--fc']:
|
||||
asking_for_mpi_compiler = True
|
||||
if asking_for_mpi_compiler and not arguments['--mpi']:
|
||||
sys.stderr.write('ERROR: you ask for an MPI compiler but have not specified --mpi\n')
|
||||
sys.exit(1)
|
||||
|
||||
return arguments
|
||||
|
34
doc/developers/interpolation.rst
Normal file
34
doc/developers/interpolation.rst
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
.. _interpolation:
|
||||
|
||||
Interpolation
|
||||
=============
|
||||
|
||||
In a custom extension to the YAML specification you can define and reuse
|
||||
variables like this (observe how we interpolate ``url_root``, ``major``,
|
||||
``minor``, ``patch``, and ``components`` in this example)::
|
||||
|
||||
url_root: https://github.com/dev-cafe/autocmake/raw/master/
|
||||
major: 1
|
||||
minor: 48
|
||||
patch: 0
|
||||
components: ""
|
||||
fetch:
|
||||
- "%(url_root)modules/boost/boost_unpack.cmake"
|
||||
- "%(url_root)modules/boost/boost_userconfig.cmake"
|
||||
- "%(url_root)modules/boost/boost_configure.cmake"
|
||||
- "%(url_root)modules/boost/boost_build.cmake"
|
||||
- "%(url_root)modules/boost/boost_install.cmake"
|
||||
- "%(url_root)modules/boost/boost_headers.cmake"
|
||||
- "%(url_root)modules/boost/boost_cleanup.cmake"
|
||||
- "http://sourceforge.net/projects/boost/files/boost/%(major).%(minor).%(patch)/boost_%(major)_%(minor)_%(patch).zip"
|
||||
docopt:
|
||||
- "--boost-headers=<BOOST_INCLUDEDIR> Include directories for Boost [default: '']."
|
||||
- "--boost-libraries=<BOOST_LIBRARYDIR> Library directories for Boost [default: '']."
|
||||
- "--build-boost=<FORCE_CUSTOM_BOOST> Deactivate Boost detection and build on-the-fly <ON/OFF> [default: OFF]."
|
||||
define:
|
||||
- "'-DBOOST_INCLUDEDIR=\"{0}\"'.format(arguments['--boost-headers'])"
|
||||
- "'-DBOOST_LIBRARYDIR=\"{0}\"'.format(arguments['--boost-libraries'])"
|
||||
- "'-DFORCE_CUSTOM_BOOST={0}'.format(arguments['--build-boost'])"
|
||||
- "'-DBOOST_MINIMUM_REQUIRED=\"%(major).%(minor).%(patch)\"'"
|
||||
- "'-DBOOST_COMPONENTS_REQUIRED=\"%(components)\"'"
|
@ -20,11 +20,11 @@ Sometimes you may want to avoid using the latest version of a CMake module and
|
||||
rather fetch an older version, for example with the hash ``abcd123``. To
|
||||
achieve this, instead of::
|
||||
|
||||
[foo]
|
||||
source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/foo.cmake
|
||||
- my_feature:
|
||||
- source: https://github.com/dev-cafe/autocmake/raw/master/modules/foo.cmake
|
||||
|
||||
pin the version to ``abcd123`` (you do not need to specify the full Git hash, a unique
|
||||
beginning will do)::
|
||||
|
||||
[foo]
|
||||
source: https://github.com/coderefinery/autocmake/raw/abcd123/modules/foo.cmake
|
||||
- my_feature:
|
||||
- source: https://github.com/dev-cafe/autocmake/raw/abcd123/modules/foo.cmake
|
||||
|
@ -73,7 +73,7 @@ def main():
|
||||
if s_out != '':
|
||||
output.append('\n\n%s' % file_name)
|
||||
output.append('-'*len(file_name))
|
||||
output.append('`[Source code] <https://github.com/coderefinery/autocmake/blob/stable-0.x/modules/%s>`__' % full_file_name)
|
||||
output.append('`[Source code] <https://github.com/dev-cafe/autocmake/blob/master/modules/%s>`__' % full_file_name)
|
||||
output.append(s_out)
|
||||
|
||||
with open(os.path.join(THIS_DIR, 'module-reference.rst'), 'w') as f:
|
||||
|
@ -7,9 +7,10 @@ Building libraries and executables from sources can be a complex task. Several
|
||||
solutions exist to this problem: GNU Makefiles is the traditional approach.
|
||||
Today, CMake is one of the trendier alternatives which can generate Makefiles
|
||||
starting from a file called ``CMakeLists.txt``.
|
||||
|
||||
Autocmake composes CMake building blocks into a CMake project and generates
|
||||
``CMakeLists.txt`` as well as a setup script, which serves as a front-end to
|
||||
``CMakeLists.txt``. All this is done based on a lightweight ``autocmake.cfg``
|
||||
``CMakeLists.txt``. All this is done based on a lightweight ``autocmake.yml``
|
||||
file::
|
||||
|
||||
python update.py --self
|
||||
@ -19,14 +20,14 @@ file::
|
||||
| and updates the update.py script |
|
||||
| |
|
||||
v Developer maintaining
|
||||
autocmake.cfg Autocmake
|
||||
autocmake.yml Autocmake
|
||||
| |
|
||||
| python update.py .. |
|
||||
| |
|
||||
v v
|
||||
CMakeLists.txt (and setup front-end)
|
||||
| |
|
||||
| python setup |
|
||||
| python setup or ./setup |
|
||||
| which invokes CMake |
|
||||
v User of the code
|
||||
Makefile (or something else) |
|
||||
@ -37,7 +38,7 @@ file::
|
||||
Build/install/test targets
|
||||
|
||||
Our main motivation to create Autocmake as a CMake framework library and
|
||||
CMake module composer was to simplify CMake code transfer between codes. We got
|
||||
CMake module composer is to simplify CMake code transfer between programs. We got
|
||||
tired of manually diffing and copy-pasting boiler-plate CMake code and watching
|
||||
it diverge while maintaining the CMake infrastructure in a growing number of
|
||||
scientific projects which typically have very similar requirements:
|
||||
|
@ -3,9 +3,11 @@
|
||||
Requirements and dependencies
|
||||
=============================
|
||||
|
||||
Autocmake update and test scripts require Python 2.7 or higher. We try to also
|
||||
support Python 3 (tested with Python 3.4). If the script fails with Python 3,
|
||||
consider this a bug and please file an issue.
|
||||
Autocmake update and test scripts require Python 2.7 or higher. We also
|
||||
support Python 3 (we automatically test with 2.7 and 3.5).
|
||||
|
||||
The generated setup script runs with Python >= 2.6 (also tested with Python
|
||||
3.4; probably also lower).
|
||||
3.5).
|
||||
|
||||
To generate ``CMakeLists.txt`` and the ``setup`` script, Autocmake
|
||||
requires the pyyaml package.
|
||||
|
@ -4,22 +4,18 @@ Autocmake
|
||||
=========
|
||||
|
||||
|
||||
General
|
||||
-------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: General
|
||||
|
||||
general/about.rst
|
||||
general/requirements.rst
|
||||
general/help.rst
|
||||
|
||||
|
||||
For developers who use Autocmake
|
||||
--------------------------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: For developers who use Autocmake
|
||||
|
||||
developers/faq.rst
|
||||
developers/bootstrap.rst
|
||||
@ -27,32 +23,27 @@ For developers who use Autocmake
|
||||
developers/example.rst
|
||||
developers/customizing-modules.rst
|
||||
developers/updating-modules.rst
|
||||
developers/interpolation.rst
|
||||
|
||||
|
||||
For users of projects which use Autocmake
|
||||
-----------------------------------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: For users of projects which use Autocmake
|
||||
|
||||
users/faq.rst
|
||||
|
||||
|
||||
For developers/contributors to Autocmake
|
||||
----------------------------------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: For developers/contributors to Autocmake
|
||||
|
||||
contributors/guidelines.rst
|
||||
contributors/testing.rst
|
||||
contributors/doc.rst
|
||||
|
||||
|
||||
Reference
|
||||
---------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Reference
|
||||
|
||||
module-reference.rst
|
||||
|
35
doc/make.bat
Normal file
35
doc/make.bat
Normal file
@ -0,0 +1,35 @@
|
||||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=.
|
||||
set BUILDDIR=_build
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.https://www.sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
@ -49,6 +49,7 @@ Like this::
|
||||
|
||||
$ python setup --cmake-options='"-DTHIS_OPTION=ON -DTHAT_OPTION=OFF"'
|
||||
|
||||
We use two sets of quotes because the shell swallows one set of them
|
||||
before passing the arguments to Python. If you do not use two sets
|
||||
of quotes then the setup command may end up incorrectly saved in `build/setup_command`.
|
||||
We use two sets of quotes because the shell swallows one set of them before
|
||||
passing the arguments to Python. Yeah that's not nice, but nothing we can do
|
||||
about it on the Python side. If you do not use two sets of quotes then the
|
||||
setup command may end up incorrectly saved in `build/setup_command`.
|
||||
|
@ -1,7 +0,0 @@
|
||||
# CMakeLists.txt and setup script will be generated from this file
|
||||
# see: http://autocmake.readthedocs.org/en/latest/developers/configuration.html
|
||||
|
||||
# uncomment the following three lines and set the project name
|
||||
# [project]
|
||||
# name: myproject
|
||||
# min_cmake_version: 2.8
|
7
example/autocmake.yml
Normal file
7
example/autocmake.yml
Normal file
@ -0,0 +1,7 @@
|
||||
# CMakeLists.txt and setup script will be generated from this file
|
||||
# see: http://autocmake.readthedocs.io/en/latest/developers/configuration.html
|
||||
# adapt the following lines and expand
|
||||
|
||||
name: myproject
|
||||
|
||||
min_cmake_version: 3.1
|
BIN
img/autocmake.png
Normal file
BIN
img/autocmake.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
90
img/autocmake.svg
Normal file
90
img/autocmake.svg
Normal file
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="210mm"
|
||||
height="297mm"
|
||||
viewBox="0 0 744.09448819 1052.3622047"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="autocmake.svg">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.49497475"
|
||||
inkscape:cx="255.71429"
|
||||
inkscape:cy="520"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1001"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="27"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<g
|
||||
id="g3411">
|
||||
<rect
|
||||
y="326.18109"
|
||||
x="72.047241"
|
||||
height="400"
|
||||
width="600"
|
||||
id="rect3407"
|
||||
style="fill:#0e4089;fill-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3401"
|
||||
d="m 308.00113,650.73649 c 0,-0.42522 5.41704,-26.15959 12.03787,-57.1875 6.62083,-31.0279 12.97185,-60.80188 14.1134,-66.16438 l 2.07552,-9.75 15.3241,0 15.32411,0 0.19153,66.9375 0.19153,66.93751 -29.62903,0 c -19.84348,0 -29.62903,-0.25534 -29.62903,-0.77313 z m 71.0849,-51.16438 c -0.0908,-28.56562 -0.19938,-58.34999 -0.24129,-66.1875 -0.0419,-7.8375 0.0685,-14.67187 0.24533,-15.1875 0.24153,-0.70421 3.74313,-0.9375 14.07204,-0.9375 7.56277,0 13.90344,0.25313 14.09042,0.5625 0.33225,0.54975 29.7486,132.27474 29.7486,133.21275 0,0.26112 -12.99375,0.47476 -28.875,0.47476 l -28.875,0 -0.1651,-51.93751 z m 33.9151,-88.28869 0,-7.52381 -41.22185,0 -41.22186,0 -0.21564,6.9375 -0.21565,6.9375 -7.875,0 -7.875,0 -0.21565,-6.9375 -0.21564,-6.9375 -9.37402,0 -9.37401,0 0.21466,-7.3125 0.21466,-7.3125 76.5,0 76.5,0 0.21562,6.9375 c 0.1638,5.26821 -0.0165,6.9383 -0.75,6.94082 -5.8743,0.0202 -16.4307,0.58678 -16.74262,0.89865 -0.21953,0.21958 -0.55058,3.56584 -0.7356,7.43614 l -0.33638,7.03689 -8.63805,0.21131 -8.63797,0.2113 0,-7.5238 z m -36.7508,-29.8988 c -1.20169,-0.401 -1.01461,-80.3489 0.1883,-80.46723 2.44805,-0.24081 8.48431,0.23383 8.86144,0.6968 0.23316,0.28623 1.1451,4.40167 2.02652,9.14542 0.88143,4.74375 4.16729,22.41712 7.30192,39.27415 3.13463,16.85703 5.55114,30.79733 5.37002,30.97845 -0.38858,0.38858 -22.65342,0.73772 -23.7482,0.37241 z m -32.72028,-1.8842 c 0.24284,-0.96756 3.82423,-18.4238 7.95865,-38.79165 4.13442,-20.36785 7.70756,-37.63246 7.94032,-38.3658 0.34778,-1.09576 1.28287,-1.33336 5.24765,-1.33336 l 4.82446,0 0,40.125 0,40.125 -13.20631,0 -13.20631,0 0.44154,-1.75919 z"
|
||||
style="fill:#ffffff" />
|
||||
<rect
|
||||
y="482.86636"
|
||||
x="77.082703"
|
||||
height="62.629459"
|
||||
width="589.92908"
|
||||
id="rect3409"
|
||||
style="fill:#0e4089;fill-opacity:1" />
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text3403"
|
||||
y="531.68109"
|
||||
x="192.04724"
|
||||
style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-family:'Pet Me 64';-inkscape-font-specification:'Pet Me 64 Medium';fill:#ffffff"
|
||||
y="531.68109"
|
||||
x="192.04724"
|
||||
id="tspan3405"
|
||||
sodipodi:role="line">Autocmake</tspan></text>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.3 KiB |
13
modules/attach-license-header.py
Normal file
13
modules/attach-license-header.py
Normal file
@ -0,0 +1,13 @@
|
||||
import glob
|
||||
|
||||
license_text = '''# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
'''
|
||||
|
||||
for filename in glob.iglob('**/*.cmake', recursive=True):
|
||||
with open(filename, 'r') as old:
|
||||
text = old.read()
|
||||
with open(filename, 'w') as new:
|
||||
new.write(license_text)
|
||||
new.write(text)
|
@ -1,184 +0,0 @@
|
||||
#.rst:
|
||||
#
|
||||
# Detect, build, and link Boost libraries.
|
||||
# This modules downloads the .zip archive from SourceForge at
|
||||
# Autocmake update time.
|
||||
# Note that the build-up commands are not Windows-compatible!
|
||||
#
|
||||
# Your autocmake.cfg should look like this::
|
||||
#
|
||||
# [boost]
|
||||
# override: {'major': 1, 'minor': 59, 'patch': 0, 'components': 'chrono;timer;system'}
|
||||
# source: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost.cmake
|
||||
#
|
||||
# Cross-dependencies between required components are not checked for.
|
||||
# For example, Boost.Timer depends on Boost.Chrono and Boost.System thus you
|
||||
# should ask explicitly for all three.
|
||||
# If the self-build of Boost components is triggered the `BUILD_CUSTOM_BOOST` variable is set
|
||||
# to `TRUE`. The CMake target `custom_boost` is also added.
|
||||
# You should use these two to ensure the right dependencies between your targets
|
||||
# and the Boost headers/libraries, in case the self-build is triggered.
|
||||
# For example::
|
||||
#
|
||||
# if(BUILD_CUSTOM_BOOST)
|
||||
# add_dependencies(your_target custom_boost)
|
||||
# endif()
|
||||
#
|
||||
# will ensure that `your_target` is built after `custom_boost` if and only if the self-build
|
||||
# of Boost took place. This is an important step to avoid race conditions when building
|
||||
# on multiple processes.
|
||||
#
|
||||
# Dependencies::
|
||||
#
|
||||
# mpi - Only if the Boost.MPI library is a needed component
|
||||
# python_libs - Only if the Boost.Python library is a needed component
|
||||
#
|
||||
# Variables used::
|
||||
#
|
||||
# BOOST_MINIMUM_REQUIRED - Minimum required version of Boost
|
||||
# BOOST_COMPONENTS_REQUIRED - Components (compiled Boost libraries) required
|
||||
# PROJECT_SOURCE_DIR
|
||||
# PROJECT_BINARY_DIR
|
||||
# CMAKE_BUILD_TYPE
|
||||
# MPI_FOUND
|
||||
# BUILD_CUSTOM_BOOST
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
#
|
||||
# major=1
|
||||
# minor=48
|
||||
# patch=0
|
||||
# components=''
|
||||
# fetch: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_unpack.cmake
|
||||
# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_userconfig.cmake
|
||||
# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_configure.cmake
|
||||
# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_build.cmake
|
||||
# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_install.cmake
|
||||
# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_headers.cmake
|
||||
# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/boost/boost_cleanup.cmake
|
||||
# http://sourceforge.net/projects/boost/files/boost/%(major)s.%(minor)s.%(patch)s/boost_%(major)s_%(minor)s_%(patch)s.zip
|
||||
# docopt: --boost-headers=<BOOST_INCLUDEDIR> Include directories for Boost [default: ''].
|
||||
# --boost-libraries=<BOOST_LIBRARYDIR> Library directories for Boost [default: ''].
|
||||
# --build-boost=<FORCE_CUSTOM_BOOST> Deactivate Boost detection and build on-the-fly <ON/OFF> [default: OFF].
|
||||
# define: '-DBOOST_INCLUDEDIR="{0}"'.format(arguments['--boost-headers'])
|
||||
# '-DBOOST_LIBRARYDIR="{0}"'.format(arguments['--boost-libraries'])
|
||||
# '-DFORCE_CUSTOM_BOOST="{0}"'.format(arguments['--build-boost'])
|
||||
# '-DBOOST_MINIMUM_REQUIRED="%(major)s.%(minor)s.%(patch)s"'
|
||||
# '-DBOOST_COMPONENTS_REQUIRED="%(components)s"'
|
||||
|
||||
# FIXME Maintainer should be able to choose between fail (end-user has to satisfy dependency
|
||||
# on its own) and soft-fail (self-build of Boost)
|
||||
# Underscore-separated version number
|
||||
string(REGEX REPLACE "\\." "_" BOOSTVER ${BOOST_MINIMUM_REQUIRED})
|
||||
# Where the Boost .zip archive is located
|
||||
# CMAKE_CURRENT_LIST_DIR is undefined in CMake 2.8.2
|
||||
# see https://public.kitware.com/Bug/print_bug_page.php?bug_id=11675
|
||||
# workaround: create CMAKE_CURRENT_LIST_DIR
|
||||
get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
set(BOOST_ARCHIVE_LOCATION ${CMAKE_CURRENT_LIST_DIR})
|
||||
set(BOOST_ARCHIVE boost_${BOOSTVER}.zip)
|
||||
|
||||
# FIXME These are possibly not always good settings
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
set(Boost_DEBUG OFF)
|
||||
set(Boost_DETAILED_FAILURE_MESSAGE OFF)
|
||||
|
||||
set(BUILD_CUSTOM_BOOST FALSE)
|
||||
if(FORCE_CUSTOM_BOOST)
|
||||
set(BUILD_CUSTOM_BOOST TRUE)
|
||||
message(STATUS "Force automatic build of Boost")
|
||||
# Just to avoid unused variable warning from CMake
|
||||
set(BOOST_INCLUDEDIR "")
|
||||
set(BOOST_LIBRARYDIR "")
|
||||
else()
|
||||
# Read from cache, needed for rebuilds
|
||||
set(BOOST_INCLUDEDIR ${Boost_INCLUDE_DIR})
|
||||
set(BOOST_LIBRARYDIR ${Boost_LIBRARY_DIR})
|
||||
find_package(Boost ${BOOST_MINIMUM_REQUIRED} COMPONENTS "${BOOST_COMPONENTS_REQUIRED}")
|
||||
if(NOT Boost_FOUND)
|
||||
set(BUILD_CUSTOM_BOOST TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_CUSTOM_BOOST)
|
||||
## Preliminary work
|
||||
# 0. Root directory for the custom build
|
||||
set(CUSTOM_BOOST_LOCATION ${PROJECT_BINARY_DIR}/boost)
|
||||
file(MAKE_DIRECTORY ${CUSTOM_BOOST_LOCATION})
|
||||
# 1. Where Boost will be built
|
||||
set(BOOST_BUILD_DIR ${CUSTOM_BOOST_LOCATION}/boost_${BOOSTVER})
|
||||
# 2. Select toolset according to compilers specified by the user
|
||||
set(toolset "")
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
|
||||
set(toolset "intel-linux")
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
||||
set(toolset "clang")
|
||||
else()
|
||||
if(CMAKE_SYSTEM_NAME MATCHES Darwin)
|
||||
set(toolset "darwin")
|
||||
else()
|
||||
set(toolset "gcc")
|
||||
endif()
|
||||
endif()
|
||||
string(TOLOWER ${CMAKE_BUILD_TYPE} type)
|
||||
|
||||
# CMAKE_CURRENT_LIST_DIR is undefined in CMake 2.8.2
|
||||
# see https://public.kitware.com/Bug/print_bug_page.php?bug_id=11675
|
||||
# workaround: create CMAKE_CURRENT_LIST_DIR
|
||||
get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_unpack.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_userconfig.cmake)
|
||||
|
||||
if(NOT "${BOOST_COMPONENTS_REQUIRED}" STREQUAL "")
|
||||
# Non-empty list. Compiled libraries needed
|
||||
# Transform the ;-separated list to a ,-separated list (digested by the Boost build toolchain!)
|
||||
string(REPLACE ";" "," b2_needed_components "${BOOST_COMPONENTS_REQUIRED}")
|
||||
# Replace unit_test_framework (used by CMake's find_package) with test (understood by Boost build toolchain)
|
||||
string(REPLACE "unit_test_framework" "test" b2_needed_components "${b2_needed_components}")
|
||||
set(select_libraries "--with-libraries=${b2_needed_components}")
|
||||
string(REPLACE ";" ", " printout "${BOOST_COMPONENTS_REQUIRED}")
|
||||
message(STATUS " Libraries to be built: ${printout}")
|
||||
message(STATUS " Toolset to be used: ${toolset}")
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_configure.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_build.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_install.cmake)
|
||||
else()
|
||||
# Empty list. Header-only libraries needed
|
||||
# Just unpack to known location
|
||||
message(STATUS " No libraries required, installing headers")
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_headers.cmake)
|
||||
endif()
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_cleanup.cmake)
|
||||
add_custom_target(custom_boost DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.cleanedup)
|
||||
# 4. Set all variables related to Boost that find_package would have set
|
||||
set(Boost_FOUND TRUE)
|
||||
string(REGEX REPLACE "\\." "0" Boost_VERSION ${BOOST_MINIMUM_REQUIRED})
|
||||
math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
|
||||
math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
|
||||
math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
|
||||
set(Boost_LIB_VERSION ${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION})
|
||||
set(Boost_INCLUDE_DIR ${CUSTOM_BOOST_LOCATION}/include CACHE PATH "Boost include directory" FORCE)
|
||||
set(Boost_LIBRARY_DIR ${CUSTOM_BOOST_LOCATION}/lib CACHE PATH "Boost library directory" FORCE)
|
||||
|
||||
foreach(_component ${BOOST_COMPONENTS_REQUIRED})
|
||||
string(TOUPPER ${_component} _COMP)
|
||||
set(Boost_${_COMP}_FOUND TRUE)
|
||||
set(Boost_${_COMP}_LIBRARY libboost_${_component}.a)
|
||||
set(Boost_${_COMP}_LIBRARY_DEBUG ${Boost_LIBRARY_DIR}/${Boost_${_COMP}_LIBRARY} CACHE FILEPATH "Boost ${_component} library (debug)" FORCE)
|
||||
set(Boost_${_COMP}_LIBRARY_RELEASE ${Boost_LIBRARY_DIR}/${Boost_${_COMP}_LIBRARY} CACHE FILEPATH "Boost ${_component} library (release)" FORCE)
|
||||
list(APPEND Boost_LIBRARIES ${Boost_${_COMP}_LIBRARY})
|
||||
endforeach()
|
||||
|
||||
set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
|
||||
set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR})
|
||||
if(CMAKE_SYSTEM_NAME MATCHES Linux)
|
||||
list(APPEND Boost_LIBRARIES rt)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
|
||||
|
||||
link_directories(${Boost_LIBRARY_DIRS})
|
@ -1,10 +0,0 @@
|
||||
# Build Boost
|
||||
# This is not Windows-friendly!
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.built
|
||||
COMMAND ./b2 toolset=${toolset} variant=${type} link=static cxxflags=-fPIC
|
||||
threading=multi --user-config=user-config.jam 1> ${CUSTOM_BOOST_LOCATION}/boost.built.log 2> ${CUSTOM_BOOST_LOCATION}/boost.built.err
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CUSTOM_BOOST_LOCATION}/boost.built
|
||||
WORKING_DIRECTORY ${BOOST_BUILD_DIR}
|
||||
DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.configured
|
||||
COMMENT "Building Boost")
|
@ -1,8 +0,0 @@
|
||||
# Clean-up
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.cleanedup
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${BOOST_BUILD_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CUSTOM_BOOST_LOCATION}/boost.cleanedup
|
||||
WORKING_DIRECTORY ${CUSTOM_BOOST_LOCATION}
|
||||
DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.installed
|
||||
COMMENT "Clean-up Boost")
|
@ -1,12 +0,0 @@
|
||||
# Run bootstrap.sh to configure the build. We will install in ${PROJECT_BINARY_DIR}/boost
|
||||
# This is not Windows-friendly!
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.configured
|
||||
COMMAND ./bootstrap.sh --with-toolset=${toolset}
|
||||
${select_libraries}
|
||||
--with-python=${PYTHON_EXECUTABLE}
|
||||
--prefix=${CUSTOM_BOOST_LOCATION} 1> ${CUSTOM_BOOST_LOCATION}/boost.configured.log 2> ${CUSTOM_BOOST_LOCATION}/boost.configured.err
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CUSTOM_BOOST_LOCATION}/boost.configured
|
||||
WORKING_DIRECTORY ${BOOST_BUILD_DIR}
|
||||
DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.user-config
|
||||
COMMENT "Configuring Boost")
|
@ -1,8 +0,0 @@
|
||||
# Install Boost
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.installed
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${BOOST_BUILD_DIR}/boost ${CUSTOM_BOOST_LOCATION}/include/boost
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CUSTOM_BOOST_LOCATION}/boost.installed
|
||||
WORKING_DIRECTORY ${BOOST_BUILD_DIR}
|
||||
DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.user-config
|
||||
COMMENT "Installing Boost headers")
|
@ -1,10 +0,0 @@
|
||||
# Install Boost
|
||||
# This is not Windows-friendly!
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.installed
|
||||
COMMAND ./b2 install toolset=${toolset} variant=${type} link=static
|
||||
threading=multi --user-config=user-config.jam 1> ${CUSTOM_BOOST_LOCATION}/boost.installed.log 2> ${CUSTOM_BOOST_LOCATION}/boost.installed.err
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CUSTOM_BOOST_LOCATION}/boost.installed
|
||||
WORKING_DIRECTORY ${BOOST_BUILD_DIR}
|
||||
DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.built
|
||||
COMMENT "Installing Boost headers and libs")
|
@ -1,8 +0,0 @@
|
||||
# Unpack Boost
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.unpacked
|
||||
COMMAND ${CMAKE_COMMAND} -E tar xzf ${BOOST_ARCHIVE_LOCATION}/${BOOST_ARCHIVE}
|
||||
COMMAND ${CMAKE_COMMAND} -E touch boost.unpacked
|
||||
DEPENDS ${BOOST_ARCHIVE_LOCATION}/${BOOST_ARCHIVE}
|
||||
WORKING_DIRECTORY ${CUSTOM_BOOST_LOCATION}
|
||||
COMMENT "Unpacking Boost")
|
@ -1,15 +0,0 @@
|
||||
# To get boost to compile MPI we need to append "using mpi ;" to the end of the
|
||||
# user-config.jam file. MPI_SENT will be the command we append
|
||||
set(MPI_SENT "")
|
||||
if(ENABLE_MPI AND MPI_FOUND)
|
||||
set(MPI_SENT "using mpi \;")
|
||||
endif()
|
||||
file(WRITE ${CUSTOM_BOOST_LOCATION}/user-config.jam ${MPI_SENT})
|
||||
# Write user-config.jam
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.user-config
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CUSTOM_BOOST_LOCATION}/user-config.jam ${BOOST_BUILD_DIR}/user-config.jam
|
||||
COMMAND ${CMAKE_COMMAND} -E touch boost.user-config
|
||||
DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.unpacked
|
||||
WORKING_DIRECTORY ${CUSTOM_BOOST_LOCATION}
|
||||
COMMENT "Generating user-config.jam")
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Adds C support.
|
||||
@ -17,14 +20,12 @@
|
||||
#
|
||||
# CFLAGS
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# 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'])
|
||||
|
||||
enable_language(C)
|
||||
# docopt:
|
||||
# - "--cc=<CC> C compiler [default: gcc]."
|
||||
# - "--extra-cc-flags=<EXTRA_CFLAGS> Extra C compiler flags [default: '']."
|
||||
# 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!")
|
||||
@ -35,8 +36,10 @@ if(NOT CMAKE_C_COMPILER_WORKS)
|
||||
endif()
|
||||
|
||||
if(DEFINED EXTRA_CFLAGS)
|
||||
if(NOT EXTRA_CFLAGS STREQUAL "")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(DEFINED ENV{CFLAGS})
|
||||
message(STATUS "CFLAGS is set to '$ENV{CFLAGS}'.")
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Adds ccache support.
|
||||
@ -10,10 +13,10 @@
|
||||
#
|
||||
# CCACHE_FOUND
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --ccache=<USE_CCACHE> Toggle use of ccache <ON/OFF> [default: ON].
|
||||
# define: '-DUSE_CCACHE="{0}"'.format(arguments['--ccache'])
|
||||
# docopt: "--ccache=<USE_CCACHE> Toggle use of ccache <ON/OFF> [default: ON]."
|
||||
# define: "'-DUSE_CCACHE={0}'.format(arguments['--ccache'])"
|
||||
|
||||
if(USE_CCACHE)
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Enables code coverage by appending corresponding compiler flags.
|
||||
@ -8,32 +11,56 @@
|
||||
# CMAKE_C_FLAGS
|
||||
# CMAKE_CXX_FLAGS
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --coverage Enable code coverage [default: False].
|
||||
# define: '-DENABLE_CODE_COVERAGE=%s' % arguments['--coverage']
|
||||
# docopt: "--coverage Enable code coverage [default: OFF]."
|
||||
# define: "'-DENABLE_CODE_COVERAGE={0}'.format(arguments['--coverage'])"
|
||||
|
||||
option(ENABLE_CODE_COVERAGE "Enable code coverage" OFF)
|
||||
|
||||
if(ENABLE_CODE_COVERAGE)
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "debug")
|
||||
message(WARNING "Code coverage analysis results with an optimized (non-Debug) build may be misleading")
|
||||
endif()
|
||||
|
||||
find_program(GCOV_PATH gcov)
|
||||
if(NOT GCOV_PATH)
|
||||
message(FATAL_ERROR "Code coverage analysis requires gcov!")
|
||||
endif()
|
||||
|
||||
if(DEFINED CMAKE_Fortran_COMPILER_ID)
|
||||
if(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
else()
|
||||
message(FATAL_ERROR "Code coverage analysis requires the GNU Fortran compiler!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(DEFINED CMAKE_C_COMPILER_ID)
|
||||
if(CMAKE_C_COMPILER_ID MATCHES GNU)
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "(Apple)?[Cc]lang")
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_LESS 3)
|
||||
message(FATAL_ERROR "Code coverage analysis on Mac OS X requires Clang version 3.0.0 or greater!")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
endif()
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES GNU)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
else()
|
||||
message(FATAL_ERROR "Code coverage analysis requires the GNU C compiler!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(DEFINED CMAKE_CXX_COMPILER_ID)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?[Cc]lang")
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3)
|
||||
message(FATAL_ERROR "Code coverage analysis on Mac OS X requires Clang version 3.0.0 or greater!")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
else()
|
||||
message(FATAL_ERROR "Code coverage analysis requires the GNU C++ compiler!")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
63
modules/custom_color_messages.cmake
Normal file
63
modules/custom_color_messages.cmake
Normal file
@ -0,0 +1,63 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Colorize CMake output.
|
||||
# Code was found on StackOverflow: http://stackoverflow.com/a/19578320
|
||||
#
|
||||
# Usage within CMake code:
|
||||
# message("This is normal")
|
||||
# message("${Red}This is Red${ColourReset}")
|
||||
# message("${Green}This is Green${ColourReset}")
|
||||
# message("${Yellow}This is Yellow${ColourReset}")
|
||||
# message("${Blue}This is Blue${ColourReset}")
|
||||
# message("${Magenta}This is Magenta${ColourReset}")
|
||||
# message("${Cyan}This is Cyan${ColourReset}")
|
||||
# message("${White}This is White${ColourReset}")
|
||||
# message("${BoldRed}This is BoldRed${ColourReset}")
|
||||
# message("${BoldGreen}This is BoldGreen${ColourReset}")
|
||||
# message("${BoldYellow}This is BoldYellow${ColourReset}")
|
||||
# message("${BoldBlue}This is BoldBlue${ColourReset}")
|
||||
# message("${BoldMagenta}This is BoldMagenta${ColourReset}")
|
||||
# message("${BoldCyan}This is BoldCyan${ColourReset}")
|
||||
# message("${BoldWhite}This is BoldWhite\n\n${ColourReset}")
|
||||
#
|
||||
# Has no effect on WIN32.
|
||||
|
||||
if(WIN32)
|
||||
set(ColourReset "")
|
||||
set(ColourBold "")
|
||||
set(Red "")
|
||||
set(Green "")
|
||||
set(Yellow "")
|
||||
set(Blue "")
|
||||
set(Magenta "")
|
||||
set(Cyan "")
|
||||
set(White "")
|
||||
set(BoldRed "")
|
||||
set(BoldGreen "")
|
||||
set(BoldYellow "")
|
||||
set(BoldBlue "")
|
||||
set(BoldMagenta "")
|
||||
set(BoldCyan "")
|
||||
set(BoldWhite "")
|
||||
else()
|
||||
string(ASCII 27 Esc)
|
||||
set(ColourReset "${Esc}[m")
|
||||
set(ColourBold "${Esc}[1m")
|
||||
set(Red "${Esc}[31m")
|
||||
set(Green "${Esc}[32m")
|
||||
set(Yellow "${Esc}[33m")
|
||||
set(Blue "${Esc}[34m")
|
||||
set(Magenta "${Esc}[35m")
|
||||
set(Cyan "${Esc}[36m")
|
||||
set(White "${Esc}[37m")
|
||||
set(BoldRed "${Esc}[1;31m")
|
||||
set(BoldGreen "${Esc}[1;32m")
|
||||
set(BoldYellow "${Esc}[1;33m")
|
||||
set(BoldBlue "${Esc}[1;34m")
|
||||
set(BoldMagenta "${Esc}[1;35m")
|
||||
set(BoldCyan "${Esc}[1;36m")
|
||||
set(BoldWhite "${Esc}[1;37m")
|
||||
endif()
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Adds C++ support.
|
||||
@ -17,26 +20,26 @@
|
||||
#
|
||||
# CXXFLAGS
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# 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'])
|
||||
# docopt:
|
||||
# - "--cxx=<CXX> C++ compiler [default: g++]."
|
||||
# - "--extra-cxx-flags=<EXTRA_CXXFLAGS> Extra C++ compiler flags [default: '']."
|
||||
# define: "'-DCMAKE_CXX_COMPILER={0} -DEXTRA_CXXFLAGS=\"{1}\"'.format(arguments['--cxx'], arguments['--extra-cxx-flags'])"
|
||||
|
||||
enable_language(CXX)
|
||||
|
||||
if(NOT DEFINED CMAKE_C_COMPILER_ID)
|
||||
message(FATAL_ERROR "CMAKE_C_COMPILER_ID variable is not defined!")
|
||||
if(NOT DEFINED CMAKE_CXX_COMPILER_ID)
|
||||
message(FATAL_ERROR "CMAKE_CXX_COMPILER_ID variable is not defined!")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_C_COMPILER_WORKS)
|
||||
message(FATAL_ERROR "CMAKE_C_COMPILER_WORKS is false!")
|
||||
if(NOT CMAKE_CXX_COMPILER_WORKS)
|
||||
message(FATAL_ERROR "CMAKE_CXX_COMPILER_WORKS is false!")
|
||||
endif()
|
||||
|
||||
if(DEFINED EXTRA_CXXFLAGS)
|
||||
if(NOT EXTRA_CXXFLAGS STREQUAL "")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(DEFINED ENV{CXXFLAGS})
|
||||
message(STATUS "CXXFLAGS is set to '$ENV{CXXFLAGS}'.")
|
||||
|
@ -1,12 +1,19 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Sets binary and library output directories to ${PROJECT_BINARY_DIR}/bin
|
||||
# and ${PROJECT_BINARY_DIR}/lib, respectively.
|
||||
# Sets binary and library output directories to ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}
|
||||
# and ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}, respectively.
|
||||
#
|
||||
# Variables modified::
|
||||
#
|
||||
# CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
||||
# CMAKE_ARCHIVE_OUTPUT_DIRECTORY
|
||||
# CMAKE_LIBRARY_OUTPUT_DIRECTORY
|
||||
# CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Add preprocessor definitions (example: --add-definitions="-DTHIS -DTHAT=137").
|
||||
@ -7,10 +10,10 @@
|
||||
#
|
||||
# PREPROCESSOR_DEFINITIONS
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --add-definitions=<STRING> Add preprocesor definitions [default: ''].
|
||||
# define: '-DPREPROCESSOR_DEFINITIONS="%s"' % arguments['--add-definitions']
|
||||
# docopt: "--add-definitions=<STRING> Add preprocesor definitions [default: '']."
|
||||
# define: "'-DPREPROCESSOR_DEFINITIONS=\"{0}\"'.format(arguments['--add-definitions'])"
|
||||
|
||||
if(NOT "${PREPROCESSOR_DEFINITIONS}" STREQUAL "")
|
||||
add_definitions(${PREPROCESSOR_DEFINITIONS})
|
||||
|
26
modules/export_header.cmake
Normal file
26
modules/export_header.cmake
Normal file
@ -0,0 +1,26 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Generates export header for your API using best practices.
|
||||
# This module wraps https://cmake.org/cmake/help/v3.0/module/GenerateExportHeader.html and
|
||||
# it is needed because of these, Very Good Indeed, reasons: https://gcc.gnu.org/wiki/Visibility.
|
||||
# If you are not afraid of jargon, please also have a look at https://www.akkadia.org/drepper/dsohowto.pdf.
|
||||
#
|
||||
# Variables used::
|
||||
#
|
||||
# PROJECT_NAME (defined by project())
|
||||
|
||||
include(GenerateExportHeader)
|
||||
|
||||
generate_export_header(${PROJECT_NAME}
|
||||
BASE_NAME "${PROJECT_NAME}"
|
||||
EXPORT_MACRO_NAME "${PROJECT_NAME}_EXPORT"
|
||||
EXPORT_FILE_NAME "include/${PROJECT_NAME}_export.h"
|
||||
DEPRECATED_MACRO_NAME "${PROJECT_NAME}_DEPRECATED"
|
||||
NO_EXPORT_MACRO_NAME "${PROJECT_NAME}_NO_EXPORT"
|
||||
STATIC_DEFINE "${PROJECT_NAME}_STATIC_DEFINE"
|
||||
NO_DEPRECATED_MACRO_NAME "${PROJECT_NAME}_NO_DEPRECATED"
|
||||
DEFINE_NO_DEPRECATED
|
||||
)
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Adds Fortran support.
|
||||
@ -21,14 +24,12 @@
|
||||
#
|
||||
# FCFLAGS
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# 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'])
|
||||
|
||||
enable_language(Fortran)
|
||||
# docopt:
|
||||
# - "--fc=<FC> Fortran compiler [default: gfortran]."
|
||||
# - "--extra-fc-flags=<EXTRA_FCFLAGS> Extra Fortran compiler flags [default: '']."
|
||||
# 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)
|
||||
@ -42,8 +43,10 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS)
|
||||
endif()
|
||||
|
||||
if(DEFINED EXTRA_FCFLAGS)
|
||||
if(NOT EXTRA_FCFLAGS STREQUAL "")
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${EXTRA_FCFLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(DEFINED ENV{FCFLAGS})
|
||||
message(STATUS "FCFLAGS is set to '$ENV{FCFLAGS}'.")
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Adds optional Fortran support.
|
||||
@ -26,14 +29,15 @@
|
||||
#
|
||||
# FCFLAGS
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --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'])
|
||||
# '-DENABLE_FC_SUPPORT="{0}"'.format(arguments['--fc-support'])
|
||||
# docopt:
|
||||
# - "--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]."
|
||||
# define:
|
||||
# - "'-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)
|
||||
|
||||
@ -52,8 +56,10 @@ if(ENABLE_FC_SUPPORT)
|
||||
endif()
|
||||
|
||||
if(DEFINED EXTRA_FCFLAGS)
|
||||
if(NOT EXTRA_FCFLAGS STREQUAL "")
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${EXTRA_FCFLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(DEFINED ENV{FCFLAGS})
|
||||
message(STATUS "FCFLAGS is set to '$ENV{FCFLAGS}'.")
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
include(CheckIncludeFile)
|
||||
|
||||
function(_find_include_dir _names _hints _result)
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
include(CheckFunctionExists)
|
||||
|
||||
function(_find_library _names _check_function _result)
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Creates git_info.h in the build directory.
|
||||
@ -5,22 +8,67 @@
|
||||
# Git repository version and status information
|
||||
# to the program output.
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# fetch: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/git_info/git_info_sub.cmake
|
||||
# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/git_info/git_info.h.in
|
||||
# url_root: https://github.com/dev-cafe/autocmake/raw/master/
|
||||
# fetch:
|
||||
# - "%(url_root)modules/git_info/git_info.h.in"
|
||||
|
||||
# CMAKE_CURRENT_LIST_DIR is undefined in CMake 2.8.2
|
||||
# see https://public.kitware.com/Bug/print_bug_page.php?bug_id=11675
|
||||
# workaround: create CMAKE_CURRENT_LIST_DIR
|
||||
get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
add_custom_command(
|
||||
OUTPUT ${PROJECT_BINARY_DIR}/git_info.h
|
||||
COMMAND ${CMAKE_COMMAND} -D_target_dir=${PROJECT_BINARY_DIR} -P git_info_sub.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
get_filename_component(_current_dir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
|
||||
function(generate_git_info_header _header_location _header_name)
|
||||
# _header_location: where the Git info header file should be generated
|
||||
# _header_name: the Git info header name, complete with extension (.h, .hpp, .hxx or whatever)
|
||||
find_package(Git)
|
||||
|
||||
set(_git_last_commit_hash "unknown")
|
||||
set(_git_last_commit_author "unknown")
|
||||
set(_git_last_commit_date "unknown")
|
||||
set(_git_branch "unknown")
|
||||
|
||||
if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} --no-pager show -s --pretty=format:%h -n 1
|
||||
OUTPUT_VARIABLE _git_last_commit_hash
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} --no-pager show -s --pretty=format:%aN -n 1
|
||||
OUTPUT_VARIABLE _git_last_commit_author
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} --no-pager show -s --pretty=format:%ad -n 1
|
||||
OUTPUT_VARIABLE _git_last_commit_date
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
||||
OUTPUT_VARIABLE _git_branch
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
${_current_dir}/git_info.h.in
|
||||
${_header_location}/${_header_name}
|
||||
@ONLY
|
||||
)
|
||||
|
||||
unset(_git_last_commit_hash)
|
||||
unset(_git_last_commit_author)
|
||||
unset(_git_last_commit_date)
|
||||
unset(_git_branch)
|
||||
|
||||
add_custom_target(
|
||||
git_info
|
||||
ALL DEPENDS ${PROJECT_BINARY_DIR}/git_info.h
|
||||
ALL DEPENDS ${_header_location}/${_header_name}
|
||||
)
|
||||
endfunction()
|
||||
|
@ -1,64 +0,0 @@
|
||||
#.rst:
|
||||
#
|
||||
# Creates git_info.h in the build directory.
|
||||
# This file can be included in sources to print
|
||||
# Git status information to the program output
|
||||
# for reproducibility reasons.
|
||||
|
||||
find_package(Git)
|
||||
|
||||
set(_git_last_commit_hash "unknown")
|
||||
set(_git_last_commit_author "unknown")
|
||||
set(_git_last_commit_date "unknown")
|
||||
set(_git_branch "unknown")
|
||||
|
||||
if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-list --max-count=1 --abbrev-commit HEAD
|
||||
OUTPUT_VARIABLE _git_last_commit_hash
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
if(_git_last_commit_hash)
|
||||
string(STRIP ${_git_last_commit_hash} _git_last_commit_hash)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} log --max-count=1 HEAD
|
||||
OUTPUT_VARIABLE _git_last_commit
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
if(_git_last_commit)
|
||||
string(REGEX MATCH "Author: +([^<]*) <" temp "${_git_last_commit}")
|
||||
set(_git_last_commit_author ${CMAKE_MATCH_1})
|
||||
string(STRIP ${_git_last_commit_author} _git_last_commit_author)
|
||||
string(REGEX MATCH "Date: +(.+[0-9][0-9][0-9][0-9] [+-][0-9][0-9][0-9][0-9])" temp "${_git_last_commit}")
|
||||
set(_git_last_commit_date ${CMAKE_MATCH_1})
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
||||
OUTPUT_VARIABLE _git_branch
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
if(_git_branch)
|
||||
string(STRIP ${_git_branch} _git_branch)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# CMAKE_CURRENT_LIST_DIR is undefined in CMake 2.8.2
|
||||
# see https://public.kitware.com/Bug/print_bug_page.php?bug_id=11675
|
||||
# workaround: create CMAKE_CURRENT_LIST_DIR
|
||||
get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_LIST_DIR}/git_info.h.in
|
||||
${_target_dir}/git_info.h
|
||||
@ONLY
|
||||
)
|
||||
|
||||
unset(_git_last_commit_hash)
|
||||
unset(_git_last_commit_author)
|
||||
unset(_git_last_commit_date)
|
||||
unset(_git_branch)
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Includes Google Test sources and adds a library "googletest".
|
||||
@ -6,9 +9,9 @@
|
||||
#
|
||||
# GOOGLETEST_ROOT
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# define: '-DGOOGLETEST_ROOT=external/googletest/googletest'
|
||||
# define: "'-DGOOGLETEST_ROOT=external/googletest/googletest'"
|
||||
|
||||
set(GOOGLETEST_ROOT external/googletest/googletest CACHE STRING "Google Test source root")
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Enables 64-bit integer support for Fortran projects.
|
||||
@ -6,10 +9,10 @@
|
||||
#
|
||||
# CMAKE_Fortran_FLAGS
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --int64 Enable 64bit integers [default: False].
|
||||
# define: '-DENABLE_64BIT_INTEGERS=%s' % arguments['--int64']
|
||||
# docopt: "--int64 Enable 64bit integers [default: False]."
|
||||
# define: "'-DENABLE_64BIT_INTEGERS={0}'.format(arguments['--int64'])"
|
||||
|
||||
option(ENABLE_64BIT_INTEGERS "Enable 64-bit integers" OFF)
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Find and link to ACCELERATE.
|
||||
@ -8,18 +11,20 @@
|
||||
# ACCELERATE_LIBRARIES - describe me, uncached
|
||||
# ACCELERATE_INCLUDE_DIR - describe me, uncached
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --accelerate Find and link to ACCELERATE [default: False].
|
||||
# define: '-DENABLE_ACCELERATE=%s' % arguments['--accelerate']
|
||||
# fetch: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/find/find_libraries.cmake
|
||||
# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/find/find_include_files.cmake
|
||||
# url_root: https://github.com/dev-cafe/autocmake/raw/master/
|
||||
# docopt: "--accelerate Find and link to ACCELERATE [default: False]."
|
||||
# define: "'-DENABLE_ACCELERATE={0}'.format(arguments['--accelerate'])"
|
||||
# fetch:
|
||||
# - "%(url_root)modules/find/find_libraries.cmake"
|
||||
# - "%(url_root)modules/find/find_include_files.cmake"
|
||||
|
||||
option(ENABLE_ACCELERATE "Find and link to ACCELERATE" OFF)
|
||||
|
||||
if(ENABLE_ACCELERATE)
|
||||
include(find_libraries)
|
||||
include(find_include_files)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../find/find_libraries.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../find/find_include_files.cmake)
|
||||
|
||||
set(ACCELERATE_FOUND FALSE)
|
||||
set(ACCELERATE_LIBRARIES "NOTFOUND")
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Find and link to ACML.
|
||||
@ -8,10 +11,10 @@
|
||||
# ACML_LIBRARIES
|
||||
# ACML_INCLUDE_DIR
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --acml Find and link to ACML [default: False].
|
||||
# define: '-DENABLE_ACML=%s' % arguments['--acml']
|
||||
# docopt: "--acml Find and link to ACML [default: False]."
|
||||
# define: "'-DENABLE_ACML={0}'.format(arguments['--acml'])"
|
||||
|
||||
option(ENABLE_ACML "Find and link to ACML" OFF)
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Find and link to ATLAS.
|
||||
@ -8,10 +11,10 @@
|
||||
# ATLAS_LIBRARIES
|
||||
# ATLAS_INCLUDE_DIR
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --atlas Find and link to ATLAS [default: False].
|
||||
# define: '-DENABLE_ATLAS=%s' % arguments['--atlas']
|
||||
# docopt: "--atlas Find and link to ATLAS [default: False]."
|
||||
# define: "'-DENABLE_ATLAS={0}'.format(arguments['--atlas'])"
|
||||
|
||||
option(ENABLE_ATLAS "Find and link to ATLAS" OFF)
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Find and link to BLAS.
|
||||
@ -8,10 +11,10 @@
|
||||
# BLAS_LIBRARIES
|
||||
# BLAS_INCLUDE_DIR
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --blas Find and link to BLAS [default: False].
|
||||
# define: '-DENABLE_BLAS=%s' % arguments['--blas']
|
||||
# docopt: "--blas Find and link to BLAS [default: False]."
|
||||
# define: "'-DENABLE_BLAS={0}'.format(arguments['--blas'])"
|
||||
|
||||
option(ENABLE_BLAS "Find and link to BLAS" OFF)
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Find and link to CBLAS.
|
||||
@ -8,18 +11,20 @@
|
||||
# CBLAS_LIBRARIES - describe me, uncached
|
||||
# CBLAS_INCLUDE_DIR - describe me, uncached
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --cblas Find and link to CBLAS [default: False].
|
||||
# define: '-DENABLE_CBLAS=%s' % arguments['--cblas']
|
||||
# fetch: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/find/find_libraries.cmake
|
||||
# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/find/find_include_files.cmake
|
||||
# url_root: https://github.com/dev-cafe/autocmake/raw/master/
|
||||
# docopt: "--cblas Find and link to CBLAS [default: False]."
|
||||
# define: "'-DENABLE_CBLAS={0}'.format(arguments['--cblas'])"
|
||||
# fetch:
|
||||
# - "%(url_root)modules/find/find_libraries.cmake"
|
||||
# - "%(url_root)modules/find/find_include_files.cmake"
|
||||
|
||||
option(ENABLE_CBLAS "Find and link to CBLAS" OFF)
|
||||
|
||||
if(ENABLE_CBLAS)
|
||||
include(find_libraries)
|
||||
include(find_include_files)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../find/find_libraries.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../find/find_include_files.cmake)
|
||||
|
||||
set(CBLAS_FOUND FALSE)
|
||||
set(CBLAS_LIBRARIES "NOTFOUND")
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Find and link to Goto BLAS.
|
||||
@ -8,10 +11,10 @@
|
||||
# GOTO_LIBRARIES
|
||||
# GOTO_INCLUDE_DIR
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --goto Find and link to GOTO [default: False].
|
||||
# define: '-DENABLE_GOTO=%s' % arguments['--goto']
|
||||
# docopt: "--goto Find and link to GOTO [default: False]."
|
||||
# define: "'-DENABLE_GOTO={0}'.format(arguments['--goto'])"
|
||||
|
||||
option(ENABLE_GOTO "Find and link to GOTO" OFF)
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Find and link to LAPACK.
|
||||
@ -8,10 +11,10 @@
|
||||
# LAPACK_LIBRARIES
|
||||
# LAPACK_INCLUDE_DIR
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --lapack Find and link to LAPACK [default: False].
|
||||
# define: '-DENABLE_LAPACK=%s' % arguments['--lapack']
|
||||
# docopt: "--lapack Find and link to LAPACK [default: False]."
|
||||
# define: "'-DENABLE_LAPACK={0}'.format(arguments['--lapack'])"
|
||||
|
||||
option(ENABLE_LAPACK "Find and link to LAPACK" OFF)
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Find and link to LAPACKE.
|
||||
@ -8,18 +11,20 @@
|
||||
# LAPACKE_LIBRARIES - describe me, uncached
|
||||
# LAPACKE_INCLUDE_DIR - describe me, uncached
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --lapacke Find and link to LAPACKE [default: False].
|
||||
# define: '-DENABLE_LAPACKE=%s' % arguments['--lapacke']
|
||||
# fetch: https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/find/find_libraries.cmake
|
||||
# https://github.com/coderefinery/autocmake/raw/stable-0.x/modules/find/find_include_files.cmake
|
||||
# url_root: https://github.com/dev-cafe/autocmake/raw/master/
|
||||
# docopt: "--lapacke Find and link to LAPACKE [default: False]."
|
||||
# define: "'-DENABLE_LAPACKE={0}'.format(arguments['--lapacke'])"
|
||||
# fetch:
|
||||
# - "%(url_root)modules/find/find_libraries.cmake"
|
||||
# - "%(url_root)modules/find/find_include_files.cmake"
|
||||
|
||||
option(ENABLE_LAPACKE "Find and link to LAPACKE" OFF)
|
||||
|
||||
if(ENABLE_LAPACKE)
|
||||
include(find_libraries)
|
||||
include(find_include_files)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/find_libraries.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/find_include_files.cmake)
|
||||
|
||||
set(LAPACKE_FOUND FALSE)
|
||||
set(LAPACKE_LIBRARIES "NOTFOUND")
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Detects and links to BLAS and LAPACK libraries.
|
||||
@ -37,18 +40,65 @@
|
||||
# MKL_ROOT
|
||||
# MKLROOT
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --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].
|
||||
# define: '-DENABLE_BLAS=%s' % arguments['--blas']
|
||||
# '-DENABLE_LAPACK=%s' % arguments['--lapack']
|
||||
# '-DMKL_FLAG=%s' % arguments['--mkl']
|
||||
# '-DMATH_LIB_SEARCH_ORDER="MKL;ESSL;OPENBLAS;ATLAS;ACML;SYSTEM_NATIVE"'
|
||||
# '-DBLAS_LANG=Fortran'
|
||||
# '-DLAPACK_LANG=Fortran'
|
||||
# warning: 'This module is deprecated and will be removed in future versions'
|
||||
# docopt:
|
||||
# - "--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'])"
|
||||
# - "'-DMKL_FLAG={0}'.format(arguments['--mkl'])"
|
||||
# - "'-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(
|
||||
NAME ENABLE_BLAS
|
||||
MESSAGE "Enable BLAS autodetection"
|
||||
DEFAULT "auto"
|
||||
)
|
||||
option_with_default(
|
||||
NAME ENABLE_LAPACK
|
||||
MESSAGE "Enable LAPACK autodetection"
|
||||
DEFAULT "auto"
|
||||
)
|
||||
option_with_default(
|
||||
NAME MKL_FLAG
|
||||
MESSAGE "MKL flag for the Intel compiler and linker. Skips BLAS/LAPACK autodetection"
|
||||
DEFAULT "off"
|
||||
)
|
||||
option_with_default(
|
||||
NAME MATH_LIB_SEARCH_ORDER
|
||||
MESSAGE "Search order for autodetection of math libraries"
|
||||
DEFAULT "MKL;ESSL;OPENBLAS;ATLAS;ACML;SYSTEM_NATIVE"
|
||||
)
|
||||
option_with_default(
|
||||
NAME BLAS_LANG
|
||||
MESSAGE "Linker language for BLAS detection"
|
||||
DEFAULT "Fortran"
|
||||
)
|
||||
option_with_default(
|
||||
NAME LAPACK_LANG
|
||||
MESSAGE "Linker language for LAPACK detection"
|
||||
DEFAULT "Fortran"
|
||||
)
|
||||
option_with_default(
|
||||
NAME SCALAPACK_LIBRARIES
|
||||
MESSAGE "Link line for ScaLAPACK libraries"
|
||||
DEFAULT ""
|
||||
)
|
||||
option_with_default(
|
||||
NAME BLACS_IMPLEMENTATION
|
||||
MESSAGE "Implementation of BLACS for MKL ScaLAPACK"
|
||||
DEFAULT "openmpi"
|
||||
)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# ENABLE_STATIC_LINKING
|
||||
@ -192,7 +242,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})
|
||||
@ -206,6 +256,7 @@ if(ENABLE_SCALAPACK)
|
||||
else()
|
||||
set(_scalapack_lib)
|
||||
set(_blacs_lib)
|
||||
set(BLACS_IMPLEMENTATION)
|
||||
endif()
|
||||
|
||||
# MKL 10.0.1.014
|
||||
@ -427,7 +478,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}")
|
||||
@ -490,12 +541,21 @@ foreach(_service BLAS LAPACK)
|
||||
endforeach()
|
||||
|
||||
# first lapack, then blas as lapack might need blas routine
|
||||
set(MATH_LIBS
|
||||
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}
|
||||
CACHE STRING "Math libraries"
|
||||
)
|
||||
endif()
|
||||
set(MATH_LIBS ${MATH_LIBS} CACHE STRING "Math libraries")
|
||||
|
||||
# further adaptation for the static linking
|
||||
if (ENABLE_STATIC_LINKING)
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Enables MPI support.
|
||||
@ -13,10 +16,10 @@
|
||||
# CMAKE_C_FLAGS
|
||||
# CMAKE_CXX_FLAGS
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --mpi Enable MPI parallelization [default: False].
|
||||
# define: '-DENABLE_MPI=%s' % arguments['--mpi']
|
||||
# docopt: "--mpi Enable MPI parallelization [default: False]."
|
||||
# define: "'-DENABLE_MPI={0}'.format(arguments['--mpi'])"
|
||||
|
||||
option(ENABLE_MPI "Enable MPI parallelization" OFF)
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Enables OpenMP support.
|
||||
@ -13,33 +16,14 @@
|
||||
# CMAKE_C_FLAGS
|
||||
# CMAKE_CXX_FLAGS
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --omp Enable OpenMP parallelization [default: False].
|
||||
# define: '-DENABLE_OPENMP=%s' % arguments['--omp']
|
||||
# docopt: "--omp Enable OpenMP parallelization [default: False]."
|
||||
# define: "'-DENABLE_OPENMP={0}'.format(arguments['--omp'])"
|
||||
|
||||
option(ENABLE_OPENMP "Enable OpenMP parallelization" OFF)
|
||||
|
||||
if(ENABLE_OPENMP)
|
||||
if(DEFINED CMAKE_Fortran_COMPILER_ID)
|
||||
# we do this in a pedestrian way because the Fortran support is relatively recent
|
||||
if(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fopenmp")
|
||||
endif()
|
||||
if(CMAKE_Fortran_COMPILER_ID MATCHES Intel)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -openmp")
|
||||
endif()
|
||||
if(CMAKE_Fortran_COMPILER_ID MATCHES PGI)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp")
|
||||
endif()
|
||||
if(CMAKE_Fortran_COMPILER_ID MATCHES XL)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qsmp")
|
||||
endif()
|
||||
if(CMAKE_Fortran_COMPILER_ID MATCHES Cray)
|
||||
# do nothing in this case
|
||||
endif()
|
||||
set(OPENMP_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
if(NOT OPENMP_FOUND)
|
||||
find_package(OpenMP)
|
||||
@ -53,5 +37,35 @@ if(ENABLE_OPENMP)
|
||||
if(DEFINED CMAKE_CXX_COMPILER_ID)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
endif()
|
||||
if(DEFINED CMAKE_Fortran_COMPILER_ID)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# this is only needed for CMake below 3.5
|
||||
if(DEFINED CMAKE_Fortran_COMPILER_ID AND NOT DEFINED OpenMP_Fortran_FLAGS)
|
||||
# we do this in a pedestrian way because the Fortran support is relatively recent
|
||||
if(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fopenmp")
|
||||
endif()
|
||||
if(CMAKE_Fortran_COMPILER_ID MATCHES Intel)
|
||||
if(WIN32)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Qopenmp")
|
||||
elseif("${CMAKE_Fortran_COMPILER_VERSION}" VERSION_LESS "15.0.0.20140528")
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -openmp")
|
||||
else()
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qopenmp")
|
||||
endif()
|
||||
endif()
|
||||
if(CMAKE_Fortran_COMPILER_ID MATCHES PGI)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp")
|
||||
endif()
|
||||
if(CMAKE_Fortran_COMPILER_ID MATCHES XL)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qsmp=omp")
|
||||
endif()
|
||||
if(CMAKE_Fortran_COMPILER_ID MATCHES Cray)
|
||||
# do nothing in this case
|
||||
endif()
|
||||
set(OPENMP_FOUND TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
33
modules/profile.cmake
Normal file
33
modules/profile.cmake
Normal file
@ -0,0 +1,33 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Enable profiling by appending corresponding compiler flags.
|
||||
#
|
||||
# Variables modified (provided the corresponding language is enabled)::
|
||||
#
|
||||
# CMAKE_Fortran_FLAGS
|
||||
# CMAKE_C_FLAGS
|
||||
# CMAKE_CXX_FLAGS
|
||||
#
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: "--profile Enable profiling [default: False]"
|
||||
# define: "'-DENABLE_PROFILING={0}'.format(arguments['--profile'])"
|
||||
|
||||
option(ENABLE_PROFILING "Enable profiling" OFF)
|
||||
|
||||
message(STATUS "Enable profiling: ${ENABLE_PROFILING}")
|
||||
|
||||
if(ENABLE_PROFILING)
|
||||
if(DEFINED CMAKE_Fortran_COMPILER_ID)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -pg")
|
||||
endif()
|
||||
if(DEFINED CMAKE_C_COMPILER_ID)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -pg")
|
||||
endif()
|
||||
if(DEFINED CMAKE_CXX_COMPILER_ID)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -pg")
|
||||
endif()
|
||||
endif()
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Detects Python interpreter.
|
||||
@ -15,10 +18,10 @@
|
||||
# PYTHON_VERSION_MINOR - Python minor version found e.g. 5
|
||||
# PYTHON_VERSION_PATCH - Python patch version found e.g. 2
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: --python=<PYTHON_INTERPRETER> The Python interpreter (development version) to use. [default: ''].
|
||||
# define: '-DPYTHON_INTERPRETER="%s"' % arguments['--python']
|
||||
# docopt: "--python=<PYTHON_INTERPRETER> The Python interpreter (development version) to use. [default: '']."
|
||||
# define: "'-DPYTHON_INTERPRETER=\"{0}\"'.format(arguments['--python'])"
|
||||
|
||||
if("${PYTHON_INTERPRETER}" STREQUAL "")
|
||||
find_package(PythonInterp REQUIRED)
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Detects Python libraries and headers.
|
||||
@ -75,12 +78,9 @@ find_package_handle_standard_args(PythonLibs
|
||||
PYTHON_EXECUTABLE)
|
||||
|
||||
if(NOT PYTHONLIBS_FOUND)
|
||||
message(FATAL_ERROR "Could NOT find PythonLibs")
|
||||
message(FATAL_ERROR "Could NOT find PythonLibs - did you install the python-dev package?")
|
||||
endif()
|
||||
|
||||
# Hook-up script variables to cache variables
|
||||
set(PYTHON_LIBRARIES ${PYTHON_LIBRARY})
|
||||
set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR})
|
||||
|
||||
include_directories(SYSTEM ${PYTHON_INCLUDE_DIRS})
|
||||
link_directories(${PYTHON_LIBRARIES})
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Provides safeguards against in-source builds and bad build types.
|
||||
@ -17,6 +20,7 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" cmake_build_type_toupper)
|
||||
|
||||
if(NOT cmake_build_type_tolower STREQUAL "debug" AND
|
||||
NOT cmake_build_type_tolower STREQUAL "release" AND
|
||||
NOT cmake_build_type_tolower STREQUAL "minsizerel" AND
|
||||
NOT cmake_build_type_tolower STREQUAL "relwithdebinfo")
|
||||
message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". Allowed values are Debug, Release, RelWithDebInfo (case-insensitive).")
|
||||
message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". Allowed values are Debug, Release, RelWithDebInfo, and MinSizeRel (case-insensitive).")
|
||||
endif()
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Take care of updating the cache for fresh configurations.
|
||||
|
30
modules/sccache.cmake
Normal file
30
modules/sccache.cmake
Normal file
@ -0,0 +1,30 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Adds sccache support.
|
||||
# The user should export the appropriate environment variables to
|
||||
# tweak the program's behaviour, as described in its manpage.
|
||||
# Notice that some additional compiler flags might be needed in order
|
||||
# to avoid unnecessary warnings.
|
||||
#
|
||||
# Variables defined::
|
||||
#
|
||||
# SCCACHE_FOUND
|
||||
#
|
||||
# autocmake.yml configuration::
|
||||
#
|
||||
# docopt: "--sccache=<USE_SCCACHE> Toggle use of sccache <ON/OFF> [default: ON]."
|
||||
# define: "'-DUSE_SCCACHE={0}'.format(arguments['--sccache'])"
|
||||
|
||||
if(USE_SCCACHE)
|
||||
find_program(SCCACHE_FOUND sccache)
|
||||
if(SCCACHE_FOUND)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE sccache)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK sccache)
|
||||
message(STATUS "Compiling with sccache")
|
||||
else()
|
||||
message(STATUS "sccache not available")
|
||||
endif()
|
||||
endif()
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Adds ${PROJECT_SOURCE_DIR}/src as subdirectory containing CMakeLists.txt.
|
||||
|
@ -1,3 +1,6 @@
|
||||
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
|
||||
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
|
||||
|
||||
#.rst:
|
||||
#
|
||||
# Determine program version from file "VERSION" (example: "14.1")
|
||||
|
@ -1,2 +1,4 @@
|
||||
pep8
|
||||
pycodestyle
|
||||
pytest
|
||||
pyyaml
|
||||
sphinx
|
@ -1,16 +0,0 @@
|
||||
[project]
|
||||
name: example
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
||||
[boost]
|
||||
override: {'major': 1, 'minor': 48, 'patch': 0}
|
||||
source: ../../../modules/boost/boost.cmake
|
||||
|
||||
[default_build_paths]
|
||||
source: ../../../modules/default_build_paths.cmake
|
||||
|
||||
[src]
|
||||
source: ../../../modules/src.cmake
|
@ -1 +0,0 @@
|
||||
add_executable(example example.cpp)
|
@ -1,17 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Boost version: "
|
||||
<< BOOST_VERSION / 100000
|
||||
<< "."
|
||||
<< BOOST_VERSION / 100 % 1000
|
||||
<< "."
|
||||
<< BOOST_VERSION % 100
|
||||
<< std::endl;
|
||||
|
||||
std::cout << "PASSED" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
[project]
|
||||
name: example
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
||||
[mpi]
|
||||
source: ../../../modules/mpi.cmake
|
||||
|
||||
[python_interpreter]
|
||||
source: ../../../modules/python_interpreter.cmake
|
||||
|
||||
[python_libs]
|
||||
source: ../../../modules/python_libs.cmake
|
||||
|
||||
[boost]
|
||||
override: {'major': 1, 'minor': 59, 'patch': 0, 'components': 'mpi;serialization;python'}
|
||||
source: ../../../modules/boost/boost.cmake
|
||||
|
||||
[default_build_paths]
|
||||
source: ../../../modules/default_build_paths.cmake
|
||||
|
||||
[src]
|
||||
source: ../../../modules/src.cmake
|
@ -1,8 +0,0 @@
|
||||
add_executable(example example.cpp)
|
||||
|
||||
if(BUILD_CUSTOM_BOOST)
|
||||
add_dependencies(example custom_boost)
|
||||
endif()
|
||||
|
||||
target_link_libraries(example ${Boost_MPI_LIBRARY} ${Boost_SERIALIZATION_LIBRARY} ${MPI_CXX_LIBRARIES}
|
||||
${Boost_PYTHON_LIBRARY} ${PYTHON_LIBRARIES})
|
@ -1,45 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/mpi/environment.hpp>
|
||||
#include <boost/mpi/communicator.hpp>
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::python;
|
||||
namespace mpi = boost::mpi;
|
||||
|
||||
std::cout << "Boost version: "
|
||||
<< BOOST_VERSION / 100000
|
||||
<< "."
|
||||
<< BOOST_VERSION / 100 % 1000
|
||||
<< "."
|
||||
<< BOOST_VERSION % 100
|
||||
<< std::endl;
|
||||
|
||||
try {
|
||||
Py_Initialize();
|
||||
|
||||
object main_module((
|
||||
handle<>(borrowed(PyImport_AddModule("__main__")))));
|
||||
|
||||
object main_namespace = main_module.attr("__dict__");
|
||||
|
||||
handle<> ignored(( PyRun_String( "print \"Hello, World\"",
|
||||
Py_file_input,
|
||||
main_namespace.ptr(),
|
||||
main_namespace.ptr() ) ));
|
||||
} catch( error_already_set ) {
|
||||
PyErr_Print();
|
||||
}
|
||||
|
||||
mpi::environment env;
|
||||
mpi::communicator world;
|
||||
std::cout << "I am process " << world.rank() << " of " << world.size()
|
||||
<< "." << std::endl;
|
||||
|
||||
std::cout << "PASSED" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
[project]
|
||||
name: example
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
||||
[default_build_paths]
|
||||
source: ../../../modules/default_build_paths.cmake
|
||||
|
||||
[src]
|
||||
source: ../../../modules/src.cmake
|
11
test/cxx/cmake/autocmake.yml
Normal file
11
test/cxx/cmake/autocmake.yml
Normal file
@ -0,0 +1,11 @@
|
||||
name: example
|
||||
min_cmake_version: 3.1
|
||||
language: CXX
|
||||
default_build_type: debug
|
||||
modules:
|
||||
- cxx:
|
||||
- source: ../../../modules/cxx.cmake
|
||||
- default_build_paths:
|
||||
- source: ../../../modules/default_build_paths.cmake
|
||||
- src:
|
||||
- source: ../../../modules/src.cmake
|
@ -1,15 +0,0 @@
|
||||
[project]
|
||||
name: example
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
||||
[math]
|
||||
source: ../../../modules/math/accelerate.cmake
|
||||
|
||||
[default_build_paths]
|
||||
source: ../../../modules/default_build_paths.cmake
|
||||
|
||||
[src]
|
||||
source: ../../../modules/src.cmake
|
15
test/cxx_accelerate/cmake/autocmake.yml
Normal file
15
test/cxx_accelerate/cmake/autocmake.yml
Normal file
@ -0,0 +1,15 @@
|
||||
name: example
|
||||
min_cmake_version: 3.1
|
||||
language:
|
||||
- CXX
|
||||
- C
|
||||
default_build_type: debug
|
||||
modules:
|
||||
- cxx:
|
||||
- source: ../../../modules/cxx.cmake
|
||||
- math:
|
||||
- source: ../../../modules/math/accelerate.cmake
|
||||
- default_build_paths:
|
||||
- source: ../../../modules/default_build_paths.cmake
|
||||
- src:
|
||||
- source: ../../../modules/src.cmake
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user