From: Ovidiu Mircescu Date: Fri, 22 Feb 2019 15:51:34 +0000 (+0100) Subject: Work on cmake. X-Git-Tag: V9_3_0rc1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=38c7c8872ca7beb4b323ecd0918331bd48ccb71f;p=tools%2Fydefx.git Work on cmake. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bd80fa..eed83b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index b5e28c0..841f83f 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -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 $ - $) + $) -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) diff --git a/src/cpp/TMonoPyJob.hxx b/src/cpp/TMonoPyJob.hxx index 9206c9b..93966a7 100644 --- a/src/cpp/TMonoPyJob.hxx +++ b/src/cpp/TMonoPyJob.hxx @@ -84,7 +84,7 @@ public: { py2cpp::PyFunction pyFn; pyFn.loadExp(_pyStudy, "getResult"); - fetchResults(_pyStudy.getAttr("sample"), _sample); + fetchResults(pyFn(), _sample); } catch(std::exception& e) { diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 62bfc34..b91514b 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -17,17 +17,6 @@ # 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 $ - $) + $) 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)