File: cgal_create_cmake_script

package info (click to toggle)
cgal 3.6.1-2
  • links: PTS
  • area: non-free
  • in suites: squeeze
  • size: 62,184 kB
  • ctags: 95,782
  • sloc: cpp: 453,758; ansic: 96,821; sh: 226; makefile: 120; xml: 2
file content (209 lines) | stat: -rwxr-xr-x 5,154 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/sh

# Copyright (c) 1999,2000,2002-2007
# 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 -tTYPE
#
#  echo "  TYPE can be any of DEMO, EXAMPLE or TEST.. any other value is ignored"

#VERSION=2.0

create_cmake_script()
{
  # print makefile header
  cat <<EOF
# Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application.


project( ${PROJECT}_${TYPE} )
EOF
  cat <<'EOF'

CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5)

set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
 
if ( COMMAND cmake_policy )
  cmake_policy( SET CMP0003 NEW )  
endif()
 
EOF

  if [ "${TYPE}" = "demo" ] ; then
    target_name="${PROJECT}_${TYPE}"
    
    for file in `ls *.C *.cpp 2>/dev/null | sort` ; do
      all="$all $file"
    done
    cat <<'EOF'  
find_package(CGAL QUIET COMPONENTS Core Qt3 )

if ( CGAL_FOUND )

  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
    
    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
    cat <<EOF
    add_executable  (${target_name} ${all})
  
    add_to_cached_list( CGAL_EXECUTABLE_TARGETS ${target_name} )
  
  
    # Link the executable to CGAL and third-party libraries
    target_link_libraries(${target_name} \${QT3_LIBRARIES} \${CGAL_LIBRARIES} \${CGAL_3RD_PARTY_LIBRARIES} )
  else()
  
    message(STATUS "NOTICE: This demo requires Qt3 and the CGAL Qt3 library, and will not be compiled.")
  
  endif()
  
else()
  
    message(STATUS "NOTICE: This demo requires the CGAL library, and will not be compiled.")
  
endif()
EOF
    
  else
  
    cat <<'EOF'
find_package(CGAL QUIET COMPONENTS Core )

if ( CGAL_FOUND )

  include( ${CGAL_USE_FILE} )

  include( CGAL_CreateSingleSourceCGALProgram )

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 file in `ls *.C *.cpp 2>/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: cgal_create_cmake_script [TYPE]"
  echo
  echo "  TYPE must be any of example, demo or test."
  echo "  Default is example."
  echo 
}


case $# in
  0) TYPE="example";;
  1) TYPE=$1;;
  *) usage
     exit 1
esac



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 > $OUTPUTFILE
echo "created $OUTPUTFILE in $PWD ..."