Switched to CMake
authorDmitriy Morozov <morozov@cs.duke.edu>
Tue, 30 Jan 2007 13:51:04 -0500
changeset 15 ef3bf83302ca
parent 14 d68c28a18f37
child 16 626e2b875d21
Switched to CMake
.hgignore
CMakeLists.txt
FindCGAL.Makefile
README
SConstruct
examples/CMakeLists.txt
examples/SConscript
examples/alphashapes/CMakeLists.txt
examples/alphashapes/SConscript
examples/grid/CMakeLists.txt
examples/grid/SConscript
examples/triangle/CMakeLists.txt
examples/triangle/SConscript
sconstools/doxygen.py
src/SConscript
tests/CMakeLists.txt
tests/SConscript
--- a/.hgignore	Wed Jan 24 17:50:45 2007 -0500
+++ b/.hgignore	Tue Jan 30 13:51:04 2007 -0500
@@ -1,5 +1,5 @@
 syntax: glob
 
 docs
-.sconsign.dblite
 aux
+build
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CMakeLists.txt	Tue Jan 30 13:51:04 2007 -0500
@@ -0,0 +1,88 @@
+project						(Dionysus)
+
+option						(debug				"Build Dionysus with debugging on" 		OFF)
+option						(counters			"Build Dionysus with counters on" 		OFF)
+option						(optimize			"Build Dionysus with optimization"		ON)
+
+# Find everything that's always required
+find_package				(Boost REQUIRED)
+find_package				(Doxygen)
+find_library				(dsrpdb_LIBRARY 			NAMES dsrpdb)
+find_path					(dsrpdb_INCLUDE_DIR 		dsrpdb/Protein.h)
+
+set							(libraries 					${libraries}
+														${dsrpdb_LIBRARY})
+
+#CGAL
+execute_process				(COMMAND ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_SOURCE_DIR}/FindCGAL.Makefile libpaths
+							 OUTPUT_VARIABLE cgal_libpaths)
+execute_process				(COMMAND ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_SOURCE_DIR}/FindCGAL.Makefile ldflags
+							 OUTPUT_VARIABLE cgal_ldflags)
+execute_process				(COMMAND ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_SOURCE_DIR}/FindCGAL.Makefile cxxflags
+							 OUTPUT_VARIABLE cgal_cxxflags)
+execute_process				(COMMAND ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_SOURCE_DIR}/FindCGAL.Makefile libpath
+							 OUTPUT_VARIABLE cgal_libpath)
+#string						(REPLACE "\n" "" cgal_libpaths	${cgal_libpaths})
+#string						(REPLACE "\n" "" cgal_ldflags 	${cgal_ldflags})
+string						(REPLACE "\n" "" cgal_cxxflags 	${cgal_cxxflags})
+string						(REPLACE "\n" "" cgal_libpath 	${cgal_libpath})
+add_definitions				(${cgal_cxxflags})
+find_library				(cgal_LIBRARY				NAMES CGAL
+														PATHS ${cgal_libpath})
+find_library				(core_LIBRARY				NAMES core++
+														PATHS ${cgal_libpath})
+find_library				(mpfr_LIBRARY				NAMES mpfr)
+find_library				(gmp_LIBRARY				NAMES gmp)
+find_library				(gmpxx_LIBRARY				NAMES gmpxx)
+find_library				(m_LIBRARY					NAMES m)
+
+set							(cgal_libraries 			${cgal_LIBRARY} 
+														${core_LIBRARY}
+														${mpfr_LIBRARY} 
+														${gmp_LIBRARY} 
+														${gmpxx_LIBRARY} 
+														${m_LIBRARY})
+
+# Debugging
+if							(debug)
+	find_library			(cwd_LIBRARY				NAMES cwd)
+	find_path				(cwd_INCLUDE_DIR			libcwd/debug.h)
+	set 					(cwd_INCLUDE_DIR			${cwd_INCLUDE_DIR}/libcwd)
+	add_definitions			(-DCWDEBUG -g)
+	set						(external_sources			${CMAKE_CURRENT_SOURCE_DIR}/src/debug.cpp)
+	set						(libraries 					${libraries} ${cwd_LIBRARY})
+else						(debug)
+	add_definitions			(-DNDEBUG)
+endif						(debug)
+
+# Counters
+if							(counters)
+	add_definitions			(-DCOUNTERS)
+endif						(counters)
+
+# Optimization
+if							(optimize GREATER 0)
+	add_definitions			(-O${optimize})
+elseif						(optimize)
+	add_definitions			(-O)
+endif						(optimize)
+endif						(optimize GREATER 0)
+
+
+# Set includes
+include_directories			(${CMAKE_CURRENT_BINARY_DIR}
+							 ${CMAKE_CURRENT_SOURCE_DIR}/include
+							 ${Boost_INCLUDE_DIR}
+							 ${dsrpdb_INCLUDE_DIR}
+							 ${cwd_INCLUDE_DIR})
+
+# Doxygen (FIXME)
+if							(DOXYGEN_FOUND)
+#	add_custom_target 		(docs ALL 
+#							${DOXYGEN_EXECUTABLE} Doxyfile
+#							DEPENDS Doxyfile)
+endif						(DOXYGEN_FOUND)
+
+# Set external sources
+add_subdirectory			(examples)
+add_subdirectory			(tests)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FindCGAL.Makefile	Tue Jan 30 13:51:04 2007 -0500
@@ -0,0 +1,15 @@
+include $(CGAL_MAKEFILE)
+
+all: libpath libpaths ldflags cxxflags
+
+libpath:
+	@echo "$(CGAL_LIB_DIR)/$(CGAL_OS_COMPILER)"
+
+libpaths:
+	@echo "$(CGAL_LIBPATHFLAGS)"
+
+ldflags:
+	@echo "$(CGAL_LDFLAGS)"
+
+cxxflags:
+	@echo "$(CGAL_CXXFLAGS)"
--- a/README	Wed Jan 24 17:50:45 2007 -0500
+++ b/README	Tue Jan 30 13:51:04 2007 -0500
@@ -1,20 +1,27 @@
 Dependencies
   CGAL-3.2 -    for alpha-shapes and kinetic data structures
   DSR-PDB -     for reading in PDB files
