From: Sergey Belash Date: Thu, 13 Mar 2014 12:53:57 +0000 (+0400) Subject: SWIG, Python and libxml included X-Git-Tag: V_0.1~58 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=86d4424c87cc0b95be289a43042ad698db633f9a;p=modules%2Fshaper.git SWIG, Python and libxml included --- diff --git a/CMakeCommon/FindPython.cmake b/CMakeCommon/FindPython.cmake new file mode 100644 index 000000000..b1aa8c531 --- /dev/null +++ b/CMakeCommon/FindPython.cmake @@ -0,0 +1,16 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11) + +IF(CMAKE_BUILD_TYPE STREQUAL "Debug") + SET(PYTHON_LIBRARY_DLL "python27_d.lib") +ElSE() + SET(PYTHON_LIBRARY_DLL "python27.lib") +ENDIF() + +FILE(TO_CMAKE_PATH "$ENV{PYTHON_LIB_DIR}/${PYTHON_LIBRARY_DLL}" PYTHON_LIBRARY) +FILE(TO_CMAKE_PATH $ENV{PYTHON_INC_DIR} PYTHON_INCLUDE_DIR) + +# TOOD: Clean a mess with python interpreter +# FIND_PACKAGE(PythonInterp) +FIND_PACKAGE(PythonLibs) + +INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS}) diff --git a/CMakeLists.txt b/CMakeLists.txt index 607249a9e..1d45e5620 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ PROJECT (NewGEOM) SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeCommon" ${CMAKE_MODULE_PATH}) -ADD_SUBDIRECTORY (src/ModelAPI) +#ADD_SUBDIRECTORY (src/ModelAPI) ADD_SUBDIRECTORY (src/Model) ADD_SUBDIRECTORY (src/XGUI) #ADD_SUBDIRECTORY (src/GeomModule) \ No newline at end of file diff --git a/buildNewGEOM.bat b/buildNewGEOM.bat index 0c26dba6d..51e29adda 100644 --- a/buildNewGEOM.bat +++ b/buildNewGEOM.bat @@ -1,11 +1,18 @@ -@SET ROOT_DIR=%~dp0.. +@ECHO OFF -@set SRC_DIR=%ROOT_DIR%\sources +REM Find absolute path to ROOT_DIR +@SET PARENT_DIR=%~dp0.. +@SET ROOT_DIR= +pushd %PARENT_DIR% +@SET ROOT_DIR=%CD% +popd -call %SRC_DIR%\env.bat +@SET SRC_DIR=%ROOT_DIR%\sources +call %SRC_DIR%\env.bat mkdir %ROOT_DIR%\build cd %ROOT_DIR%\build cmake %SRC_DIR% -G "Visual Studio 10" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install + start "" %MSVC_EXE% NewGEOM.sln diff --git a/env.bat b/env.bat index abf39c37f..1b241f546 100644 --- a/env.bat +++ b/env.bat @@ -14,19 +14,19 @@ if exist "%ROOT_DIR%\localenv.bat" ( rem --------------- Configuration -------------- rem --------------- Products path -------------- -if "%PRODUCTSDIR%" == "" ( - set PRODUCTSDIR=%ROOT_DIR%\PRODUCTS +if "%PDIR%" == "" ( + set PDIR=%ROOT_DIR%\products ) rem --------------- cmake 2.8.7 -------------- if "%CMAKEDIR%" == "" ( - set CMAKEDIR=%PRODUCTSDIR%\cmake-2.8.12.1 + set CMAKEDIR=%PDIR%\cmake-2.8.12.1 ) set PATH=%CMAKEDIR%\bin;%PATH% @REM ------------------------- @REM CASCADE -@SET CAS_ROOT_DIR=%PRODUCTSDIR%\OCCT-6.7.0 +@SET CAS_ROOT_DIR=%PDIR%\OCCT-6.7.0 @SET CASROOT=%CAS_ROOT_DIR% @REM ------------------------- @@ -55,37 +55,59 @@ set PATH=%CMAKEDIR%\bin;%PATH% @REM ------------------------- @REM FREEIMAGE (Used by OCCT) -@SET PATH=%PRODUCTSDIR%\freeimage-3.15.4\bin;%PATH% +@SET PATH=%PDIR%\freeimage-3.15.4\bin;%PATH% @REM ------------------------- @REM ------------------------- @REM FTGL (Used by OCCT) -@SET PATH=%PRODUCTSDIR%\ftgl-2.1.3\bin;%PATH% +@SET PATH=%PDIR%\ftgl-2.1.3\bin;%PATH% @REM ------------------------- @REM ------------------------- @REM FREETYPE (Used by OCCT) -@SET PATH=%PRODUCTSDIR%\freetype-2.4.11\bin;%PATH% +@SET PATH=%PDIR%\freetype-2.4.11\bin;%PATH% @REM ------------------------- @REM ------------------------- @REM GL2PS (Used by OCCT AND PARAVIEW) -@SET PATH=%PRODUCTSDIR%\gl2ps-1.3.8\bin;%PATH% +@SET PATH=%PDIR%\gl2ps-1.3.8\bin;%PATH% @REM ------------------------- @REM ------------------------- @REM TBB (Used by OCCT) -@SET PATH=%PRODUCTSDIR%\tbb\bin;%PATH% +@SET PATH=%PDIR%\tbb\bin;%PATH% @REM ------------------------- @REM ------------------------- @REM QT if "%QTDIR%" == "" ( - @SET QTDIR=%PRODUCTSDIR%\Qt-5.2.0\5.2.0\msvc2010 + @SET QTDIR=%PDIR%\Qt-5.2.0\5.2.0\msvc2010 ) @SET PATH=%QTDIR%\bin;%PATH% @REM ------------------------- +@REM ------------------------- +@REM PYTHON +@SET PYTHONHOME=%PDIR%\python-2.7.3 +@SET PYTHON_LIB_DIR=%PYTHONHOME%\libs +@SET PYTHON_INC_DIR=%PYTHONHOME%\include +@SET PATH=%PYTHON_LIB_DIR%;%PATH% +@SET PATH=%PYTHONHOME%;%PATH% +@SET PYTHONPATH=%PYTHONHOME%\Lib;%PYTHONPATH% +@SET PYTHONPATH=%PYTHONHOME%\DLLs;%PYTHONPATH% +@SET PYTHON_VERSION=2.7 +@REM ------------------------- + +@REM ------------------------- +@REM LIBXML2 +@SET PATH=%PDIR%\libxml2-2.9.0\lib;%PATH% +@REM ------------------------- + +@REM ------------------------- +@REM SWIG +@SET PATH=%PDIR%\swig-2.0.9\bin;%PATH% +@REM ------------------------- + rem -------- Visual Studio -------------------- rem Detect Visual Studio (either commercial or Express edition) if "%VS100COMNTOOLS%" == "" ( diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 50f25206d..dc9e40965 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -1,6 +1,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11) INCLUDE(Common) +FIND_PACKAGE(SWIG REQUIRED) +INCLUDE(${SWIG_USE_FILE}) +INCLUDE(FindPython) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) SET(PROJECT_HEADERS ModelAPI.hxx @@ -12,3 +16,31 @@ ADD_DEFINITIONS(-DMODELAPI_EXPORTS) ADD_LIBRARY(ModelAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) SET_TARGET_PROPERTIES(ModelAPI PROPERTIES LINKER_LANGUAGE CXX) #TARGET_LINK_LIBRARIES(ModelAPI ${PROJECT_LIBRARIES}) + +SET(CMAKE_SWIG_FLAGS "") + +SET_SOURCE_FILES_PROPERTIES(ModelAPI.i PROPERTIES CPLUSPLUS ON) +SET_SOURCE_FILES_PROPERTIES(ModelAPI.i PROPERTIES SWIG_FLAGS "-includeall") +SET_SOURCE_FILES_PROPERTIES(ModelAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow") +#SET_SOURCE_FILES_PROPERTIES(ModelAPIPYTHON_wrap.cxx PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H") + +SET(SWIG_SCRIPTS + ${CMAKE_CURRENT_BINARY_DIR}/ModelAPI.py +) + +SET(SWIG_LINK_LIBRARIES + ModelAPI + ${PYTHON_LIBRARIES} +) + +SWIG_ADD_MODULE(ModelAPI python ModelAPI.i ${PROJECT_HEADERS}) +SWIG_LINK_LIBRARIES(ModelAPI ${SWIG_LINK_LIBRARIES}) + +IF(WIN32) + SET_TARGET_PROPERTIES(_ModelAPI PROPERTIES DEBUG_OUTPUT_NAME _ModelAPI_d) +ENDIF(WIN32) + +INSTALL(TARGETS _ModelAPI DESTINATION swig) +#INSTALL(TARGETS ${SWIG_SCRIPTS} DESTINATION swig) + + diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i new file mode 100644 index 000000000..ffc072a2f --- /dev/null +++ b/src/ModelAPI/ModelAPI.i @@ -0,0 +1,9 @@ +/* ModelAPI.i */ +%module ModelAPI +%{ + #include "ModelAPI.hxx" + #include "ModelAPI_Application.hxx" + #include "ModelAPI_Document.hxx" +%} +%include "ModelAPI_Application.hxx" +%include "ModelAPI_Document.hxx" diff --git a/src/ModelAPI/ModelAPI_Application.hxx b/src/ModelAPI/ModelAPI_Application.hxx index b9d5e0c17..284e5a11d 100644 --- a/src/ModelAPI/ModelAPI_Application.hxx +++ b/src/ModelAPI/ModelAPI_Application.hxx @@ -6,7 +6,8 @@ #ifndef ModelAPI_Application_HeaderFile #define ModelAPI_Application_HeaderFile -#include +#include "ModelAPI.hxx" +class ModelAPI_Document; /**\class Model_Application * \ingroup DataModel @@ -17,9 +18,8 @@ class ModelAPI_Application { public: // useful methods inside of the module - //! Retuns the application: one per process - MODELAPI_EXPORT virtual static ModelAPI_Application GetApplication() = 0; + MODELAPI_EXPORT virtual ModelAPI_Application GetApplication() = 0; MODELAPI_EXPORT virtual ModelAPI_Document* GetMainDocument() = 0; };