]> SALOME platform Git repositories - tools/ydefx.git/commitdiff
Salome HOME
Work on cmake.
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Fri, 22 Feb 2019 15:51:34 +0000 (16:51 +0100)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Fri, 22 Feb 2019 15:51:34 +0000 (16:51 +0100)
CMakeLists.txt
src/cpp/CMakeLists.txt
src/cpp/TMonoPyJob.hxx
src/gui/CMakeLists.txt

index 2bd80fa2a5ea9c9b48a51fb042ebbd547e14d1e7..eed83b139f566f2a0c3dc7bdb12b4886dfdc4607 100644 (file)
@@ -25,6 +25,53 @@ SET(BUILD_SHARED_LIBS TRUE)
 
 OPTION(YDEFX_BUILD_GUI "Generate widgets" ON)
 
+FIND_PACKAGE(Py2cpp REQUIRED)
+
+# SalomeKERNEL can be useful in order to define SALOME_INSTALL directories and
+# for using salome test, but it is not a c++ dependency.
+FIND_PACKAGE(SalomeKERNEL NO_MODULE)
+
+IF(NOT SalomeKERNEL_FOUND)
+  MESSAGE("SalomeKERNEL not found. Salome installation paths will not be used")
+ENDIF()
+
+IF(NOT DEFINED SALOME_INSTALL_PYTHON)
+  EXECUTE_PROCESS ( COMMAND ${PYTHON_EXECUTABLE} -c
+  "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))"
+                        OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
+                        RESULT_VARIABLE _PYTHON_pythonlib_result
+                        OUTPUT_STRIP_TRAILING_WHITESPACE )
+
+  IF (_PYTHON_pythonlib_result)
+    MESSAGE (SEND_ERROR "Could not set SALOME_INSTALL_PYTHON!")
+  ENDIF ()
+  GET_FILENAME_COMPONENT(_ABS_PYTHON_MODULE_PATH
+                         ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE)
+  FILE(RELATIVE_PATH SALOME_INSTALL_PYTHON
+                     ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH})
+ENDIF(NOT DEFINED SALOME_INSTALL_PYTHON)
+
+IF(NOT DEFINED SALOME_INSTALL_BINS)
+  SET(SALOME_INSTALL_BINS "bin")
+ENDIF()
+IF(NOT DEFINED SALOME_INSTALL_LIBS)
+  SET(SALOME_INSTALL_LIBS "lib")
+ENDIF()
+IF(NOT DEFINED SALOME_INSTALL_HEADERS)
+  SET(SALOME_INSTALL_HEADERS "include")
+ENDIF()
+IF(NOT DEFINED SALOME_INSTALL_CMAKE)
+  SET(SALOME_INSTALL_CMAKE "lib/cmake/ydefx")
+ENDIF()
+
+SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Path to install Python files")
+SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Path to install binary files")
+SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Path to install libraries")
+SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Path to install headers")
+SET(SALOME_INSTALL_CMAKE "${SALOME_INSTALL_CMAKE}" CACHE PATH "Path to install cmake configuration files")
+
+# there are some problems if the configuration tools are included before the
+# detection of py2cpp and SalomeKERNEL
 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
   LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
@@ -38,18 +85,10 @@ ENDIF()
 FIND_PACKAGE(SalomePythonInterp REQUIRED)
 FIND_PACKAGE(SalomePythonLibs REQUIRED)
 
-SET(PY2CPP_ROOT_DIR $ENV{PY2CPP_ROOT_DIR} CACHE PATH "Path to py2cpp")
-IF( EXISTS ${PY2CPP_ROOT_DIR} )
-  LIST(APPEND CMAKE_MODULE_PATH "${PY2CPP_ROOT_DIR}/lib/cmake/py2cpp")
-ELSE()
-  MESSAGE(FATAL_ERROR "We absolutely need py2cpp, please define PY2CPP_ROOT_DIR")
-ENDIF()
-FIND_PACKAGE(Py2cpp REQUIRED)
-
 IF(YDEFX_BUILD_GUI)
   FIND_PACKAGE(Qt5Widgets CONFIG REQUIRED)
 ENDIF(YDEFX_BUILD_GUI)
 
-SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install Python files")
-
 ADD_SUBDIRECTORY(src)