-  scons -       for controlling the build process
+  cmake -       for controlling the build process
   boost -       great set of C++ libraries
   Doxygen -     for building documentation
+  libcwd -      for debugging only (is not needed by default)
 
 Configuration
-  Local configuration is read from config/HOSTNAME.py 
-  The path to and architecture of CGAL are important variables (cgal_path and
-  cgal_architecture respectively).
+  The path to CGAL's Makefile is expected to be set in $CGAL_MAKEFILE, the rest
+  is just usual CMake configuration
 
 Building
-  To build examples run "scons" at the top level, or "scons -u" in the specific
-  examples/ subdirectory.
-  "scons debug=1" turns on debugging. "scons counters=1" turns on counters. 
-  "scons optimize=3" turns on -O3 optimizations.
+  To build examples, create a directory build (to keep everything in one place),
+  go to that directory and run cmake and make:
+  mkdir build
+  cd build
+  cmake ..   (or "ccmake .." if you want a curses interface)
+  make
+  
+  In the cmake line you can provide -Ddebug:bool=on to turn on debugging,
+  -Dcounters:bool=on to turn on counters, -Doptimize:int=3 would set
+  optimization to -O3. All of this can be set using a text user interface by
+  running ccmake instead of cmake.
 
 Author
   Dmitriy Morozov <morozov@cs.duke.edu>
