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