Salome HOME
Update licence.
[tools/ydefx.git] / CMakeLists.txt
1 # Copyright (C) 2019-2021 EDF R&D
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 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
20 PROJECT(ydefx)
21
22 SET (CMAKE_CXX_STANDARD 11)
23 ENABLE_TESTING()
24 SET(BUILD_SHARED_LIBS TRUE)
25
26 OPTION(YDEFX_BUILD_GUI "Generate widgets" ON)
27
28 FIND_PACKAGE(Py2cpp REQUIRED)
29
30 # SalomeKERNEL can be useful in order to define SALOME_INSTALL directories and
31 # for using salome test, but it is not a c++ dependency.
32 FIND_PACKAGE(SalomeKERNEL NO_MODULE)
33
34 IF(NOT SalomeKERNEL_FOUND)
35   MESSAGE("SalomeKERNEL not found. Salome installation paths will not be used")
36 ELSE()
37   SET(SALOME_BUILD_TESTS ON)
38   SET(SALOME_YDEFX_INSTALL_TEST ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test CACHE PATH
39       "Install path: SALOME Test files")
40 ENDIF()
41
42 IF(NOT DEFINED SALOME_INSTALL_PYTHON)
43   EXECUTE_PROCESS ( COMMAND ${PYTHON_EXECUTABLE} -c
44   "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))"
45                         OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
46                         RESULT_VARIABLE _PYTHON_pythonlib_result
47                         OUTPUT_STRIP_TRAILING_WHITESPACE )
48
49   IF (_PYTHON_pythonlib_result)
50     MESSAGE (SEND_ERROR "Could not set SALOME_INSTALL_PYTHON!")
51   ENDIF ()
52   GET_FILENAME_COMPONENT(_ABS_PYTHON_MODULE_PATH
53                          ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE)
54   FILE(RELATIVE_PATH SALOME_INSTALL_PYTHON
55                      ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH})
56 ENDIF(NOT DEFINED SALOME_INSTALL_PYTHON)
57
58 IF(NOT DEFINED SALOME_INSTALL_BINS)
59   SET(SALOME_INSTALL_BINS "bin")
60 ENDIF()
61 IF(NOT DEFINED SALOME_INSTALL_LIBS)
62   SET(SALOME_INSTALL_LIBS "lib")
63 ENDIF()
64 IF(NOT DEFINED SALOME_INSTALL_HEADERS)
65   SET(SALOME_INSTALL_HEADERS "include")
66 ENDIF()
67 IF(NOT DEFINED SALOME_INSTALL_CMAKE)
68   SET(SALOME_INSTALL_CMAKE "lib/cmake/ydefx")
69 ENDIF()
70
71 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Path to install Python files")
72 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Path to install binary files")
73 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Path to install libraries")
74 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Path to install headers")
75 SET(SALOME_INSTALL_CMAKE "${SALOME_INSTALL_CMAKE}" CACHE PATH "Path to install cmake configuration files")
76
77 # there are some problems if the configuration tools are included before the
78 # detection of py2cpp and SalomeKERNEL
79 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
80 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
81   LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
82   INCLUDE(SalomeMacros)
83   INCLUDE(SalomeSetupPlatform)
84 ELSE()
85   MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !"
86 )
87 ENDIF()
88
89 FIND_PACKAGE(SalomePythonInterp REQUIRED)
90 FIND_PACKAGE(SalomePythonLibs REQUIRED)
91
92 IF(YDEFX_BUILD_GUI)
93   FIND_PACKAGE(Qt5Widgets CONFIG REQUIRED)
94 ENDIF(YDEFX_BUILD_GUI)
95
96 ADD_SUBDIRECTORY(src)
97
98 INSTALL(EXPORT ydefxCfg_cmake DESTINATION ${SALOME_INSTALL_CMAKE} FILE ydefxConfig.cmake)