]> SALOME platform Git repositories - samples/pyhello.git/blob - CMakeLists.txt
Salome HOME
e682ba3bbbb1b1a5d2e6fa70b3534a5bf2f04ddc
[samples/pyhello.git] / CMakeLists.txt
1 # Copyright (C) 2012-2016  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 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
20 PROJECT(SalomePYHELLO C CXX)
21
22 # Ensure a proper linker behavior:
23 CMAKE_POLICY(SET CMP0003 NEW)
24
25 # Versioning
26 # ===========
27 # Project name, upper case
28 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
29
30 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 9)
31 SET(${PROJECT_NAME_UC}_MINOR_VERSION 2)
32 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
33 SET(${PROJECT_NAME_UC}_VERSION
34   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
35 SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
36
37 # Common CMake macros
38 # ===================
39 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
40 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
41   LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
42   INCLUDE(SalomeMacros)
43 ELSE()
44   MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
45 ENDIF()
46
47 # Find KERNEL
48 # ===========
49 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
50 IF(EXISTS ${KERNEL_ROOT_DIR})
51   LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
52   INCLUDE(SalomeMacros)
53   FIND_PACKAGE(SalomeKERNEL REQUIRED)
54   KERNEL_WITH_CORBA() # check whether KERNEL builded with CORBA
55 ELSE(EXISTS ${KERNEL_ROOT_DIR})
56   MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
57 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
58
59 # Platform setup
60 # ==============
61 INCLUDE(SalomeSetupPlatform)   # From KERNEL
62 # Always build libraries as shared objects:
63 SET(BUILD_SHARED_LIBS TRUE)
64 # Local macros:
65 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
66
67 # User options
68 # ============
69 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
70 OPTION(SALOME_BUILD_DOC "Generate SALOME PYHELLO documentation" ON)
71
72 IF(SALOME_BUILD_TESTS)
73   ENABLE_TESTING()
74 ENDIF()
75 IF(SALOME_BUILD_DOC)
76   FIND_PACKAGE(SalomeDoxygen)
77   SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
78 ENDIF()
79
80 ##
81 ## From KERNEL:
82 ##
83 FIND_PACKAGE(SalomePythonInterp REQUIRED)
84 FIND_PACKAGE(SalomePythonLibs REQUIRED)
85 FIND_PACKAGE(SalomeOmniORB REQUIRED)
86 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
87
88 # Find GUI
89 # ===========
90 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
91 IF(EXISTS ${GUI_ROOT_DIR})
92    LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
93    FIND_PACKAGE(SalomeGUI REQUIRED)
94    ADD_DEFINITIONS(${GUI_DEFINITIONS})
95    INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})   
96  ELSE(EXISTS ${GUI_ROOT_DIR})
97    MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR")
98 ENDIF(EXISTS ${GUI_ROOT_DIR})
99
100 ##
101 ## From GUI:
102 ##
103 # Qt
104 IF(NOT SALOME_GUI_BUILD_WITH_QT5)
105   FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
106 ELSE()
107   FIND_PACKAGE(SalomeQt5 REQUIRED)
108 ENDIF()
109
110 # Detection summary:
111 SALOME_PACKAGE_REPORT_AND_CHECK()
112
113 # Directories
114 # (default values taken from KERNEL)
115 # ===========
116 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
117 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
118 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
119 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
120 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH 
121    "Install path: SALOME scripts")
122 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH 
123    "Install path: SALOME script data")
124 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH 
125    "Install path: SALOME Python scripts")
126 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH 
127    "Install path: SALOME application skeleton - scripts")
128 SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH 
129    "Install path: SALOME application skeleton - Python")
130 #SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
131 #SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH 
132 #   "Install path: SALOME Python shared modules")
133 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH "Install path: SALOME CMake files")
134 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
135   "Install path: local SALOME config files (obsolete, to be removed)")
136
137 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
138 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
139
140 # Specific to PYHELLO:
141 SET(SALOME_PYHELLO_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/pyhello" CACHE PATH 
142     "Install path: SALOME PYHELLO specific data")
143    
144 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
145 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
146 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
147 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
148 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
149 MARK_AS_ADVANCED(SALOME_PYHELLO_INSTALL_RES_DATA)
150
151 # Accumulate environment variables for PYHELLO module
152 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
153                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON})
154 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}) 
155
156 # Sources 
157 # ========
158
159 ADD_SUBDIRECTORY(idl)
160 ADD_SUBDIRECTORY(adm_local)
161 ADD_SUBDIRECTORY(resources)
162 ADD_SUBDIRECTORY(src)
163 ADD_SUBDIRECTORY(bin)
164 IF(SALOME_BUILD_DOC)
165   ADD_SUBDIRECTORY(doc)
166 ENDIF()
167
168 # Configuration export
169 # (here only the level 1 prerequisites are exposed)
170 # ====================
171 INCLUDE(CMakePackageConfigHelpers)
172
173 # List of targets in this project we want to make visible to the rest of the world.
174 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
175 SET(_${PROJECT_NAME}_exposed_targets 
176   SalomeIDLPYHELLO
177 )
178
179 # Add all targets to the build-tree export set
180 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
181   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
182
183 # Create the configuration files:
184 #   - in the build tree:
185
186 # Ensure the variables are always defined for the configure:
187 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
188
189 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
190
191 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
192 # SALOME_CONFIGURE_PREPARE() #For use in the future
193
194 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
195     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
196     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
197     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
198     GUI_ROOT_DIR)
199
200 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
201     VERSION ${${PROJECT_NAME_UC}_VERSION}
202     COMPATIBILITY AnyNewerVersion)
203   
204 # Install the CMake configuration files:
205 INSTALL(FILES
206   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
207   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
208   DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
209
210 # Install the export set for use with the install-tree
211 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" 
212   FILE ${PROJECT_NAME}Targets.cmake)