Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 19d1b2a990
Fetching contributors…

Cannot retrieve contributors at this time

executable file 76 lines (64 sloc) 2.892 kb
#!/bin/bash
# Author: Sean Fisk <sean@seanfisk.com>
# URL: https://github.com/seanfisk/cmake-flymake
#
# Copyright (C) 2011 by Sean Fisk <sean@seanfisk.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# generateMakefiles.sh by Nil Geisweiller
#
# That script generates Makefile.flymake (or rather Makefile for now)
# all over the CMake project.
# It takes 1 argument, the name of the building dir
#readonly MAKEFILE_NAME=Makefile.flymake
readonly MAKEFILE_NAME=Makefile
set -o nounset
set -o errexit
if [[ $# -ne 1 ]]; then
echo "Usage: $0 BUILD_DIR_NAME" 1>&2
exit 1
fi
build_dir_name=$1
# for each CMakeLists.txt found from the current directory
# create the associated Makefile.flymake (or rather Makefile for now).
# read : -r : backslash doesn't escape, -d : delims
find . -name CMakeLists.txt -print0 | while read -r -d $'\0' cmakelists_path; do
# get some paths
rel_makefile_dir=$(dirname "$cmakelists_path")
makefile_path=$rel_makefile_dir/$MAKEFILE_NAME
# begin writing to Makefile
echo "# Automatically generated by ${0}, you may remove it using \`cmake-flymake-remove' as you please" > "$makefile_path"
# parse out the executables and include their `flags.make' files in our Makefile
shopt -s nocasematch
while read -r line; do
if [[ $line =~ add_executable\(([[:alnum:][:punct:]]+) ]]; then
executable_name=${BASH_REMATCH[1]}
flags_make_file=$(readlink --canonicalize "$PWD/$build_dir_name/$rel_makefile_dir/CMakeFiles/$executable_name.dir/flags.make")
echo "include $flags_make_file" >> $makefile_path
fi
done < $cmakelists_path
shopt -u nocasematch
# write the rest of the Makefile
(cat <<EOF
.PHONY: check-syntax
check-syntax:
\${CXX} -o /dev/null \${CXX_FLAGS} \${CXX_DEFINES} -S \${CHK_SOURCES}
EOF
) >> $makefile_path
done
Jump to Line
Something went wrong with that request. Please try again.