diff --git a/.gitattributes b/.gitattributes index 74a034de3eb..36fa34e62cd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3307,6 +3307,7 @@ Scripts/developer_scripts/remove_package_files_from_build_tree_impl.rb -text Scripts/developer_scripts/test_testsuite_submission -text Scripts/scripts/cgal_create_cmake_script -text Scripts/scripts/cgal_create_cmake_script_with_includes -text +Scripts/scripts/cgal_create_cmake_script_with_options -text SearchStructures/doc_tex/SearchStructures/d-range.eps -text svneol=unset#application/postscript SearchStructures/doc_tex/SearchStructures/d-range.gif -text svneol=unset#image/gif SearchStructures/doc_tex/SearchStructures/d-range.pdf -text svneol=unset#application/pdf diff --git a/Scripts/scripts/cgal_create_cmake_script_with_options b/Scripts/scripts/cgal_create_cmake_script_with_options new file mode 100755 index 00000000000..df709dad0cf --- /dev/null +++ b/Scripts/scripts/cgal_create_cmake_script_with_options @@ -0,0 +1,330 @@ +#!/bin/sh + +# Copyright (c) 1999,2000,2002-2007,2009 +# Utrecht University (The Netherlands), +# ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany), +# INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg +# (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria), +# and Tel-Aviv University (Israel). All rights reserved. +# +# This file is part of CGAL (www.cgal.org); you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; version 2.1 of the License. +# See the file LICENSE.LGPL distributed with CGAL. +# +# Licensees holding a valid commercial license may use this file in +# accordance with the commercial license agreement provided with the software. +# +# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +# +# $URL: svn+ssh://fcacciola@scm.gforge.inria.fr/svn/cgal/trunk/Scripts/scripts/cgal_create_makefile $ +# $Id: cgal_create_makefile 36976 2007-03-09 22:53:24Z reichel $ +# +# Author(s) : various + +# This script creates a CGAL cmake script with entries for all .C and .cpp +# files in the current directory. +# +# Usage: cgal_create_cmake_script_with_includes -tTYPE +# +# echo " TYPE can be any of DEMO, EXAMPLE or TEST.. any other value is ignored" + +#VERSION=2.0 + +create_cmake_script_with_includes() +{ + +qt3='n' +qt4='n' + +# TODO distinguish Qt3 + Qt4 demos! + +if [ -e "$INCLUDE_FILE" ]; then + + OLDIFS="$IFS" + IFS=$'\n' + for LINE in `cat $INCLUDE_FILE`; do + next_package=`echo $LINE | grep -v "#" | grep PACKAGE` + next_package=${next_package/PACKAGE /} + if [ -d "$next_package/include/CGAL" ]; then + PACKAGES=$PACKAGES" "$next_package + fi + + next_dir=`echo $LINE | grep -v "#" | grep DIRECTORY` + next_dir=${next_dir/DIRECTORY /} + IFS="$OLDIFS" + for package in `ls $next_dir`; do + next_package="$next_dir/$package" + #echo $next_package + if [ -d "$next_package/include/CGAL" ]; then + PACKAGES=$PACKAGES" "$next_package + fi + done; + IFS=$'\n' + done + IFS="$OLDIFS" +fi; + +# print makefile header + cat </dev/null | sort` ; do + all="$all $file" + done + cat <<'EOF' +find_package(CGAL QUIET COMPONENTS Core Qt3 ) + +if ( CGAL_FOUND ) + +EOF + if [ -d ../../include ] ; then + echo ' include_directories (BEFORE ../../include)' + echo + fi + if [ -d ../include ] ; then + echo ' include_directories (BEFORE ../include)' + echo + fi + if [ -d include ] ; then + echo ' include_directories (BEFORE include)' + echo + fi + + for package in $PACKAGES; do + echo " include_directories($package/include/)"; + done + + echo + + OLDIFS="$IFS" + IFS=',' + for boost_component in $BOOST_COMPONENTS; do + BOOST_COMPONENT=`echo $boost_component | tr '[:lower:]' '[:upper:]'` + echo " find_package(Boost REQUIRED $boost_component)" + echo " link_libraries(\${BOOST_${BOOST_COMPONENT}_LIBRARY})" + done + IFS=$OLDIFS + + cat <<'EOF' + + include( ${CGAL_USE_FILE} ) + + find_package(Qt3-patched QUIET ) + # FindQt3-patched.cmake is FindQt3.cmake patched by CGAL developers, so + # that it can be used together with FindQt4: all its variables are prefixed + # by "QT3_" instead of "QT_". + + if(CGAL_Qt3_FOUND AND QT3_FOUND) + + include( Qt3Macros-patched ) +EOF + echo " qt3_automoc( ${all} )" + cat<<'EOF' + + # Make sure the compiler can find generated .moc files + include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) + + include_directories( ${QT3_INCLUDE_DIR} ) + +EOF + + cat </dev/null | sort` ; do + # Create an executable for each cpp that contains a function "main()" + BASE=`basename $file .C` + BASE=`basename $BASE .cpp` + egrep '\bmain[ \t]*\(' $file >/dev/null 2>&1 + if [ $? -eq 0 ]; then + echo " create_single_source_cgal_program( \"$file\" )" + fi + done + + cat <<'EOF' + +else() + + message(STATUS "This program requires the CGAL library, and will not be compiled.") + +endif() +EOF + + fi + + echo + +} + + +usage() +{ + echo "Usage: `basename $0` [-s [SOURCE]] [-c cgal-component1,cgal-component2,...] [-i include_file='$HOME/.cgal_cmake_includes'] [-t type] [-b boost-component1,boost-component2,...] [-h]" >&2 + echo >&2 + echo " -s [SOURCE] If there is parameter is given the script will create one single executable with all sources, based on the given SOURCE, it creates one executable for each main'ed source." >&2 + echo " cgal_componentX - must be a valid cgal component, examples are 'Core','imageIO','PDB','Qt','Qt4' ('benchmark')." >&2 + echo " include_file - file with PACKAGE or DIRECTORY directives" >&2 + echo " type - must be any of example, demo or test. Default is example." >&2 + echo " boost_componentX - must be a valid boost component, like 'filesystem', 'program_options'." >&2 + echo >&2 +} + +CGAL_COMPONENTS="" +TYPE="example" +INCLUDE_FILE="${HOME}/.cgal_cmake_includes" +BOOST_COMPONENTS="" +SINGLE_SOURCE='n' +SOURCE="" + +# parse command line arguments +while getopts c:b:i:t:s:hv OPT; do + case "$OPT" in + c) CGAL_COMPONENTS=$OPTARG + ;; + i) INCLUDE_FILE=$OPTARG + if [ ! -e "$INCLUDE_FILE" ]; then + echo "File $INCLUDE_FILE does not exist." >&2 + exit 1 + fi + ;; + b) BOOST_COMPONENTS=$OPTARG + ;; + t) TYPE=$OPTARG + ;; + s) SINGLE_SOURCE='y' + SOURCE=$OPTARG + ;; + + h) usage + exit 0 + ;; + v) echo "`basename $0` version 0.1" + exit 0 + ;; + \?) # getopts issues an error message + usage + exit 1 + ;; + esac +done + +shift `expr $OPTIND - 1` + +#echo "TYPE: $TYPE" +#echo "FILE: $INCLUDE_FILE" +#echo "BOOST_COMPONENTS: $BOOST_COMPONENTS" +#echo "CGAL_COMPONENTS: $CGAL_COMPONENTS" +#echo "SINGLE_SOURCE: $SINGLE_SOURCE" +#echo "SOURCE: $SOURCE" + +if [ "${TYPE}" = "example" -o "${TYPE}" = "demo" -o "${TYPE}" = "test" ]; then + ok='y' +fi + +if [ -z "$ok" ]; then + echo "Invalid type: '${TYPE}'. Valid values are 'example', 'demo' or 'test'" + exit 1 +fi + +OUTPUTFILE=CMakeLists.txt +PROJECT=`basename $PWD` + +if [ -f ${OUTPUTFILE} ] ; then + echo "moving $OUTPUTFILE to ${OUTPUTFILE}.bak ..." + mv -f $OUTPUTFILE ${OUTPUTFILE}.bak +fi + +create_cmake_script_with_includes | tee $OUTPUTFILE + +echo "created $OUTPUTFILE in $PWD ..."