[Greater-commits] r258 - in trunk/GREAT-ER-DB: . cmake
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Jun 24 09:40:46 CEST 2011
Author: bricks
Date: 2011-06-24 09:40:45 +0200 (Fri, 24 Jun 2011)
New Revision: 258
Added:
trunk/GREAT-ER-DB/CMakeLists.txt
trunk/GREAT-ER-DB/cmake/
trunk/GREAT-ER-DB/cmake/FindDagreater.cmake
Log:
Add cmake files to be able to build dagreater c wrapper via CMake
Added: trunk/GREAT-ER-DB/CMakeLists.txt
===================================================================
--- trunk/GREAT-ER-DB/CMakeLists.txt 2011-06-24 07:38:14 UTC (rev 257)
+++ trunk/GREAT-ER-DB/CMakeLists.txt 2011-06-24 07:40:45 UTC (rev 258)
@@ -0,0 +1,137 @@
+# CMakeLists.txt
+#
+# Description: cmake file for python database bindings for GREAT-ER
+#
+# Authors:
+# Andre Heinecke <aheinecke at intevation.de>
+# Björn Ricks <bjoern.ricks at intevation.de>
+#
+# Copyright:
+# Copyright (C) 2011 by Intevation GmbH
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2,
+# or, at your option, any later version as published by the Free
+# Software Foundation
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+project(dagreater_pg)
+
+cmake_minimum_required(VERSION 2.6)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+set(CMAKE_PYDAGREATER_VERSION_MAJOR 1)
+set(CMAKE_PYDAGREATER_VERSION_MINOR 9)
+set(CMAKE_PYDAGREATER_VERSION_PATCH 0)
+set(CMAKE_PYDAGREATER_VERSION_STRING "${CMAKE_PYDAGREATER_VERSION_MAJOR}.${CMAKE_PYDAGREATER_VERSION_MINOR}.${CMAKE_PYDAGREATER_VERSION_PATCH}")
+
+option(PYDAGERATER_ENABLE_TESTS "Enable tests" OFF)
+option(PYDAGREATER_DEBUG "Add debug output" OFF)
+
+if (PYDAGREATER_ENABLE_TESTS)
+ message(STATUS "Testing is not yet implemented from cmake")
+ add_subdirectory(tests)
+endif (PYDAGREATER_ENABLE_TESTS)
+
+find_package(Dagreater REQUIRED)
+find_package(PythonLibs REQUIRED)
+find_package(PythonInterp REQUIRED)
+
+if(PYTHON_EXECUTABLE)
+ execute_process(COMMAND "${PYTHON_EXECUTABLE}" --version ERROR_VARIABLE _VERSION OUTPUT_QUIET ERROR_STRIP_TRAILING_WHITESPACE)
+ string(REPLACE "Python " "" PYTHON_VERSION "${_VERSION}")
+ STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION}")
+ STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION}")
+ STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PYTHON_VERSION_PATCH "${PYTHON_VERSION}")
+endif()
+
+set(DAGREATER_INSTALL_PATH "python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/GreaterDB")
+
+if (MSVC)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+ add_definitions(/we4700)
+endif()
+
+set(DEBUG_ARG "")
+
+if (PYDAGREATER_DEBUG)
+ set(CMAKE_BUILD_TYPE "RelWithDebInfo")
+ set(DEBUG_ARG "--debug")
+endif()
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${DAGREATER_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
+
+set(pydagreater_SRCS
+ ${CMAKE_CURRENT_BINARY_DIR}/dagreater/_dagreater_pg.c
+)
+
+set(DAGREATER_PYTHON_SOURCE_FILES
+ ${CMAKE_SOURCE_DIR}/GreaterDB/dssfiledb.py
+ ${CMAKE_SOURCE_DIR}/GreaterDB/__init__.py
+ ${CMAKE_SOURCE_DIR}/GreaterDB/interface.py
+ )
+
+set(DAGREATER_PYTHON_FILES
+ ${DAGREATER_PYTHON_SOURCE_FILES}
+ ${CMAKE_SOURCE_DIR}/GreaterDB/dssfiledb.pyc
+ ${CMAKE_SOURCE_DIR}/GreaterDB/__init__.pyc
+ ${CMAKE_SOURCE_DIR}/GreaterDB/interface.pyc
+ )
+
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/dagreater/pydagreater.py
+ ${DAGREATER_PYTHON_FILES}
+ DESTINATION lib/${DAGREATER_INSTALL_PATH}
+)
+
+ADD_CUSTOM_COMMAND(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dagreater/_dagreater_pg.c
+ ${CMAKE_CURRENT_BINARY_DIR}/dagreater/pydagreater.py
+ COMMAND ${CMAKE_SOURCE_DIR}/generatewrapper.py ${DEBUG_ARG}
+ -o ${CMAKE_CURRENT_BINARY_DIR}/dagreater
+ -i ${CMAKE_SOURCE_DIR}/dagreater
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dagreater/apispec.py ${CMAKE_SOURCE_DIR}/generatewrapper.py
+)
+
+macro(python_compile PYTHON_FILE)
+ string(REPLACE ".py" ".pyc" PYTHON_COMPILED_FILE "${PYTHON_FILE}")
+ get_filename_component(_target ${PYTHON_COMPILED_FILE} NAME)
+ add_custom_target( ${_target} ALL
+ COMMAND pycompile
+ ${PYTHON_FILE}
+ COMMENT "Compiling ${PYTHON_FILE}"
+ SOURCES ${PYTHON_FILE}
+ )
+endmacro(python_compile)
+
+foreach(_PYTHON_FILE ${DAGREATER_PYTHON_SOURCE_FILES})
+ message(STATUS "Compiling ${_PYTHON_FILE}")
+ python_compile(${_PYTHON_FILE})
+endforeach(_PYTHON_FILE)
+
+add_library(pydagreater MODULE ${pydagreater_SRCS})
+message(STATUS "pydagreater libs ${DAGREATER_LIBRARIES}")
+target_link_libraries(pydagreater ${DAGREATER_LIBRARIES}
+ ${PYTHON_LIBRARIES})
+
+set_target_properties(pydagreater PROPERTIES PREFIX ""
+ OUTPUT_NAME _dagreater_pg)
+if(WIN32 AND NOT CYGWIN)
+ set_target_properties(pydagreater PROPERTIES
+ SUFFIX .pyd
+ LINK_FLAGS /EXPORT:init_dagreater_pg
+ )
+ENDIF()
+
+
+install(TARGETS pydagreater ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${DAGREATER_INSTALL_PATH})
Added: trunk/GREAT-ER-DB/cmake/FindDagreater.cmake
===================================================================
--- trunk/GREAT-ER-DB/cmake/FindDagreater.cmake 2011-06-24 07:38:14 UTC (rev 257)
+++ trunk/GREAT-ER-DB/cmake/FindDagreater.cmake 2011-06-24 07:40:45 UTC (rev 258)
@@ -0,0 +1,36 @@
+# - Find Dagreater
+# Find the Dagreater includes and client library
+# This module defines
+# DAGREATER_INCLUDE_DIRS, where to find daexplib_pg.h
+# DAGREATER_LIBRARIES, the libraries needed to use dagreater
+# DAGREATER_FOUND, If false, do not try to use dagreater
+#
+# Copyright (c) 2011, Björn Ricks <bjoern.ricks at intevation.de>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+if(DAGREATER_INCLUDE_DIRS AND DAGREATER_LIBRARIES)
+ set(DAGREATER_FOUND TRUE)
+else(DAGREATER_INCLUDE_DIRS AND DAGREATER_LIBRARIES)
+ find_path(DAGREATER_INCLUDE_DIRS daexplib_pg.h
+ PATH_SUFFIXES dagreater
+ )
+
+ find_library(DAGREATER_LIBRARIES dagreater_pg)
+
+ if(DAGREATER_INCLUDE_DIRS AND DAGREATER_LIBRARIES)
+ set(DAGREATER_FOUND TRUE)
+ message(STATUS "Found Dagreater: ${DAGREATER_INCLUDE_DIRS}, ${DAGREATER_LIBRARIES}")
+ else(DAGREATER_INCLUDE_DIRS AND DAGREATER_LIBRARIES)
+ set(DAGREATER_FOUND FALSE)
+ if(Dagreater_FIND_REQUIRED)
+ message(FATAL_ERROR "Dagreater not found.")
+ else()
+ message(STATUS "Dagreater not found.")
+ endif()
+ endif(DAGREATER_INCLUDE_DIRS AND DAGREATER_LIBRARIES)
+
+ mark_as_advanced(DAGREATER_INCLUDE_DIRS DAGREATER_LIBRARIES)
+
+endif(DAGREATER_INCLUDE_DIRS AND DAGREATER_LIBRARIES)
More information about the Greater-commits
mailing list