From 541d4d583aa572893055c42b60b2d8e105200faf Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 17 Apr 2020 17:10:51 +0300 Subject: [PATCH] Include SalomeMacros.cmake with NO_POLICY_SCOPE to apply policies --- CMakeLists.txt | 3 +- tools/CMakeLists.txt | 23 +++--- tools/CurvePlot/CMakeLists.txt | 17 ++--- tools/PyConsole/CMakeLists.txt | 85 +++++++++++++--------- tools/PyConsole/src/CMakeLists.txt | 7 +- tools/PyConsole/src/python/CMakeLists.txt | 2 +- tools/PyEditor/CMakeLists.txt | 88 ++++++++++++----------- tools/PyEditor/src/CMakeLists.txt | 12 ++-- tools/PyEditor/src/python/CMakeLists.txt | 2 +- tools/PyInterp/CMakeLists.txt | 58 +++++++++------ tools/PyInterp/src/CMakeLists.txt | 2 +- tools/RemoteFileBrowser/CMakeLists.txt | 3 +- tools/TODO | 18 +++++ 13 files changed, 182 insertions(+), 138 deletions(-) create mode 100644 tools/TODO diff --git a/CMakeLists.txt b/CMakeLists.txt index ed57a1927..ca5c1a495 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ SET(${PROJECT_NAME_UC}_VERSION_DEV 1) 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") - INCLUDE(SalomeMacros) + INCLUDE(SalomeMacros NO_POLICY_SCOPE) ELSE() MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !") ENDIF() @@ -47,7 +47,6 @@ ENDIF() # =========== SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL") IF(EXISTS ${KERNEL_ROOT_DIR}) - LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files") FIND_PACKAGE(SalomeKERNEL REQUIRED) ADD_DEFINITIONS(${KERNEL_DEFINITIONS}) INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS}) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 14ab59f0c..53cacc3c4 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -24,30 +24,33 @@ ADD_SUBDIRECTORY(dlgfactory) ## IF(SALOME_USE_PYCONSOLE) - # Include sub-project PyConsole: - SET(TOOLS_EXPORT_NAME ${PROJECT_NAME}) + # Include sub-project PyConsole + SET(PYCONSOLE_SUBPROJECT YES CACHE INTERNAL "") + SET(PYINTERP_EXPORT_NAME "${PROJECT_NAME}" CACHE STRING "") + SET(PYCONSOLE_EXPORT_NAME "${PROJECT_NAME}" CACHE STRING "") SET(PYCONSOLE_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "") + SET(PYCONSOLE_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "") SET(PYCONSOLE_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "") SET(PYCONSOLE_INSTALL_RES "${SALOME_GUI_INSTALL_RES_DATA}" CACHE PATH "") - - ADD_SUBDIRECTORY(../tools/PyConsole) # will bring in PyInterp automatically - - ADD_SUBDIRECTORY(CurvePlot) - + SET(PYCONSOLE_INSTALL_CMAKE "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH "") + ADD_SUBDIRECTORY(PyConsole) # brings in PyInterp automatically + ADD_SUBDIRECTORY(CurvePlot) # to be refactored (CurvePlot does not directly depend on PyConsole) ENDIF(SALOME_USE_PYCONSOLE) IF(SALOME_USE_PYVIEWER) - # Include sub-project PyEditor: - SET(TOOLS_EXPORT_NAME ${PROJECT_NAME}) + # Include sub-project PyEditor + SET(PYEDITOR_SUBPROJECT YES CACHE INTERNAL "") + SET(PYEDITOR_EXPORT_NAME "${PROJECT_NAME}" CACHE STRING "") SET(PYEDITOR_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "") SET(PYEDITOR_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "") + SET(PYEDITOR_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "") SET(PYEDITOR_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "") SET(PYEDITOR_INSTALL_RES "${SALOME_GUI_INSTALL_RES_DATA}" CACHE PATH "") + SET(PYEDITOR_INSTALL_CMAKE "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH "") ADD_SUBDIRECTORY(PyEditor) ENDIF(SALOME_USE_PYVIEWER) IF(COMPILER_SUPPORTS_CXX11) - SET(TOOLS_EXPORT_NAME ${PROJECT_NAME}) SET(REMOTEFILEBROWSER_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "") SET(REMOTEFILEBROWSER_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "") SET(REMOTEFILEBROWSER_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "") diff --git a/tools/CurvePlot/CMakeLists.txt b/tools/CurvePlot/CMakeLists.txt index 2921c3a00..f6dc0048c 100644 --- a/tools/CurvePlot/CMakeLists.txt +++ b/tools/CurvePlot/CMakeLists.txt @@ -44,7 +44,7 @@ OPTION(SALOME_BUILD_TESTS "Generate SALOME CURVEPLOT tests" ON) 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") - INCLUDE(SalomeMacros) + INCLUDE(SalomeMacros NO_POLICY_SCOPE) ELSE() MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !") ENDIF() @@ -54,7 +54,6 @@ IF(NOT SALOME_CURVEPLOT_STANDALONE) # ============== SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL") IF( EXISTS ${KERNEL_ROOT_DIR} ) - LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files") FIND_PACKAGE(SalomeKERNEL REQUIRED) KERNEL_WITH_CORBA() # check whether KERNEL builded with CORBA ADD_DEFINITIONS(${KERNEL_DEFINITIONS} -DSALOME_KERNEL) @@ -67,33 +66,27 @@ IF(NOT SALOME_CURVEPLOT_STANDALONE) SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI") # Are we compiled being into GUI/tools directory or have we been extracted somewhere else? IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../src/Session/SALOME_Session.hxx") # we are in GUI - LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../adm_local/cmake_files") # Re-define GUI_INCLUDE_DIRS SET(GUI_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../PyInterp/src) ELSE() IF(EXISTS ${GUI_ROOT_DIR}) - LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files") FIND_PACKAGE(SalomeGUI) ELSE() MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR or turn option SALOME_CURVEPLOT_STANDALONE to ON!") ENDIF() ENDIF() - # Platform setup - # ============== - INCLUDE(SalomeSetupPlatform) # From KERNEL ENDIF(NOT SALOME_CURVEPLOT_STANDALONE) +# Platform setup +# ============== +INCLUDE(SalomeSetupPlatform) + # Always build libraries as shared objects: SET(BUILD_SHARED_LIBS TRUE) # Local macros: LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files") -IF(SALOME_CURVEPLOT_STANDALONE) - INCLUDE(SalomeMacros) -ENDIF() - - # Prerequisites # ============= # Find "big" prerequisites first - they reference themselves many others diff --git a/tools/PyConsole/CMakeLists.txt b/tools/PyConsole/CMakeLists.txt index 1b91bb46b..a231bede3 100644 --- a/tools/PyConsole/CMakeLists.txt +++ b/tools/PyConsole/CMakeLists.txt @@ -22,21 +22,19 @@ PROJECT(PyConsole C CXX) # Versioning # =========== -# Project name, upper case +# Project name, uppercase / lowercase STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC) +STRING(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LC) -################### -# To be changed once externalized CMake procedure: -SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL") -IF(EXISTS ${KERNEL_ROOT_DIR}) - LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files") - INCLUDE(SalomeMacros) -ELSE(EXISTS ${KERNEL_ROOT_DIR}) - MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR") -ENDIF(EXISTS ${KERNEL_ROOT_DIR}) -# From GUI - again to be changed once externalized: -LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../../adm_local/cmake_files") -################### +# Include common macros +# ===================== +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") + INCLUDE(SalomeMacros NO_POLICY_SCOPE) +ELSE() + MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !") +ENDIF() # Platform setup # ============== @@ -44,50 +42,67 @@ INCLUDE(SalomeSetupPlatform) # Options # ======= -OPTION(PYCONSOLE_BUILD_PYTHON "Build Python wrapping for PyConsole" ON) +OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON) +OPTION(BUILD_PYMODULE "Build Python module" ON) -# -# Set list of prerequisites -# ========================= +# Detect prerequisites +# ==================== +# Python FIND_PACKAGE(SalomePythonInterp REQUIRED) FIND_PACKAGE(SalomePythonLibs REQUIRED) - # Qt FIND_PACKAGE(SalomeQt5 REQUIRED) -IF(PYCONSOLE_BUILD_PYTHON) - # Sip - FIND_PACKAGE(SalomeSIP REQUIRED) # should come after Python and before PyQt - SALOME_LOG_OPTIONAL_PACKAGE(SalomeSIP PYCONSOLE_BUILD_PYTHON) +IF(BUILD_PYMODULE) + # Sip (should come after Python and before PyQt) + FIND_PACKAGE(SalomeSIP REQUIRED) + SALOME_LOG_OPTIONAL_PACKAGE(SalomeSIP BUILD_PYMODULE) # PyQt FIND_PACKAGE(SalomePyQt5 REQUIRED) - SALOME_LOG_OPTIONAL_PACKAGE(SalomePyQt5 PYCONSOLE_BUILD_PYTHON) -ENDIF(PYCONSOLE_BUILD_PYTHON) + SALOME_LOG_OPTIONAL_PACKAGE(SalomePyQt5 BUILD_PYMODULE) +ENDIF(BUILD_PYMODULE) -# Detection report +# Detection summary report SALOME_PACKAGE_REPORT_AND_CHECK() # Directories # # Directories have to be given after prerequisites (to be able to use # Python version string for example). -# =========== -SET(PYCONSOLE_INSTALL_LIBS lib CACHE PATH "Install path: PyConsole libs") -SET(PYCONSOLE_INSTALL_HEADERS include CACHE PATH "Install path: PyConsole headers") +# =================================================================== +SET(PYCONSOLE_INSTALL_LIBS lib CACHE PATH "Install path: libraries") +SET(PYCONSOLE_INSTALL_PYTHON lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages CACHE PATH "Install path: Python module") +SET(PYCONSOLE_INSTALL_HEADERS include CACHE PATH "Install path: headers") +SET(PYCONSOLE_INSTALL_RES share/resources CACHE PATH "Install path: resources") +SET(PYCONSOLE_INSTALL_CMAKE lib/cmake/${PROJECT_NAME_LC} CACHE PATH "Install path: cmake files") -SET(PYCONSOLE_INSTALL_RES share/resources CACHE PATH "Install path: PyConsole resources") +MARK_AS_ADVANCED(PYCONSOLE_INSTALL_LIBS PYCONSOLE_INSTALL_HEADERS + PYCONSOLE_INSTALL_RES PYCONSOLE_INSTALL_CMAKE) -# Tool dependencies -# ================= -# PyConsole depends on PyInterp: -SET(PYINTERP_INSTALL_LIBS "${PYCONSOLE_INSTALL_LIBS}" CACHE PATH "") +SET(PYCONSOLE_EXPORT_NAME ${PROJECT_NAME} CACHE STRING "Export name") +MARK_AS_ADVANCED(PYCONSOLE_EXPORT_NAME) + +# Dependencies +# ============ +# Force PyInterp to build as a sub-project +SET(PYINTERP_SUBPROJECT YES CACHE INTERNAL "") +SET(PYINTERP_EXPORT_NAME "${PROJECT_NAME}" CACHE STRING "") +SET(PYINTERP_INSTALL_LIBS "${PYCONSOLE_INSTALL_LIBS}" CACHE PATH "") SET(PYINTERP_INSTALL_HEADERS "${PYCONSOLE_INSTALL_HEADERS}" CACHE PATH "") SET(PYINTERP_INSTALL_RES "${PYCONSOLE_INSTALL_RES}" CACHE PATH "") +SET(PYINTERP_INSTALL_CMAKE "${PYCONSOLE_INSTALL_CMAK}" CACHE PATH "") ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/../PyInterp ${PROJECT_BINARY_DIR}/PyInterp) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/../PyInterp/src) -# Sources -# ======== +# Subdirs +# ======= ADD_SUBDIRECTORY(src) +# Export configuration and targets +# ================================ +IF(NOT PYCONSOLE_SUBPROJECT) + # Install the export set for use with the install-tree + INSTALL(EXPORT ${PYCONSOLE_EXPORT_NAME}TargetGroup DESTINATION ${PYCONSOLE_INSTALL_CMAKE} + FILE ${PROJECT_NAME}Targets.cmake) +ENDIF() diff --git a/tools/PyConsole/src/CMakeLists.txt b/tools/PyConsole/src/CMakeLists.txt index 826b64696..5b7f45aa4 100644 --- a/tools/PyConsole/src/CMakeLists.txt +++ b/tools/PyConsole/src/CMakeLists.txt @@ -19,9 +19,9 @@ INCLUDE(UseQtExt) -IF(PYCONSOLE_BUILD_PYTHON) +IF(BUILD_PYMODULE) ADD_SUBDIRECTORY(python) -ENDIF(PYCONSOLE_BUILD_PYTHON) +ENDIF(BUILD_PYMODULE) # --- options --- @@ -29,7 +29,6 @@ ENDIF(PYCONSOLE_BUILD_PYTHON) INCLUDE_DIRECTORIES( ${QT_INCLUDES} ${PYTHON_INCLUDE_DIRS} - ${PROJECT_SOURCE_DIR}/src/PyInterp ) # additional preprocessor / compiler flags @@ -87,7 +86,7 @@ SET(PyConsole_SOURCES ${_other_SOURCES} ${_moc_SOURCES}) ADD_LIBRARY(PyConsole ${PyConsole_SOURCES}) TARGET_LINK_LIBRARIES(PyConsole ${_link_LIBRARIES}) -INSTALL(TARGETS PyConsole EXPORT ${TOOLS_EXPORT_NAME}TargetGroup DESTINATION ${PYCONSOLE_INSTALL_LIBS}) +INSTALL(TARGETS PyConsole EXPORT ${PYCONSOLE_EXPORT_NAME}TargetGroup DESTINATION ${PYCONSOLE_INSTALL_LIBS}) INSTALL(FILES ${PyConsole_HEADERS} DESTINATION ${PYCONSOLE_INSTALL_HEADERS}) QT_INSTALL_TS_RESOURCES("${_ts_RESOURCES}" "${PYCONSOLE_INSTALL_RES}") diff --git a/tools/PyConsole/src/python/CMakeLists.txt b/tools/PyConsole/src/python/CMakeLists.txt index 8c78c7729..d5e301350 100644 --- a/tools/PyConsole/src/python/CMakeLists.txt +++ b/tools/PyConsole/src/python/CMakeLists.txt @@ -59,4 +59,4 @@ ELSE() SET_TARGET_PROPERTIES(PyConsolePy PROPERTIES PREFIX "") ENDIF() TARGET_LINK_LIBRARIES(PyConsolePy ${_link_LIBRARIES}) -INSTALL(TARGETS PyConsolePy EXPORT ${TOOLS_EXPORT_NAME}TargetGroup DESTINATION ${PYCONSOLE_INSTALL_LIBS}) +INSTALL(TARGETS PyConsolePy EXPORT ${PYCONSOLE_EXPORT_NAME}TargetGroup DESTINATION ${PYCONSOLE_INSTALL_PYTHON}) diff --git a/tools/PyEditor/CMakeLists.txt b/tools/PyEditor/CMakeLists.txt index 018124bd0..9d5c0d64d 100644 --- a/tools/PyEditor/CMakeLists.txt +++ b/tools/PyEditor/CMakeLists.txt @@ -22,21 +22,19 @@ PROJECT(PyEditor C CXX) # Versioning # =========== -# Project name, upper case +# Project name, uppercase / lowercase STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC) +STRING(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LC) -# To be changed once externalized CMake procedure: -################### -SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL") -IF(EXISTS ${KERNEL_ROOT_DIR}) - LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files") - INCLUDE(SalomeMacros) -ELSE(EXISTS ${KERNEL_ROOT_DIR}) - MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR") -ENDIF(EXISTS ${KERNEL_ROOT_DIR}) -# From GUI - again to be changed once externalized: -LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../../adm_local/cmake_files") -################### +# Include common macros +# ===================== +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") + INCLUDE(SalomeMacros NO_POLICY_SCOPE) +ELSE() + MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !") +ENDIF() # Platform setup # ============== @@ -44,50 +42,58 @@ INCLUDE(SalomeSetupPlatform) # Options # ======= -OPTION(PYEDITOR_BUILD_SHARED_LIBS "Build shared libraries for PyEditor" ON) -OPTION(PYEDITOR_BUILD_EXE "Build PyEditor's executable" ON) -OPTION(PYEDITOR_BUILD_PYTHON "Build Python wrapping for PyEditor" ON) +OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON) +OPTION(BUILD_EXECUTABLE "Build executable" ON) +OPTION(BUILD_PYMODULE "Build Python module" ON) -# -# Set list of prerequisites -# ========================= - -IF(PYEDITOR_BUILD_SHARED_LIBS) - SET(BUILD_SHARED_LIBS TRUE) -ELSE(PYEDITOR_BUILD_SHARED_LIBS) - SET(BUILD_SHARED_LIBS FALSE) -ENDIF(PYEDITOR_BUILD_SHARED_LIBS) +# Detect prerequisites +# ==================== # Qt FIND_PACKAGE(SalomeQt5 REQUIRED) -IF(PYEDITOR_BUILD_PYTHON) +IF(BUILD_PYMODULE) # Python FIND_PACKAGE(SalomePythonInterp REQUIRED) FIND_PACKAGE(SalomePythonLibs REQUIRED) - SALOME_LOG_OPTIONAL_PACKAGE(SalomePythonInterp PYEDITOR_BUILD_PYTHON) - SALOME_LOG_OPTIONAL_PACKAGE(SalomePythonLibs PYEDITOR_BUILD_PYTHON) - # Sip - FIND_PACKAGE(SalomeSIP REQUIRED) # should come after Python and before PyQt - SALOME_LOG_OPTIONAL_PACKAGE(SalomeSIP PYEDITOR_BUILD_PYTHON) + SALOME_LOG_OPTIONAL_PACKAGE(SalomePythonInterp BUILD_PYMODULE) + SALOME_LOG_OPTIONAL_PACKAGE(SalomePythonLibs BUILD_PYMODULE) + # Sip (should come after Python and before PyQt) + FIND_PACKAGE(SalomeSIP REQUIRED) + SALOME_LOG_OPTIONAL_PACKAGE(SalomeSIP BUILD_PYMODULE) # PyQt FIND_PACKAGE(SalomePyQt5 REQUIRED) - SALOME_LOG_OPTIONAL_PACKAGE(SalomePyQt5 PYEDITOR_BUILD_PYTHON) -ENDIF(PYEDITOR_BUILD_PYTHON) + SALOME_LOG_OPTIONAL_PACKAGE(SalomePyQt5 BUILD_PYMODULE) +ENDIF(BUILD_PYMODULE) -# Detection report +# Detection summary report SALOME_PACKAGE_REPORT_AND_CHECK() # Directories # # Directories have to be given after prerequisites (to be able to use # Python version string for example). -# =========== -SET(PYEDITOR_INSTALL_BINS bin CACHE PATH "Install path: PyEditor binaries") -SET(PYEDITOR_INSTALL_LIBS lib CACHE PATH "Install path: PyEditor libraries") -SET(PYEDITOR_INSTALL_HEADERS include CACHE PATH "Install path: PyEditor headers") -SET(PYEDITOR_INSTALL_RES share/resources CACHE PATH "Install path: PyEditor resources") +# =================================================================== +SET(PYEDITOR_INSTALL_BINS bin CACHE PATH "Install path: binaries") +SET(PYEDITOR_INSTALL_LIBS lib CACHE PATH "Install path: libraries") +SET(PYEDITOR_INSTALL_PYTHON lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages CACHE PATH "Install path: Python module") +SET(PYEDITOR_INSTALL_HEADERS include CACHE PATH "Install path: headers") +SET(PYEDITOR_INSTALL_RES share/resources CACHE PATH "Install path: resources") +SET(PYEDITOR_INSTALL_CMAKE lib/cmake/${PROJECT_NAME_LC} CACHE PATH "Install path: cmake files") -# Sources -# ======== +MARK_AS_ADVANCED(PYEDITOR_INSTALL_BINS PYEDITOR_INSTALL_LIBS PYEDITOR_INSTALL_PYTHON + PYEDITOR_INSTALL_HEADERS PYEDITOR_INSTALL_RES PYEDITOR_INSTALL_CMAKE) + +SET(PYEDITOR_EXPORT_NAME ${PROJECT_NAME} CACHE STRING "Export name") +MARK_AS_ADVANCED(PYEDITOR_EXPORT_NAME) + +# Subdirs +# ======= ADD_SUBDIRECTORY(src) +# Export configuration and targets +# ================================ +IF(NOT PYEDITOR_SUBPROJECT) + # Install the export set for use with the install-tree + INSTALL(EXPORT ${PYEDITOR_EXPORT_NAME}TargetGroup DESTINATION ${PYEDITOR_INSTALL_CMAKE} + FILE ${PROJECT_NAME}Targets.cmake) +ENDIF() diff --git a/tools/PyEditor/src/CMakeLists.txt b/tools/PyEditor/src/CMakeLists.txt index f7bfb9d2f..f9f180d4f 100644 --- a/tools/PyEditor/src/CMakeLists.txt +++ b/tools/PyEditor/src/CMakeLists.txt @@ -21,9 +21,9 @@ INCLUDE(UseQtExt) -IF(PYEDITOR_BUILD_PYTHON) +IF(BUILD_PYMODULE) ADD_SUBDIRECTORY(python) -ENDIF(PYEDITOR_BUILD_PYTHON) +ENDIF(BUILD_PYMODULE) # --- options --- @@ -108,15 +108,15 @@ SET(pyeditorexe_SOURCES ${PyEditor_SOURCES} PyEditor.cxx) ADD_LIBRARY(PyEditor ${PyEditor_SOURCES}) TARGET_LINK_LIBRARIES(PyEditor ${_link_LIBRARIES}) -INSTALL(TARGETS PyEditor EXPORT ${TOOLS_EXPORT_NAME}TargetGroup DESTINATION ${PYEDITOR_INSTALL_LIBS}) +INSTALL(TARGETS PyEditor EXPORT ${PYEDITOR_EXPORT_NAME}TargetGroup DESTINATION ${PYEDITOR_INSTALL_LIBS}) -IF(PYEDITOR_BUILD_EXE) +IF(BUILD_EXECUTABLE) ADD_EXECUTABLE(pyeditorexe ${pyeditorexe_SOURCES}) SET_TARGET_PROPERTIES(pyeditorexe PROPERTIES OUTPUT_NAME "pyeditor") TARGET_LINK_LIBRARIES(pyeditorexe ${_link_LIBRARIES}) TARGET_COMPILE_DEFINITIONS(pyeditorexe PUBLIC "-DPYEDITOREXE") - INSTALL(TARGETS pyeditorexe EXPORT ${TOOLS_EXPORT_NAME}TargetGroup DESTINATION ${PYEDITOR_INSTALL_BINS}) -ENDIF(PYEDITOR_BUILD_EXE) + INSTALL(TARGETS pyeditorexe EXPORT ${PYEDITOR_EXPORT_NAME}TargetGroup DESTINATION ${PYEDITOR_INSTALL_BINS}) +ENDIF(BUILD_EXECUTABLE) INSTALL(FILES ${PyEditor_HEADERS} DESTINATION ${PYEDITOR_INSTALL_HEADERS}) QT_INSTALL_TS_RESOURCES("${_ts_RESOURCES}" "${PYEDITOR_INSTALL_RES}") diff --git a/tools/PyEditor/src/python/CMakeLists.txt b/tools/PyEditor/src/python/CMakeLists.txt index 4339a1e19..3db1dd4b8 100644 --- a/tools/PyEditor/src/python/CMakeLists.txt +++ b/tools/PyEditor/src/python/CMakeLists.txt @@ -59,4 +59,4 @@ ELSE() SET_TARGET_PROPERTIES(PyEditorPy PROPERTIES PREFIX "") ENDIF() TARGET_LINK_LIBRARIES(PyEditorPy ${_link_LIBRARIES}) -INSTALL(TARGETS PyEditorPy EXPORT ${TOOLS_EXPORT_NAME}TargetGroup DESTINATION ${PYEDITOR_INSTALL_LIBS}) +INSTALL(TARGETS PyEditorPy EXPORT ${PYEDITOR_EXPORT_NAME}TargetGroup DESTINATION ${PYEDITOR_INSTALL_PYTHON}) diff --git a/tools/PyInterp/CMakeLists.txt b/tools/PyInterp/CMakeLists.txt index 55a496784..ff56d2517 100644 --- a/tools/PyInterp/CMakeLists.txt +++ b/tools/PyInterp/CMakeLists.txt @@ -22,21 +22,19 @@ PROJECT(PyInterp C CXX) # Versioning # =========== -# Project name, upper case +# Project name, uppercase / lowercase STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC) +STRING(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LC) -# To be changed once externalized CMake procedure: -################### -SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL") -IF(EXISTS ${KERNEL_ROOT_DIR}) - LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files") - INCLUDE(SalomeMacros) -ELSE(EXISTS ${KERNEL_ROOT_DIR}) - MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR") -ENDIF(EXISTS ${KERNEL_ROOT_DIR}) -# From GUI - again to be changed once externalized: -LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../../adm_local/cmake_files") -################### +# Include common macros +# ===================== +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") + INCLUDE(SalomeMacros NO_POLICY_SCOPE) +ELSE() + MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !") +ENDIF() # Platform setup # ============== @@ -44,30 +42,44 @@ INCLUDE(SalomeSetupPlatform) # Options # ======= +OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON) -# -# Set list of prerequisites -# ========================= +# Detect prerequisites +# ==================== +# Python FIND_PACKAGE(SalomePythonInterp REQUIRED) FIND_PACKAGE(SalomePythonLibs REQUIRED) # Qt FIND_PACKAGE(SalomeQt5 REQUIRED) -# Detection report +# Detection summary report SALOME_PACKAGE_REPORT_AND_CHECK() # Directories # # Directories have to be given after prerequisites (to be able to use # Python version string for example). -# =========== -SET(PYINTERP_INSTALL_LIBS lib CACHE PATH "Install path: PyInterp libs") -SET(PYINTERP_INSTALL_HEADERS include CACHE PATH "Install path: PyInterp headers") +# =================================================================== +SET(PYINTERP_INSTALL_LIBS lib CACHE PATH "Install path: libraries") +SET(PYINTERP_INSTALL_HEADERS include CACHE PATH "Install path: headers") +SET(PYINTERP_INSTALL_RES share/resources CACHE PATH "Install path: resources") +SET(PYINTERP_INSTALL_CMAKE lib/cmake/${PROJECT_NAME_LC} CACHE PATH "Install path: cmake files") -SET(PYINTERP_INSTALL_RES share/resources CACHE PATH "Install path: PyInterp resources") +MARK_AS_ADVANCED(PYINTERP_INSTALL_LIBS PYINTERP_INSTALL_HEADERS + PYINTERP_INSTALL_RES PYINTERP_INSTALL_CMAKE) -# Sources -# ======== +SET(PYINTERP_EXPORT_NAME ${PROJECT_NAME} CACHE STRING "Export name") +MARK_AS_ADVANCED(PYINTERP_EXPORT_NAME) + +# Subdirs +# ======= ADD_SUBDIRECTORY(src) +# Export configuration and targets +# ================================ +IF(NOT PYINTERP_SUBPROJECT) + # Install the export set for use with the install-tree + INSTALL(EXPORT ${PYINTERP_EXPORT_NAME}TargetGroup DESTINATION ${PYINTERP_INSTALL_CMAKE} + FILE ${PROJECT_NAME}Targets.cmake) +ENDIF() diff --git a/tools/PyInterp/src/CMakeLists.txt b/tools/PyInterp/src/CMakeLists.txt index 523c8b13b..cbfb14085 100644 --- a/tools/PyInterp/src/CMakeLists.txt +++ b/tools/PyInterp/src/CMakeLists.txt @@ -73,6 +73,6 @@ SET(PyInterp_SOURCES ${_other_SOURCES} ${_moc_SOURCES}) ADD_LIBRARY(PyInterp ${PyInterp_SOURCES}) TARGET_LINK_LIBRARIES(PyInterp ${_link_LIBRARIES}) -INSTALL(TARGETS PyInterp EXPORT ${TOOLS_EXPORT_NAME}TargetGroup DESTINATION ${PYINTERP_INSTALL_LIBS}) +INSTALL(TARGETS PyInterp EXPORT ${PYINTERP_EXPORT_NAME}TargetGroup DESTINATION ${PYINTERP_INSTALL_LIBS}) INSTALL(FILES ${PyInterp_HEADERS} DESTINATION ${PYINTERP_INSTALL_HEADERS}) diff --git a/tools/RemoteFileBrowser/CMakeLists.txt b/tools/RemoteFileBrowser/CMakeLists.txt index 005efe376..d1d69fe9c 100644 --- a/tools/RemoteFileBrowser/CMakeLists.txt +++ b/tools/RemoteFileBrowser/CMakeLists.txt @@ -24,7 +24,7 @@ PROJECT(RemoteFileBrowser CXX) SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake files") IF(EXISTS ${CONFIGURATION_ROOT_DIR}) LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake") - INCLUDE(SalomeMacros) + INCLUDE(SalomeMacros NO_POLICY_SCOPE) ELSE() MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !") ENDIF() @@ -35,7 +35,6 @@ SET(REMOTEFILEBROWSER_INSTALL_HEADERS include CACHE PATH "Install path: RemoteFi INCLUDE(SalomeSetupPlatform) SET(BUILD_SHARED_LIBS TRUE) -INCLUDE(SalomeMacros) FIND_PACKAGE(SalomeQt5 REQUIRED) INCLUDE(UseQtExt) INCLUDE_DIRECTORIES( diff --git a/tools/TODO b/tools/TODO new file mode 100644 index 000000000..751e8a790 --- /dev/null +++ b/tools/TODO @@ -0,0 +1,18 @@ +1. Each sub-project must export its own configuration. + +2. When building as sub-projects within SALOME GUI top-level project, + targets file can be directly included from the GUI main configuration. + Or, alternatively, find_package(sub-project) must be called from + GUI main configuration file, similarly to other pre-requisites. + +3. As soon as (1) and (2) are done, refactor sub-projects to: + * Include other sub-projects recursively, following this approach, + for example, SalomeGUI -> PyConsole -> PyInterp. + * CurvePlot should become independent project, probably depending + on PyInterp. Also, it seems reasonable to avoid this direct + dependency as it is minimal de facto and needed features can be + achieved by simple copy-paste. + * Due to this refactoring, direct inclusion of PyInterp to PyConsole + via add_subdirectory() will be not needed anymore. + +4. Export targets for RemoteFileBrowser. -- 2.39.2