0029296: Data Exchange - implement import of mesh data from files in OBJ format
[occt.git] / adm / cmake / tcl.cmake
CommitLineData
9f33b387 1# tcl
ad211ad3 2
3321f684 3if (NOT DEFINED INSTALL_TCL AND BUILD_SHARED_LIBS)
316d77d9 4 set (INSTALL_TCL OFF CACHE BOOL "${INSTALL_TCL_DESCR}")
9f33b387 5endif()
ad211ad3 6
9f33b387 7# tcl directory
8if (NOT DEFINED 3RDPARTY_TCL_DIR)
9 set (3RDPARTY_TCL_DIR "" CACHE PATH "The directory containing tcl")
10endif()
ad211ad3 11
9f33b387 12# tcl include directory
13if (NOT DEFINED 3RDPARTY_TCL_INCLUDE_DIR)
14 set (3RDPARTY_TCL_INCLUDE_DIR "" CACHE FILEPATH "The directory containing headers of tcl")
15endif()
ad211ad3 16
3321f684 17if (BUILD_SHARED_LIBS)
18 # tcl library file (with absolute path)
19 if (NOT DEFINED 3RDPARTY_TCL_LIBRARY OR NOT 3RDPARTY_TCL_LIBRARY_DIR)
20 set (3RDPARTY_TCL_LIBRARY "" CACHE FILEPATH "tcl library" FORCE)
21 endif()
9f33b387 22
3321f684 23 # tcl library directory
24 if (NOT DEFINED 3RDPARTY_TCL_LIBRARY_DIR)
25 set (3RDPARTY_TCL_LIBRARY_DIR "" CACHE FILEPATH "The directory containing tcl library")
26 endif()
9f33b387 27
3321f684 28 # tcl shared library (with absolute path)
29 if (WIN32)
30 if (NOT DEFINED 3RDPARTY_TCL_DLL OR NOT 3RDPARTY_TCL_DLL_DIR)
31 set (3RDPARTY_TCL_DLL "" CACHE FILEPATH "tcl shared library" FORCE)
32 endif()
9f33b387 33 endif()
9f33b387 34
3321f684 35 # tcl shared library directory
36 if (WIN32 AND NOT DEFINED 3RDPARTY_TCL_DLL_DIR)
37 set (3RDPARTY_TCL_DLL_DIR "" CACHE FILEPATH "The directory containing tcl shared library")
38 endif()
9f33b387 39endif()
40
9f33b387 41# search for tcl in user defined directory
42if (NOT 3RDPARTY_TCL_DIR AND 3RDPARTY_DIR)
ad211ad3 43 FIND_PRODUCT_DIR("${3RDPARTY_DIR}" tcl TCL_DIR_NAME)
9f33b387 44 if (TCL_DIR_NAME)
45 set (3RDPARTY_TCL_DIR "${3RDPARTY_DIR}/${TCL_DIR_NAME}" CACHE PATH "The directory containing tcl" FORCE)
46 endif()
47endif()
ad211ad3 48
9f33b387 49# define paths for default engine
50if (3RDPARTY_TCL_DIR AND EXISTS "${3RDPARTY_TCL_DIR}")
51 set (TCL_INCLUDE_PATH "${3RDPARTY_TCL_DIR}/include")
52endif()
53
82f443b6 54# check tcl include dir, library dir and shared library dir
55COMPLIANCE_PRODUCT_CONSISTENCY(TCL)
19286d7c 56
82f443b6 57# use default (CMake) TCL search
a3d2cb24 58find_package(TCL QUIET)
9f33b387 59
82f443b6 60# tcl include dir
61if (NOT 3RDPARTY_TCL_INCLUDE_DIR)
62 if (TCL_INCLUDE_PATH AND EXISTS "${TCL_INCLUDE_PATH}")
63 set (3RDPARTY_TCL_INCLUDE_DIR "${TCL_INCLUDE_PATH}" CACHE FILEPATH "The directory containing headers of TCL" FORCE)
9f33b387 64 endif()
82f443b6 65endif()
9f33b387 66
3321f684 67if (BUILD_SHARED_LIBS)
68 # tcl dir and library
69 if (NOT 3RDPARTY_TCL_LIBRARY)
70 if (TCL_LIBRARY AND EXISTS "${TCL_LIBRARY}")
71 set (3RDPARTY_TCL_LIBRARY "${TCL_LIBRARY}" CACHE FILEPATH "TCL library" FORCE)
9f33b387 72
3321f684 73 if (NOT 3RDPARTY_TCL_LIBRARY_DIR)
74 get_filename_component (3RDPARTY_TCL_LIBRARY_DIR "${3RDPARTY_TCL_LIBRARY}" PATH)
75 set (3RDPARTY_TCL_LIBRARY_DIR "${3RDPARTY_TCL_LIBRARY_DIR}" CACHE FILEPATH "The directory containing TCL library" FORCE)
76 endif()
9f33b387 77 endif()
9f33b387 78 endif()
79
82f443b6 80
3321f684 81 if (WIN32)
82 if (NOT 3RDPARTY_TCL_DLL)
1ce0716b 83 set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll .a)
3321f684 84
85 set (DLL_FOLDER_FOR_SEARCH "")
86 if (3RDPARTY_TCL_DLL_DIR)
87 set (DLL_FOLDER_FOR_SEARCH "${3RDPARTY_TCL_DLL_DIR}")
88 elseif (3RDPARTY_TCL_DIR)
89 set (DLL_FOLDER_FOR_SEARCH "${3RDPARTY_TCL_DIR}/bin")
90 elseif (3RDPARTY_TCL_LIBRARY_DIR)
91 get_filename_component (3RDPARTY_TCL_LIBRARY_DIR_PARENT "${3RDPARTY_TCL_LIBRARY_DIR}" PATH)
92 set (DLL_FOLDER_FOR_SEARCH "${3RDPARTY_TCL_LIBRARY_DIR_PARENT}/bin")
93 endif()
94
95 set (3RDPARTY_TCL_DLL "3RDPARTY_TCL_DLL-NOTFOUND" CACHE FILEPATH "TCL shared library" FORCE)
4fecc365 96 find_library (3RDPARTY_TCL_DLL NAMES ${CSF_TclLibs}
97 PATHS "${DLL_FOLDER_FOR_SEARCH}"
98 NO_DEFAULT_PATH)
9f33b387 99 endif()
82f443b6 100 endif()
101endif()
9f33b387 102
82f443b6 103COMPLIANCE_PRODUCT_CONSISTENCY(TCL)
9f33b387 104
3321f684 105if (BUILD_SHARED_LIBS)
106 # tcl dir and library
107 if (NOT 3RDPARTY_TCL_LIBRARY)
108 set (3RDPARTY_TCL_LIBRARY "3RDPARTY_TCL_LIBRARY-NOTFOUND" CACHE FILEPATH "TCL library" FORCE)
4fecc365 109 find_library (3RDPARTY_TCL_LIBRARY NAMES ${CSF_TclLibs}
110 PATHS "${3RDPARTY_TCL_LIBRARY_DIR}"
111 NO_DEFAULT_PATH)
9f33b387 112
3321f684 113 # search in another place if previous search doesn't find anything
4fecc365 114 find_library (3RDPARTY_TCL_LIBRARY NAMES ${CSF_TclLibs}
115 PATHS "${3RDPARTY_TCL_DIR}/lib"
116 NO_DEFAULT_PATH)
9f33b387 117
9f33b387 118
3321f684 119 if (NOT 3RDPARTY_TCL_LIBRARY OR NOT EXISTS "${3RDPARTY_TCL_LIBRARY}")
120 set (3RDPARTY_TCL_LIBRARY "" CACHE FILEPATH "TCL library" FORCE)
121 endif()
9f33b387 122
3321f684 123 if (NOT 3RDPARTY_TCL_LIBRARY_DIR AND 3RDPARTY_TCL_LIBRARY)
124 get_filename_component (3RDPARTY_TCL_LIBRARY_DIR "${3RDPARTY_TCL_LIBRARY}" PATH)
125 set (3RDPARTY_TCL_LIBRARY_DIR "${3RDPARTY_TCL_LIBRARY_DIR}" CACHE FILEPATH "The directory containing TCL library" FORCE)
126 endif()
9f33b387 127 endif()
19286d7c 128
3321f684 129 set (3RDPARTY_TCL_LIBRARY_VERSION "")
130 if (3RDPARTY_TCL_LIBRARY AND EXISTS "${3RDPARTY_TCL_LIBRARY}")
131 get_filename_component (TCL_LIBRARY_NAME "${3RDPARTY_TCL_LIBRARY}" NAME)
132 string(REGEX REPLACE "^.*tcl([0-9]\\.*[0-9]).*$" "\\1" TCL_LIBRARY_VERSION "${TCL_LIBRARY_NAME}")
9f33b387 133
3321f684 134 if (NOT "${TCL_LIBRARY_VERSION}" STREQUAL "${TCL_LIBRARY_NAME}")
135 set (3RDPARTY_TCL_LIBRARY_VERSION "${TCL_LIBRARY_VERSION}")
136 else() # if the version isn't found - seek other library with 8.6 or 8.5 version in the same dir
137 message (STATUS "Info: TCL version isn't found")
138 endif()
9f33b387 139 endif()
140
3321f684 141 set (3RDPARTY_TCL_LIBRARY_VERSION_WITH_DOT "")
142 if (3RDPARTY_TCL_LIBRARY_VERSION)
143 string (REGEX REPLACE "^.*([0-9])[^0-9]*[0-9].*$" "\\1" 3RDPARTY_TCL_MAJOR_VERSION "${3RDPARTY_TCL_LIBRARY_VERSION}")
144 string (REGEX REPLACE "^.*[0-9][^0-9]*([0-9]).*$" "\\1" 3RDPARTY_TCL_MINOR_VERSION "${3RDPARTY_TCL_LIBRARY_VERSION}")
145 set (3RDPARTY_TCL_LIBRARY_VERSION_WITH_DOT "${3RDPARTY_TCL_MAJOR_VERSION}.${3RDPARTY_TCL_MINOR_VERSION}")
146 endif()
19286d7c 147
3321f684 148 if (WIN32)
149 if (NOT 3RDPARTY_TCL_DLL)
1ce0716b 150 set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll .a)
3321f684 151
152 set (DLL_FOLDER_FOR_SEARCH "")
153 if (3RDPARTY_TCL_DLL_DIR)
154 set (DLL_FOLDER_FOR_SEARCH "${3RDPARTY_TCL_DLL_DIR}")
155 elseif (3RDPARTY_TCL_DIR)
156 set (DLL_FOLDER_FOR_SEARCH "${3RDPARTY_TCL_DIR}/bin")
157 else()
158 get_filename_component (3RDPARTY_TCL_LIBRARY_DIR_PARENT "${3RDPARTY_TCL_LIBRARY_DIR}" PATH)
159 set (DLL_FOLDER_FOR_SEARCH "${3RDPARTY_TCL_LIBRARY_DIR_PARENT}/bin")
160 endif()
161
162 set (3RDPARTY_TCL_DLL "3RDPARTY_TCL_DLL-NOTFOUND" CACHE FILEPATH "TCL shared library" FORCE)
163 find_library (3RDPARTY_TCL_DLL NAMES tcl${3RDPARTY_TCL_LIBRARY_VERSION}
4fecc365 164 PATHS "${DLL_FOLDER_FOR_SEARCH}"
165 NO_DEFAULT_PATH)
82f443b6 166
3321f684 167 if (NOT 3RDPARTY_TCL_DLL OR NOT EXISTS "${3RDPARTY_TCL_DLL}")
168 set (3RDPARTY_TCL_DLL "" CACHE FILEPATH "TCL shared library" FORCE)
169 endif()
9f33b387 170 endif()
3321f684 171 if (NOT 3RDPARTY_TCL_DLL_DIR AND 3RDPARTY_TCL_DLL)
172 get_filename_component (3RDPARTY_TCL_DLL_DIR "${3RDPARTY_TCL_DLL}" PATH)
173 set (3RDPARTY_TCL_DLL_DIR "${3RDPARTY_TCL_DLL_DIR}" CACHE FILEPATH "The directory containing TCL shared library" FORCE)
9f33b387 174 endif()
175 endif()
9f33b387 176
3321f684 177 # include found paths to common variables
178 if (3RDPARTY_TCL_INCLUDE_DIR AND EXISTS "${3RDPARTY_TCL_INCLUDE_DIR}")
179 list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_TCL_INCLUDE_DIR}")
9f33b387 180 else()
3321f684 181 list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TCL_INCLUDE_DIR)
9f33b387 182 endif()
9f33b387 183
3321f684 184 if (3RDPARTY_TCL_LIBRARY AND EXISTS "${3RDPARTY_TCL_LIBRARY}")
185 list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_TCL_LIBRARY_DIR}")
186 else()
0553a8ea 187 list (APPEND 3RDPARTY_NO_LIBS 3RDPARTY_TCL_LIBRARY_DIR)
3321f684 188 endif()
9f33b387 189
190 if (WIN32)
3321f684 191 if (3RDPARTY_TCL_DLL OR EXISTS "${3RDPARTY_TCL_DLL}")
192 list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_TCL_DLL_DIR}")
193 else()
0553a8ea 194 list (APPEND 3RDPARTY_NO_DLLS 3RDPARTY_TCL_DLL_DIR)
3321f684 195 endif()
196 endif()
096ef695 197
3321f684 198 # install tcl
199 if (INSTALL_TCL)
200 # include occt macros. compiler_bitness, os_wiht_bit, compiler
201 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
202
203 OCCT_MAKE_OS_WITH_BITNESS()
204 OCCT_MAKE_COMPILER_SHORT_NAME()
205
206 if (WIN32)
207 # tcl 8.6 requires zlib. install all dlls from tcl bin folder that may contain zlib also
208
209 # collect and install all dlls from tcl dll dirs
210 file (GLOB TCL_DLLS "${3RDPARTY_TCL_DLL_DIR}/*.dll")
211
212 if (SINGLE_GENERATOR)
d26375e2 213 install (FILES ${TCL_DLLS} DESTINATION "${INSTALL_DIR_BIN}")
3321f684 214 else()
215 install (FILES ${TCL_DLLS}
216 CONFIGURATIONS Release
d26375e2 217 DESTINATION "${INSTALL_DIR_BIN}")
3321f684 218 install (FILES ${TCL_DLLS}
219 CONFIGURATIONS RelWithDebInfo
d26375e2 220 DESTINATION "${INSTALL_DIR_BIN}i")
3321f684 221 install (FILES ${TCL_DLLS}
222 CONFIGURATIONS Debug
d26375e2 223 DESTINATION "${INSTALL_DIR_BIN}d")
3321f684 224 endif()
096ef695 225 else()
3321f684 226 get_filename_component(3RDPARTY_TCL_LIBRARY_REALPATH ${3RDPARTY_TCL_LIBRARY} REALPATH)
227
228 if (SINGLE_GENERATOR)
d26375e2 229 install (FILES ${3RDPARTY_TCL_LIBRARY_REALPATH} DESTINATION "${INSTALL_DIR_LIB}")
3321f684 230 else()
231 install (FILES ${3RDPARTY_TCL_LIBRARY_REALPATH}
232 CONFIGURATIONS Release
d26375e2 233 DESTINATION "${INSTALL_DIR_LIB}")
3321f684 234 install (FILES ${3RDPARTY_TCL_LIBRARY_REALPATH}
235 CONFIGURATIONS RelWithDebInfo
d26375e2 236 DESTINATION "${INSTALL_DIR_LIB}i")
3321f684 237 install (FILES ${3RDPARTY_TCL_LIBRARY_REALPATH}
238 CONFIGURATIONS Debug
d26375e2 239 DESTINATION "${INSTALL_DIR_LIB}d")
3321f684 240 endif()
096ef695 241 endif()
096ef695 242
3321f684 243 if (TCL_TCLSH_VERSION)
244 # tcl is required to install in lib folder (without)
d26375e2 245 install (DIRECTORY "${3RDPARTY_TCL_LIBRARY_DIR}/tcl8" DESTINATION "${INSTALL_DIR_LIB}")
246 install (DIRECTORY "${3RDPARTY_TCL_LIBRARY_DIR}/tcl${TCL_TCLSH_VERSION}" DESTINATION "${INSTALL_DIR_LIB}")
096ef695 247 else()
3321f684 248 message (STATUS "\nWarning: tclX.X subdir won't be copyied during the installation process.")
249 message (STATUS "Try seeking tcl within another folder by changing 3RDPARTY_TCL_DIR variable.")
096ef695 250 endif()
9f33b387 251
3321f684 252 set (USED_3RDPARTY_TCL_DIR "")
9f33b387 253 else()
3321f684 254 # the library directory for using by the executable
255 if (WIN32)
256 set (USED_3RDPARTY_TCL_DIR ${3RDPARTY_TCL_DLL_DIR})
257 else()
258 set (USED_3RDPARTY_TCL_DIR ${3RDPARTY_TCL_LIBRARY_DIR})
259 endif()
9f33b387 260 endif()
0a66e59d 261
3321f684 262 mark_as_advanced (3RDPARTY_TCL_LIBRARY 3RDPARTY_TCL_DLL)
9f33b387 263endif()
264
82f443b6 265if (TK_FOUND AND 3RDPARTY_TCL_DIR)
d3ff0ff2 266
267 get_filename_component (TK_WISH_ABSOLUTE "${TK_WISH}" ABSOLUTE)
268 get_filename_component (3RDPARTY_TCL_DIR_ABSOLUTE "${3RDPARTY_TCL_DIR}" ABSOLUTE)
269
270 string (FIND "${TK_WISH_ABSOLUTE}" "${3RDPARTY_TCL_DIR_ABSOLUTE}" THE_SAME_FOLDER)
271
272 if (${THE_SAME_FOLDER} EQUAL 0)
82f443b6 273 set (3RDPARTY_TCLTK_DIR "${3RDPARTY_TCL_DIR}")
a6874708 274 message (STATUS "Info: TK is used from TCL folder: ${3RDPARTY_TCLTK_DIR}")
82f443b6 275 endif()
276endif()
9f33b387 277
278# unset all redundant variables
279#TCL
280OCCT_CHECK_AND_UNSET (TCL_LIBRARY)
281OCCT_CHECK_AND_UNSET (TCL_INCLUDE_PATH)
282OCCT_CHECK_AND_UNSET (TCL_TCLSH)
283#TK
284OCCT_CHECK_AND_UNSET (TK_LIBRARY)
285OCCT_CHECK_AND_UNSET (TK_INCLUDE_PATH)
286OCCT_CHECK_AND_UNSET (TK_WISH)
3321f684 287
288if (NOT BUILD_SHARED_LIBS)
289 OCCT_CHECK_AND_UNSET (3RDPARTY_TCL_LIBRARY)
290 OCCT_CHECK_AND_UNSET (3RDPARTY_TCL_LIBRARY_DIR)
291 OCCT_CHECK_AND_UNSET (3RDPARTY_TCL_DLL)
292 OCCT_CHECK_AND_UNSET (3RDPARTY_TCL_DLL_DIR)
293 OCCT_CHECK_AND_UNSET (INSTALL_TCL)
a3d2cb24 294endif()