--- a/SConstruct	Wed Jan 24 17:50:45 2007 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-import os
-
-# Get options
-options_filenames =		['config/' + os.uname()[1] + '.py', os.path.expanduser('~/.scons/config.py')]
-
-for fn in options_filenames:
-	if os.path.exists(fn):
-		optns =			Options(fn)
-		print "Found configuration:", fn
-		break
-else:
-		optns =			Options()
-
-optns.AddOptions		(PathOption('cgal_path', 'where CGAL is installed', ''),
-						('cgal_architecture', 'string describing CGAL architecture'),
-						('INCPATH', 'additional include paths separated with :',''),
-						('LIBPATH', 'additional library paths separated with :',''),
-						PathOption('qt4_includes', 'where Qt4 headers are installed', ''),
-						PathOption('qt4_libs', 'where Qt4 libraries are installed', ''),
-						('CXX', 'The C++ compiler'))
-
-# Setup environment
-base_env = 				Environment(options = optns,
-									ENV = os.environ,
-									tools=["default", "doxygen"], #, "qt4"], 
-									toolpath=["sconstools"])
-Help					(optns.GenerateHelpText(base_env))
-
-dbg =					base_env.Copy(CPPFLAGS = ['-g'])
-opt = 					base_env.Copy(CPPDEFINES = ['NDEBUG'])
-
-if ARGUMENTS.get('debug', 0):
-	env = 				dbg
-	env.Append			(CPPDEFINES = ['CWDEBUG'])
-	env.Append			(LIBS = ['cwd'])
-elif ARGUMENTS.get('optimize', 0):
-	opt.Append 			(CPPFLAGS = ['-O' + str(ARGUMENTS['optimize'])])
-	env =				opt
-else:
-	opt.Append 			(CPPFLAGS = ['-O'])
-	env =				opt
-
-if ARGUMENTS.get('counters', 0):
-	env.Append			(CPPDEFINES = ['COUNTERS'])
-
-# Don't create .sconsign files all over the place
-SConsignFile()
-
-# Create tags file
-#tags =					env.Command('tags', 'sources',			# FIXME
-#									['ctags '])
-
-# CGAL
-cgal_path = 			env['cgal_path']
-cgal_architecture = 	env['cgal_architecture']	
-
-cgal_defines = 			['CGAL_USE_GMP', 'CGAL_USE_GMPXX', 'CGAL_USE_CORE']
-cgal_cpppath =			[cgal_path + '/include/CGAL/config/' + cgal_architecture, cgal_path + '/include']
-cgal_libs = 			['CGAL', 'core++', 'mpfr', 'gmpxx', 'gmp', 'm']
-cgal_link_flags =		['-Wl,-R' + cgal_path + '/lib/' + cgal_architecture]
-cgal_lib_paths = 		[cgal_path + '/lib/' + cgal_architecture]
-
-# Includes
-cpppath =				['#/include'] + env['INCPATH'].split(':')
-libpath = 				env['LIBPATH'].split(':')
-
-# Append variables to the environment
-env.Append				(CPPDEFINES = cgal_defines, 
-						 CPPPATH = cpppath + cgal_cpppath,
-						 LIBS = cgal_libs, 
-						 LIBPATH = libpath + cgal_lib_paths, 
-						 LINKFLAGS = cgal_link_flags)
-
-# Build documentation (in docs/)
-Default(env.Doxygen("Doxyfile"))
-
-# Build stuff in src/, and export it
-external_sources = 		SConscript(['src/SConscript'], exports = ['env'])
-
-# Build examples/ and tools/
-#SConscript				(['examples/SConscript',
-#						  'tools/SConscript'],
-#						 exports = ['env', 'external_sources'])
-SConscript				(['examples/SConscript', 
-						  'tests/SConscript'],
-						 exports = ['env', 'external_sources'])
-
-# vim: syntax=python
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/CMakeLists.txt	Tue Jan 30 13:51:04 2007 -0500
@@ -0,0 +1,3 @@
+add_subdirectory			(alphashapes)
+add_subdirectory			(grid)
+add_subdirectory			(triangle)
--- a/examples/SConscript	Wed Jan 24 17:50:45 2007 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-Import('*')
-
-SConscript				(['triangle/SConscript',
-						  'alphashapes/SConscript',
-						  'grid/SConscript'],
-						 exports=['env', 'external_sources'])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/alphashapes/CMakeLists.txt	Tue Jan 30 13:51:04 2007 -0500
@@ -0,0 +1,8 @@
+set							(targets						
+							 alphashapes3d
+							 alpharadius)
+							 
+foreach 					(t ${targets})
+	add_executable			(${t} ${t}.cpp ${external_sources})
+	target_link_libraries	(${t} ${libraries} ${cgal_libraries})
+endforeach 					(t ${targets})
--- a/examples/alphashapes/SConscript	Wed Jan 24 17:50:45 2007 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-Import('*')
-
-# Sources
-sources = 				['alphashapes3d.cpp', 'alpharadius.cpp']
-
-for s in sources:
-	Default				(env.Program([s] + external_sources))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/grid/CMakeLists.txt	Tue Jan 30 13:51:04 2007 -0500
@@ -0,0 +1,9 @@
+set							(targets						
+							 test-grid2D 
+							 pdbdistance-vineyard
+							 combustion-vineyard)
+							 
+foreach 					(t ${targets})
+	add_executable			(${t} ${t}.cpp ${external_sources})
+	target_link_libraries	(${t} ${libraries} ${cgal_libraries})
+endforeach 					(t ${targets})
--- a/examples/grid/SConscript	Wed Jan 24 17:50:45 2007 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-Import('*')
-
-# Libraries
-libraries =				['dsrpdb']
-
-# Sources
-sources = 				['test-grid2D.cpp', 'pdbdistance-vineyard.cpp', 'combustion-vineyard.cpp']
-
-local_env = 			env.Copy()
-local_env.Append		(LIBS = libraries)
-
-for s in sources:
-	Default(local_env.Program([s] + external_sources))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/triangle/CMakeLists.txt	Tue Jan 30 13:51:04 2007 -0500
@@ -0,0 +1,7 @@
+set							(targets						
+							 triangle)
+							 
+foreach 					(t ${targets})
+	add_executable			(${t} ${t}.cpp ${external_sources})
+	target_link_libraries	(${t} ${libraries})
+endforeach 					(t ${targets})
--- a/examples/triangle/SConscript	Wed Jan 24 17:50:45 2007 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-Import('*')
-
-Default(env.Program(['triangle.cpp'] + external_sources))
--- a/sconstools/doxygen.py	Wed Jan 24 17:50:45 2007 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,192 +0,0 @@
-# vim: set et sw=3 tw=0 fo=awqorc ft=python:
-#
-# Astxx, the Asterisk C++ API and Utility Library.
-# Copyright (C) 2005, 2006  Matthew A. Nicholson
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License version 2.1 as published by the Free Software Foundation.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-import os
-import glob
-
-def DoxyfileParse(file_contents):
-   """
-   Parse a Doxygen source file and return a dictionary of all the values.
-   Values will be strings and lists of strings.
-   """
-   data = {}
-
-   import shlex
-   lex = shlex.shlex(instream = file_contents, posix = True)
-   lex.wordchars += "./-"
-   lex.whitespace = lex.whitespace.replace("\n", "")
-   lex.escape = ""
-
-   lineno = lex.lineno
-   token = lex.get_token()
-   key = token   # the first token should be a key
-   last_token = ""
-   key_token = False
-   next_key = False
-
-   while token:
-      if token in ['\n']:
-         if last_token not in ['\\']:
-            key_token = True
-      elif token in ['\\']:
-         pass
-      elif key_token:
-         key = token
-         key_token = False
-      else:
-         if token == "+=":
-            if not data.has_key(key):
-               data[key] = list()
-         elif token == "=":
-            data[key] = list()
-         else:
-            data[key].append(token)
-
-      last_token = token
-      token = lex.get_token()
-
-   # compress lists of len 1 into single strings
-   for (k, v) in data.items():
-      if len(v) == 0:
-         data.pop(k)
-
-      if k in ["INPUT", "FILE_PATTERNS"]:
-         continue
-
-      if len(v) == 1:
-         data[k] = v[0]
-
-   return data
-
-def DoxySourceScan(node, env, path):
-   """
-   Doxygen Doxyfile source scanner.  This should scan the Doxygen file and add
-   any files used to generate docs to the list of source files.
-   """
-   default_file_patterns = [
-      '*.c', '*.cc', '*.cxx', '*.cpp', '*.c++', '*.java', '*.ii', '*.ixx',
-      '*.ipp', '*.i++', '*.inl', '*.h', '*.hh ', '*.hxx', '*.hpp', '*.h++',
-      '*.idl', '*.odl', '*.cs', '*.php', '*.php3', '*.inc', '*.m', '*.mm',
-      '*.py',
-   ]
-
-   sources = []
-
-   data = DoxyfileParse(node.get_contents())
-
-   if data.get("RECURSIVE", "NO") == "YES":
-      recursive = True
-   else:
-      recursive = False
-
-   file_patterns = data.get("FILE_PATTERNS", default_file_patterns)
-
-   def recursively_scan_dir(dir, file_patterns):
-      matches = []
-      if not os.path.isdir(dir):
-         return matches
-
-      for pattern in file_patterns:
-         matches.extend(glob.glob("/".join([dir, pattern])))
-
-      for node in os.listdir(dir):
-         path = "/".join([dir, node])
-         if os.path.isdir(path):
-            matches.extend(recursively_scan_dir(path, file_patterns))
-
-      return matches
-
-   for node in data.get("INPUT", []):
-      if os.path.isfile(node):
-         sources.add(node)
-      elif os.path.isdir(node):
-         if recursive:
-            sources.extend(recursively_scan_dir(node, file_patterns))
-         else:
-            for pattern in file_patterns:
-               sources.extend(glob.glob("/".join([node, pattern])))
-
-   return sources
-
-def DoxySourceScanCheck(node, env):
-   """Check if we should scan this file"""
-   return os.path.isfile(node.path)
-
-def DoxyEmitter(source, target, env):
-   """Doxygen Doxyfile emitter"""
-   # possible output formats and their default values and output locations
-   output_formats = {
-      "HTML": ("YES", "html"),
-      "LATEX": ("NO", "latex"),
-      "RTF": ("NO", "rtf"),
-      "MAN": ("NO", "man"),
-      "XML": ("NO", "xml"),
-   }
-
-   data = DoxyfileParse(source[0].get_contents())
-
-   targets = []
-   out_dir = data.get("OUTPUT_DIRECTORY", ".")
-
-   # add our output locations
-   for (k, v) in output_formats.items():
-      if data.get("GENERATE_" + k, v[0]) == "YES":
-         targets.append("/".join([out_dir, data.get(k + "_OUTPUT", v[1])]))
-
-   # don't clobber targets
-   for node in targets:
-      env.Precious(node)
-
-   # set up cleaning stuff
-   for node in targets:
-      env.Clean(node, node)
-
-   return (targets, source)
-
-def generate(env):
-   """
-   Add builders and construction variables for the
-   Doxygen tool.  This is currently for Doxygen 1.4.6.
-   """
-   doxygen_scanner = env.Scanner(
-      DoxySourceScan,
-      "DoxySourceScan",
-      scan_check = DoxySourceScanCheck,
-   )
-
-   doxygen_builder = env.Builder(
-      action = env.Action("${DOXYGEN} ${SOURCE}"),
-      emitter = DoxyEmitter,
-      target_factory = env.fs.Entry,
-      single_source = True,
-      source_scanner =  doxygen_scanner,
-   )
-
-   env.Append(BUILDERS = {
-      'Doxygen': doxygen_builder,
-   })
-
-   env.AppendUnique(
-      DOXYGEN = 'doxygen',
-   )
-
-def exists(env):
-   """
-   Make sure doxygen exists.
-   """
-   return env.Detect("doxygen")
--- a/src/SConscript	Wed Jan 24 17:50:45 2007 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-Import('*')
-
-#sources = ['grid2D.cpp', 'debug.cpp']
-sources = ['debug.cpp']
-o = []
-
-for s in sources:
-	o += [env.Object(s)]
-
-Return('o')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/CMakeLists.txt	Tue Jan 30 13:51:04 2007 -0500
@@ -0,0 +1,8 @@
+set							(targets						
+							 test-consistencylist
+							 test-orderlist)
+
+foreach 					(t ${targets})
+	add_executable			(${t} ${t}.cpp ${external_sources})
+	target_link_libraries	(${t} ${libraries})
+endforeach 					(t ${targets})
--- a/tests/SConscript	Wed Jan 24 17:50:45 2007 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-Import('*')
-
-sources = 			['test-orderlist.cpp', 'test-consistencylist.cpp']
-
-for s in sources:
-	Default(env.Program([s] + external_sources))