+
+INSTALL(EXPORT ydefxCfg_cmake DESTINATION ${SALOME_INSTALL_CMAKE} FILE ydefxConfig.cmake)
index b5e28c072d6232bb3e701c44a16838a295660317..841f83f2a89be7840f1f4ca1593ccb1b7ab03b81 100644 (file)
@@ -38,6 +38,7 @@ SET(ydefx_HEADERS
   JobParametersProxy.hxx
   Sample.hxx
   SamplePyConversions.hxx
+  PyConversions.hxx
   Exceptions.hxx
   MonoPyJob.hxx
   TMonoPyJob.hxx
@@ -54,11 +55,10 @@ ADD_LIBRARY(ydefx ${ydefx_SOURCES})
 TARGET_LINK_LIBRARIES(ydefx ${ydefx_LINK})
 TARGET_INCLUDE_DIRECTORIES(ydefx PUBLIC
                           $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/cpp>
-                          $<INSTALL_INTERFACE:include>)
+                          $<INSTALL_INTERFACE:${SALOME_INSTALL_HEADERS}>)
 
-INSTALL(TARGETS ydefx DESTINATION lib)
-INSTALL(TARGETS ydefx EXPORT Findydefx LIBRARY DESTINATION lib)
-INSTALL(FILES ${ydefx_HEADERS} DESTINATION include/ydefx)
-INSTALL(EXPORT Findydefx DESTINATION lib/cmake/ydefx)
+INSTALL(TARGETS ydefx DESTINATION ${SALOME_INSTALL_LIBS})
+INSTALL(TARGETS ydefx EXPORT ydefxCfg_cmake LIBRARY DESTINATION ${SALOME_INSTALL_LIBS})
+INSTALL(FILES ${ydefx_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}/ydefx)
 
 ADD_SUBDIRECTORY(Test)
index 9206c9b4c6bee124fed9a86c662442222cf1dec2..93966a7c392462b458a2bed830109e7969153d69 100644 (file)
@@ -84,7 +84,7 @@ public:
     {
       py2cpp::PyFunction pyFn;
       pyFn.loadExp(_pyStudy, "getResult");
-      fetchResults(_pyStudy.getAttr("sample"), _sample);
+      fetchResults(pyFn(), _sample);
     }
     catch(std::exception& e)
     {
index 62bfc346066aa7b877b98d059472a0ce25922eda..b91514bfebfaa7317bdbde4abdebf5be0396020f 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-#INCLUDE(UseQtExt)
-#INCLUDE_DIRECTORIES(
-#  ${QT_INCLUDES}
-#  ${PROJECT_SOURCE_DIR}/src/cpp
-#)
-
-#ADD_DEFINITIONS(
-#  ${QT_DEFINITIONS}
-#  ${GUI_DEFINITIONS}
-#  ${PYTHON_DEFINITIONS}
-#)
 SET(CMAKE_AUTOMOC ON)
 
 INCLUDE_DIRECTORIES(
@@ -39,27 +28,31 @@ ADD_DEFINITIONS(
   ${PYTHON_DEFINITIONS}
 )
 
-SET(YDEFX_SOURCES
+SET(YDEFXGUI_SOURCES
   ResourceWidget.cxx
   ParamsConfig.cxx
   PathsConfig.cxx
   QuickConfig.cxx
 )
 
-SET(YDEFX_HEADERS
+SET(YDEFXGUI_HEADERS
   ResourceWidget.hxx
 )
 
-SET(YDEFX_link_LIBRARIES
+SET(YDEFXGUI_link_LIBRARIES
   Qt5::Widgets
   ydefx
 )
 
-ADD_LIBRARY(ydefxgui ${YDEFX_SOURCES})
-TARGET_LINK_LIBRARIES(ydefxgui ${YDEFX_link_LIBRARIES})
+ADD_LIBRARY(ydefxgui ${YDEFXGUI_SOURCES})
+TARGET_LINK_LIBRARIES(ydefxgui ${YDEFXGUI_link_LIBRARIES})
 TARGET_INCLUDE_DIRECTORIES(ydefxgui PUBLIC
                           $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/gui>
-                          $<INSTALL_INTERFACE:include>)
+                          $<INSTALL_INTERFACE:${SALOME_INSTALL_HEADERS}>)
 
 ADD_EXECUTABLE(ydefxgui.exe ydefxgui.cxx)
 TARGET_LINK_LIBRARIES(ydefxgui.exe ydefxgui)
+
+INSTALL(TARGETS ydefxgui DESTINATION ${SALOME_INSTALL_LIBS})
+INSTALL(TARGETS ydefxgui EXPORT ydefxCfg_cmake LIBRARY DESTINATION ${SALOME_INSTALL_LIBS})
+INSTALL(FILES ${YDEFXGUI_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}/ydefx)