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