Salome HOME
d76fdb27613caca20783c35d1477c4af78785fdd
[modules/gui.git] / tools / PyConsole / CMakeLists.txt
1 # Copyright (C) 2015-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
21 PROJECT(PyConsole C CXX)
22
23 # Versioning
24 # ===========
25 # Project name, uppercase / lowercase
26 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
27 STRING(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LC)
28
29 # Include common macros
30 # =====================
31 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
32 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
33   LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
34   INCLUDE(SalomeMacros NO_POLICY_SCOPE)
35 ELSE()
36   MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
37 ENDIF()
38
39 # Platform setup
40 # ==============
41 INCLUDE(SalomeSetupPlatform)
42
43 # Options
44 # =======
45 OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON)
46 OPTION(BUILD_PYMODULE "Build Python module" ON)
47
48 # Detect prerequisites
49 # ====================
50
51 # Python
52 FIND_PACKAGE(SalomePythonInterp REQUIRED)
53 FIND_PACKAGE(SalomePythonLibs REQUIRED)
54 # Qt
55 FIND_PACKAGE(SalomeQt5 REQUIRED)
56 IF(BUILD_PYMODULE)
57   # Sip (should come after Python and before PyQt)
58   FIND_PACKAGE(SalomeSIP REQUIRED)
59   SALOME_LOG_OPTIONAL_PACKAGE(SalomeSIP BUILD_PYMODULE)
60   # PyQt
61   FIND_PACKAGE(SalomePyQt5 REQUIRED)
62   SALOME_LOG_OPTIONAL_PACKAGE(SalomePyQt5 BUILD_PYMODULE)
63 ENDIF(BUILD_PYMODULE)
64
65 # Detection summary report
66 SALOME_PACKAGE_REPORT_AND_CHECK()
67
68 # Directories
69 #
70 # Directories have to be given after prerequisites (to be able to use
71 # Python version string for example).
72 # ===================================================================
73 SET(PYCONSOLE_INSTALL_LIBS lib CACHE PATH "Install path: libraries")
74 SET(PYCONSOLE_INSTALL_PYTHON lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages CACHE PATH "Install path: Python module")
75 SET(PYCONSOLE_INSTALL_HEADERS include CACHE PATH "Install path: headers")
76 SET(PYCONSOLE_INSTALL_RES share/resources CACHE PATH "Install path: resources")
77 SET(PYCONSOLE_INSTALL_CMAKE lib/cmake/${PROJECT_NAME_LC} CACHE PATH "Install path: cmake files")
78
79 MARK_AS_ADVANCED(PYCONSOLE_INSTALL_LIBS PYCONSOLE_INSTALL_HEADERS
80                  PYCONSOLE_INSTALL_RES PYCONSOLE_INSTALL_CMAKE)
81
82 SET(PYCONSOLE_EXPORT_NAME ${PROJECT_NAME} CACHE STRING "Export name")
83 MARK_AS_ADVANCED(PYCONSOLE_EXPORT_NAME)
84
85 # Dependencies
86 # ============
87 # Force PyInterp to build as a sub-project
88 SET(PYINTERP_SUBPROJECT YES CACHE INTERNAL "")
89 SET(PYINTERP_EXPORT_NAME "${PROJECT_NAME}" CACHE STRING "")
90 SET(PYINTERP_INSTALL_LIBS "${PYCONSOLE_INSTALL_LIBS}" CACHE PATH "")
91 SET(PYINTERP_INSTALL_HEADERS "${PYCONSOLE_INSTALL_HEADERS}" CACHE PATH "")
92 SET(PYINTERP_INSTALL_RES "${PYCONSOLE_INSTALL_RES}" CACHE PATH "")
93 SET(PYINTERP_INSTALL_CMAKE "${PYCONSOLE_INSTALL_CMAK}" CACHE PATH "")
94
95 ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/../PyInterp ${PROJECT_BINARY_DIR}/PyInterp)
96 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/../PyInterp/src)
97
98 # Subdirs
99 # =======
100 ADD_SUBDIRECTORY(src)
101
102 # Export configuration and targets
103 # ================================
104 IF(NOT PYCONSOLE_SUBPROJECT)
105   # Install the export set for use with the install-tree
106   INSTALL(EXPORT ${PYCONSOLE_EXPORT_NAME}TargetGroup DESTINATION ${PYCONSOLE_INSTALL_CMAKE}
107           FILE ${PROJECT_NAME}Targets.cmake)
108 ENDIF()