]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
SWIG, Python and libxml included
authorSergey Belash <sergey.belash@opencascade.com>
Thu, 13 Mar 2014 12:53:57 +0000 (16:53 +0400)
committerSergey Belash <sergey.belash@opencascade.com>
Thu, 13 Mar 2014 12:53:57 +0000 (16:53 +0400)
CMakeCommon/FindPython.cmake [new file with mode: 0644]
CMakeLists.txt
buildNewGEOM.bat
env.bat
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI.i [new file with mode: 0644]
src/ModelAPI/ModelAPI_Application.hxx

diff --git a/CMakeCommon/FindPython.cmake b/CMakeCommon/FindPython.cmake
new file mode 100644 (file)
index 0000000..b1aa8c5
--- /dev/null
@@ -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})
index 607249a9e2e1a6c0b548753df1594ae264565a66..1d45e5620b835bce356177bb70591248cca264d5 100644 (file)
@@ -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
index 0c26dba6d4202bb8ec5114f3460f8abdc56a0516..51e29adda2e4d59f1ad9a6dacc02e7431b7846c6 100644 (file)
@@ -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 abf39c37fb378c648cb7f859617ff564c52c1f40..1b241f5468c6cc291da01ee974a1a6eab3e29591 100644 (file)
--- 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%" == "" (
index 50f25206d73b63d4dcd78b3924c6be4803fff94b..dc9e4096553e79c5b0ee3edd2ede4494d7decac9 100644 (file)
@@ -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 (file)
index 0000000..ffc072a
--- /dev/null
@@ -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"
index b9d5e0c17ce5e61c86cecb1c257521be9b866dd7..284e5a11d582d120722539695157c00e68b447a5 100644 (file)
@@ -6,7 +6,8 @@
 #ifndef ModelAPI_Application_HeaderFile
 #define ModelAPI_Application_HeaderFile
 
-#include <ModelAPI.hxx>
+#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;
 };