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