# CMakeLists.txt # # Description: cmake file for python database bindings for GREAT-ER # # Authors: # Andre Heinecke # Björn Ricks # # 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) find_package(PythonLibs 2.3 REQUIRED) find_package(PythonInterp REQUIRED) if (NOT DAGREATER_FOUND) add_subdirectory(${CMAKE_SOURCE_DIR}/impl/postgresql) set(DAGREATER_LIBRARIES dagreater_pg) set(DAGREATER_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/impl/postgresql) endif() set(PYDAGREATER_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(PYDAGREATER_SOURCE_FILES ${CMAKE_SOURCE_DIR}/GreaterDB/dssfiledb.py ${CMAKE_SOURCE_DIR}/GreaterDB/__init__.py ${CMAKE_SOURCE_DIR}/GreaterDB/interface.py ) set(PYDAGREATER_FILES ${PYDAGREATER_SOURCE_FILES} ${CMAKE_SOURCE_DIR}/GreaterDB/dssfiledb.pyc ${CMAKE_SOURCE_DIR}/GreaterDB/__init__.pyc ${CMAKE_SOURCE_DIR}/GreaterDB/interface.pyc ) set(PYDAGREATER_GENERATOR_FILES ${CMAKE_SOURCE_DIR}/generator/WrapperGenerator/typesystem.py ${CMAKE_SOURCE_DIR}/generator/WrapperGenerator/cmodule.py ${CMAKE_SOURCE_DIR}/generator/WrapperGenerator/functions.py ${CMAKE_SOURCE_DIR}/generator/GreaterAPIGenerator/cfiles.py ${CMAKE_SOURCE_DIR}/generator/GreaterAPIGenerator/dbfunctions.py ${CMAKE_SOURCE_DIR}/generator/GreaterAPIGenerator/greatertypes.py ${CMAKE_SOURCE_DIR}/generator/GreaterAPIGenerator/main.py ${CMAKE_SOURCE_DIR}/generator/GreaterAPIGenerator/pyfiles.py ${CMAKE_SOURCE_DIR}/generator/GreaterAPIGenerator/helper.py ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dagreater/pydagreater.py ${PYDAGREATER_FILES} DESTINATION lib/${PYDAGREATER_INSTALL_PATH} ) ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dagreater/_dagreater_pg.c ${CMAKE_CURRENT_BINARY_DIR}/dagreater/pydagreater.py COMMAND ${PYTHON_EXECUTABLE} ${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 ${PYDAGREATER_GENERATOR_FILES} ) 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 ${PYTHON_EXECUTABLE} -m py_compile ${PYTHON_FILE} COMMENT "Compiling ${PYTHON_FILE}" SOURCES ${PYTHON_FILE} ) endmacro(python_compile) foreach(_PYTHON_FILE ${PYDAGREATER_SOURCE_FILES}) message(STATUS "Compiling ${_PYTHON_FILE}") python_compile(${_PYTHON_FILE}) endforeach(_PYTHON_FILE) add_library(pydagreater MODULE ${pydagreater_SRCS}) 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/${PYDAGREATER_INSTALL_PATH})