Salome HOME
2f88f377f193e0198a537f8b5eeffa579e7c4a65
[modules/gui.git] / tools / PyEditor / CMakeLists.txt
1 # Copyright (C) 2015-2022  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(PyEditor 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_EXECUTABLE "Build executable" ON)
47 OPTION(BUILD_PYMODULE "Build Python module" ON)
48
49 # Detect prerequisites
50 # ====================
51
52 # Qt
53 FIND_PACKAGE(SalomeQt5 REQUIRED)
54 IF(BUILD_PYMODULE)
55   # Python
56   FIND_PACKAGE(SalomePythonInterp REQUIRED)
57   FIND_PACKAGE(SalomePythonLibs REQUIRED)
58   SALOME_LOG_OPTIONAL_PACKAGE(SalomePythonInterp BUILD_PYMODULE)
59   SALOME_LOG_OPTIONAL_PACKAGE(SalomePythonLibs BUILD_PYMODULE)
60   # Sip (should come after Python and before PyQt)
61   FIND_PACKAGE(SalomeSIP REQUIRED)
62   SALOME_LOG_OPTIONAL_PACKAGE(SalomeSIP BUILD_PYMODULE)
63   # PyQt
64   FIND_PACKAGE(SalomePyQt5 REQUIRED)
65   SALOME_LOG_OPTIONAL_PACKAGE(SalomePyQt5 BUILD_PYMODULE)
66 ENDIF(BUILD_PYMODULE)
67
68 # Detection summary report
69 SALOME_PACKAGE_REPORT_AND_CHECK()
70
71 # Directories
72 #
73 # Directories have to be given after prerequisites (to be able to use
74 # Python version string for example).
75 # ===================================================================
76 SET(PYEDITOR_INSTALL_BINS bin CACHE PATH "Install path: binaries")
77 SET(PYEDITOR_INSTALL_LIBS lib CACHE PATH "Install path: libraries")
78 SET(PYEDITOR_INSTALL_PYTHON lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages CACHE PATH "Install path: Python module")
79 SET(PYEDITOR_INSTALL_HEADERS include CACHE PATH "Install path: headers")
80 SET(PYEDITOR_INSTALL_RES share/resources CACHE PATH "Install path: resources")
81 SET(PYEDITOR_INSTALL_CMAKE lib/cmake/${PROJECT_NAME_LC} CACHE PATH "Install path: cmake files")
82
83 MARK_AS_ADVANCED(PYEDITOR_INSTALL_BINS PYEDITOR_INSTALL_LIBS PYEDITOR_INSTALL_PYTHON
84                  PYEDITOR_INSTALL_HEADERS PYEDITOR_INSTALL_RES PYEDITOR_INSTALL_CMAKE)
85
86 SET(PYEDITOR_EXPORT_NAME ${PROJECT_NAME} CACHE STRING "Export name")
87 MARK_AS_ADVANCED(PYEDITOR_EXPORT_NAME)
88
89 # Subdirs
90 # =======
91 ADD_SUBDIRECTORY(src)
92
93 # Export configuration and targets
94 # ================================
95 IF(NOT PYEDITOR_SUBPROJECT)
96   # Install the export set for use with the install-tree
97   INSTALL(EXPORT ${PYEDITOR_EXPORT_NAME}TargetGroup DESTINATION ${PYEDITOR_INSTALL_CMAKE}
98           FILE ${PROJECT_NAME}Targets.cmake)
99 ENDIF()