| 1 | cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) |
| 2 | |
| 3 | set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/adm/cmake") |
| 4 | |
| 5 | set (CMAKE_SUPPRESS_REGENERATION TRUE) |
| 6 | |
| 7 | set (CMAKE_CONFIGURATION_TYPES Release Debug RelWithDebInfo CACHE INTERNAL "" FORCE) |
| 8 | |
| 9 | # macro: include patched file if it exists |
| 10 | macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE) |
| 11 | if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake") |
| 12 | include (${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake) |
| 13 | else() |
| 14 | include (${CMAKE_SOURCE_DIR}/${BEING_INCLUDED_FILE}.cmake) |
| 15 | endif() |
| 16 | endmacro() |
| 17 | |
| 18 | # include variable description |
| 19 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vardescr") |
| 20 | |
| 21 | # set type of OCCT libraries |
| 22 | if (NOT BUILD_LIBRARY_TYPE) |
| 23 | set (BUILD_LIBRARY_TYPE "Shared" CACHE STRING "${BUILD_LIBRARY_TYPE_DESCR}" FORCE) |
| 24 | SET_PROPERTY(CACHE BUILD_LIBRARY_TYPE PROPERTY STRINGS Shared Static) |
| 25 | endif() |
| 26 | |
| 27 | if ("${BUILD_LIBRARY_TYPE}" STREQUAL "Shared") |
| 28 | set (BUILD_SHARED_LIBS ON) |
| 29 | |
| 30 | if (NOT DEFINED BUILD_SHARED_LIBRARY_NAME_POSTFIX) |
| 31 | set (BUILD_SHARED_LIBRARY_NAME_POSTFIX "" CACHE STRING "${BUILD_SHARED_LIBRARY_NAME_POSTFIX_DESCR}" FORCE) |
| 32 | endif() |
| 33 | else() |
| 34 | unset (BUILD_SHARED_LIBS) |
| 35 | message (STATUS "Info: Only 3rdparty's header files are used for building of static OCCT libraries") |
| 36 | unset (BUILD_SHARED_LIBRARY_NAME_POSTFIX) |
| 37 | endif() |
| 38 | |
| 39 | # the name of the project |
| 40 | project (OCCT) |
| 41 | |
| 42 | if (WIN32) |
| 43 | add_definitions(-DUNICODE) |
| 44 | add_definitions(-D_UNICODE) |
| 45 | endif() |
| 46 | |
| 47 | # include occt macros |
| 48 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros") |
| 49 | |
| 50 | # Solution folder property |
| 51 | set_property (GLOBAL PROPERTY USE_FOLDERS ON) |
| 52 | |
| 53 | # get current OCCT version |
| 54 | OCC_VERSION (OCC_VERSION_MAJOR OCC_VERSION_MINOR OCC_VERSION_MAINTENANCE OCC_VERSION_DEVELOPMENT OCC_VERSION_STRING_EXT) |
| 55 | |
| 56 | set_property (GLOBAL PROPERTY OCC_VERSION_MAJOR ${OCC_VERSION_MAJOR}) |
| 57 | set_property (GLOBAL PROPERTY OCC_VERSION_MINOR ${OCC_VERSION_MINOR}) |
| 58 | set_property (GLOBAL PROPERTY OCC_VERSION_MAINTENANCE ${OCC_VERSION_MAINTENANCE}) |
| 59 | |
| 60 | set (INSTALL_TEST_CASES OFF CACHE BOOL "${INSTALL_TEST_CASES_DESCR}") |
| 61 | |
| 62 | # Regeneration of OCCT resource files |
| 63 | set (BUILD_RESOURCES OFF CACHE BOOL "${BUILD_RESOURCES_DESCR}") |
| 64 | |
| 65 | # single-configuration generator |
| 66 | set (SINGLE_GENERATOR OFF) |
| 67 | if (CMAKE_BUILD_TYPE) |
| 68 | set (SINGLE_GENERATOR ON) |
| 69 | endif() |
| 70 | |
| 71 | # a single-configuration generator like the Makefile generator defines CMAKE_BUILD_TYPE variable |
| 72 | # check this variable and set if it's required |
| 73 | if (DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE) # single-configuration generator. |
| 74 | set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) |
| 75 | endif() |
| 76 | |
| 77 | # enable extended messages of many OCCT algorithms |
| 78 | if (((SINGLE_GENERATOR AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR NOT SINGLE_GENERATOR) AND (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")) |
| 79 | if (NOT BUILD_WITH_DEBUG) |
| 80 | set (BUILD_WITH_DEBUG OFF CACHE BOOL "${BUILD_WITH_DEBUG_DESCR}") |
| 81 | endif() |
| 82 | else() |
| 83 | OCCT_CHECK_AND_UNSET (BUILD_WITH_DEBUG) |
| 84 | endif() |
| 85 | |
| 86 | if (BUILD_WITH_DEBUG) |
| 87 | set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:DEBUG>:OCCT_DEBUG>) |
| 88 | endif() |
| 89 | |
| 90 | # option to enable or disable use of precompiled headers |
| 91 | if (NOT DEFINED BUILD_USE_PCH) |
| 92 | set (BUILD_USE_PCH OFF CACHE BOOL "${BUILD_USE_PCH_DESCR}") |
| 93 | endif() |
| 94 | |
| 95 | if (BUILD_USE_PCH) |
| 96 | |
| 97 | # Load Cotire tool for accelerating build procedure |
| 98 | include(cotire) |
| 99 | |
| 100 | # Set Cotire to ignore lxx, pxx, gxx |
| 101 | set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS "lxx;pxx;gxx" CACHE STRING "Set Cotire to ignore OCCT specific files that can be #included" FORCE) |
| 102 | |
| 103 | # Set priority for inclusion of system headers in PCH to reduce problems |
| 104 | # due to incomplete inclusion or wrong order. |
| 105 | if (WIN32) |
| 106 | # on Windows, assume that SDK (windows.h) is in default location |
| 107 | set(ProgramFilesX86 "ProgramFiles(x86)") |
| 108 | file(TO_CMAKE_PATH "$ENV{${ProgramFilesX86}}" ProgramFilesX86) |
| 109 | set_property (DIRECTORY PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH "${ProgramFilesX86}") |
| 110 | unset(ProgramFilesX86) |
| 111 | endif() |
| 112 | |
| 113 | endif() |
| 114 | |
| 115 | # copy samples to install directory |
| 116 | set (INSTALL_SAMPLES OFF CACHE BOOL "${INSTALL_SAMPLES_DESCR}") |
| 117 | |
| 118 | # install dir of the project |
| 119 | if (NOT DEFINED INSTALL_DIR) |
| 120 | # set default install directory for Windows |
| 121 | if (WIN32 AND NOT DEFINED CMAKE_INSTALL_PREFIX) |
| 122 | set (CMAKE_INSTALL_PREFIX "C:/opencascade-${OCC_VERSION_STRING_EXT}") |
| 123 | endif() |
| 124 | set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}") |
| 125 | else() |
| 126 | file (TO_CMAKE_PATH "${INSTALL_DIR}" INSTALL_DIR) |
| 127 | set (INSTALL_DIR "${INSTALL_DIR}" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE) |
| 128 | endif() |
| 129 | |
| 130 | # choose a variant of the layout of the install paths |
| 131 | if (NOT INSTALL_DIR_LAYOUT) |
| 132 | if (WIN32) |
| 133 | set (INSTALL_DIR_LAYOUT "Windows" CACHE STRING "${INSTALL_DIR_LAYOUT_DESCR}" FORCE) |
| 134 | else() |
| 135 | set (INSTALL_DIR_LAYOUT "Unix" CACHE STRING "${INSTALL_DIR_LAYOUT_DESCR}" FORCE) |
| 136 | endif() |
| 137 | SET_PROPERTY(CACHE INSTALL_DIR_LAYOUT PROPERTY STRINGS Windows Unix) |
| 138 | endif() |
| 139 | |
| 140 | # check INSTALL_DIR_LAYOUT changes and update INSTALL_DIR_* paths if necessary |
| 141 | if (NOT DEFINED INSTALL_DIR_LAYOUT_PREV) |
| 142 | set (INSTALL_DIR_LAYOUT_PREV "${INSTALL_DIR_LAYOUT}" CACHE INTERNAL "" FORCE) |
| 143 | elseif (NOT "${INSTALL_DIR_LAYOUT_PREV}" STREQUAL "${INSTALL_DIR_LAYOUT}") |
| 144 | set (INSTALL_DIR_LAYOUT_PREV "${INSTALL_DIR_LAYOUT}" CACHE INTERNAL "" FORCE) |
| 145 | # The structure of install folder should be reset due to changed layout |
| 146 | OCCT_CHECK_AND_UNSET_INSTALL_DIR_SUBDIRS () |
| 147 | |
| 148 | # Unset INSTALL_DIR_WITH_VERSION on windows |
| 149 | if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Windows") |
| 150 | OCCT_CHECK_AND_UNSET (INSTALL_DIR_WITH_VERSION) |
| 151 | else() |
| 152 | if (NOT DEFINED INSTALL_DIR_WITH_VERSION) |
| 153 | set (INSTALL_DIR_WITH_VERSION OFF CACHE BOOL "${INSTALL_DIR_WITH_VERSION_DESCR}") |
| 154 | endif() |
| 155 | endif() |
| 156 | endif() |
| 157 | |
| 158 | # check CMAKE_INSTALL_PREFIX changes and update INSTALL_DIR if necessary |
| 159 | if (NOT DEFINED CMAKE_INSTALL_PREFIX_PREV) |
| 160 | set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE) |
| 161 | elseif (NOT "${CMAKE_INSTALL_PREFIX_PREV}" STREQUAL "${CMAKE_INSTALL_PREFIX}") |
| 162 | # CMAKE_INSTALL_PREFIX has been changed at previous step |
| 163 | set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE) |
| 164 | |
| 165 | # INSTALL_DIR is required to be updated |
| 166 | set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE) |
| 167 | endif() |
| 168 | |
| 169 | # check INSTALL_DIR changes and update CMAKE_INSTALL_PREFIX if necessary |
| 170 | if (NOT DEFINED INSTALL_DIR_PREV) |
| 171 | set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE) |
| 172 | elseif (NOT "${INSTALL_DIR_PREV}" STREQUAL "${INSTALL_DIR}") |
| 173 | # INSTALL_DIR has been changed at previous step |
| 174 | set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE) |
| 175 | |
| 176 | # sync CMAKE_INSTALL_PREFIX with INSTALL_DIR |
| 177 | set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE) |
| 178 | |
| 179 | # set CMAKE_INSTALL_PREFIX_PREV to avoid the reset of structure of the install folder |
| 180 | set (CMAKE_INSTALL_PREFIX_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE) |
| 181 | endif() |
| 182 | |
| 183 | if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") |
| 184 | if (NOT DEFINED INSTALL_DIR_WITH_VERSION_PREV) |
| 185 | set (INSTALL_DIR_WITH_VERSION_PREV "${INSTALL_DIR_WITH_VERSION}" CACHE INTERNAL "" FORCE) |
| 186 | elseif (NOT "${INSTALL_DIR_WITH_VERSION_PREV}" STREQUAL "${INSTALL_DIR_WITH_VERSION}") |
| 187 | # INSTALL_DIR_WITH_VERSION has been changed at previous step |
| 188 | set (INSTALL_DIR_WITH_VERSION_PREV "${INSTALL_DIR_WITH_VERSION}" CACHE INTERNAL "" FORCE) |
| 189 | |
| 190 | OCCT_CHECK_AND_UNSET_INSTALL_DIR_SUBDIRS () |
| 191 | endif() |
| 192 | endif() |
| 193 | |
| 194 | # hide CMAKE_INSTALL_PREFIX from a user |
| 195 | set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE) |
| 196 | |
| 197 | set (BIN_LETTER "") |
| 198 | if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") |
| 199 | set (BIN_LETTER "d") |
| 200 | elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") |
| 201 | set (BIN_LETTER "i") |
| 202 | endif() |
| 203 | |
| 204 | # Get all used variables: OS_WITH_BIT, COMPILER |
| 205 | OCCT_MAKE_OS_WITH_BITNESS() |
| 206 | OCCT_MAKE_COMPILER_SHORT_NAME() |
| 207 | |
| 208 | # do not define INSTALL_DIR_BIN for win. |
| 209 | # Leave library structure for win: <prefix>/win64/vc10/bin(d) |
| 210 | if (NOT DEFINED INSTALL_DIR_BIN) |
| 211 | if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") |
| 212 | set (INSTALL_DIR_BIN "bin" CACHE PATH "${INSTALL_DIR_BIN_DESCR}") |
| 213 | else() |
| 214 | set (INSTALL_DIR_BIN "${OS_WITH_BIT}/${COMPILER}/bin" CACHE PATH "${INSTALL_DIR_BIN_DESCR}") |
| 215 | endif() |
| 216 | endif() |
| 217 | |
| 218 | # define folder contaning all shell/batch scripts |
| 219 | if (NOT DEFINED INSTALL_DIR_SCRIPT) |
| 220 | if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") |
| 221 | set (INSTALL_DIR_SCRIPT "${INSTALL_DIR_BIN}" CACHE PATH "${INSTALL_DIR_SCRIPT_DESCR}") |
| 222 | else() |
| 223 | set (INSTALL_DIR_SCRIPT "." CACHE PATH "${INSTALL_DIR_SCRIPT_DESCR}") |
| 224 | endif() |
| 225 | endif() |
| 226 | |
| 227 | # place the libraries to <prefix>/lib folder for unix and leave old structure for windows |
| 228 | if (NOT DEFINED INSTALL_DIR_LIB) |
| 229 | if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") |
| 230 | set (INSTALL_DIR_LIB "lib" CACHE PATH "${INSTALL_DIR_LIB_DESCR}") |
| 231 | else() |
| 232 | set (INSTALL_DIR_LIB "${OS_WITH_BIT}/${COMPILER}/lib" CACHE PATH "${INSTALL_DIR_LIB_DESCR}") |
| 233 | endif() |
| 234 | endif() |
| 235 | |
| 236 | # OCCT headers: <prefix>/inc for windows, |
| 237 | # <prefix>/include/opencascade-7.0.0 for unix |
| 238 | if (NOT DEFINED INSTALL_DIR_INCLUDE) |
| 239 | if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") |
| 240 | set (INSTALL_DIR_INCLUDE "include/opencascade" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}") |
| 241 | if (INSTALL_DIR_WITH_VERSION) |
| 242 | set (INSTALL_DIR_INCLUDE "include/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}" FORCE) |
| 243 | endif() |
| 244 | else() |
| 245 | set (INSTALL_DIR_INCLUDE "inc" CACHE PATH "${INSTALL_DIR_INCLUDE_DESCR}") |
| 246 | endif() |
| 247 | endif() |
| 248 | |
| 249 | # OCCT resources: <prefix>/src for windows, |
| 250 | # <prefix>/share/opencascade-7.0.0/resources for unix |
| 251 | if (NOT DEFINED INSTALL_DIR_RESOURCE) |
| 252 | if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") |
| 253 | set (INSTALL_DIR_RESOURCE "share/opencascade/resources" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}") |
| 254 | if (INSTALL_DIR_WITH_VERSION) |
| 255 | set (INSTALL_DIR_RESOURCE "share/opencascade-${OCC_VERSION_STRING_EXT}/resources" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}" FORCE) |
| 256 | endif() |
| 257 | else() |
| 258 | set (INSTALL_DIR_RESOURCE "src" CACHE PATH "${INSTALL_DIR_RESOURCE_DESCR}") |
| 259 | endif() |
| 260 | endif() |
| 261 | |
| 262 | # OCCT data |
| 263 | if (NOT DEFINED INSTALL_DIR_DATA) |
| 264 | if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") |
| 265 | set (INSTALL_DIR_DATA "share/opencascade/data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}") |
| 266 | if (INSTALL_DIR_WITH_VERSION) |
| 267 | set (INSTALL_DIR_DATA "share/opencascade-${OCC_VERSION_STRING_EXT}/data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}" FORCE) |
| 268 | endif() |
| 269 | else() |
| 270 | set (INSTALL_DIR_DATA "data" CACHE PATH "${INSTALL_DIR_DATA_DESCR}") |
| 271 | endif() |
| 272 | endif() |
| 273 | |
| 274 | # OCCT samples |
| 275 | if (NOT DEFINED INSTALL_DIR_SAMPLES) |
| 276 | if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") |
| 277 | set (INSTALL_DIR_SAMPLES "share/opencascade/samples" CACHE PATH "${INSTALL_DIR_SAMPLES_DESCR}") |
| 278 | if (INSTALL_DIR_WITH_VERSION) |
| 279 | set (INSTALL_DIR_SAMPLES "share/opencascade-${OCC_VERSION_STRING_EXT}/samples" CACHE PATH "${INSTALL_DIR_SAMPLES_DESCR}" FORCE) |
| 280 | endif() |
| 281 | else() |
| 282 | set (INSTALL_DIR_SAMPLES "samples" CACHE PATH "${INSTALL_DIR_SAMPLES_DESCR}") |
| 283 | endif() |
| 284 | endif() |
| 285 | |
| 286 | # OCCT tests |
| 287 | if (NOT DEFINED INSTALL_DIR_TESTS) |
| 288 | if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") |
| 289 | set (INSTALL_DIR_TESTS "share/opencascade/tests" CACHE PATH "${INSTALL_DIR_TESTS_DESCR}") |
| 290 | if (INSTALL_DIR_WITH_VERSION) |
| 291 | set (INSTALL_DIR_TESTS "share/opencascade-${OCC_VERSION_STRING_EXT}/tests" CACHE PATH "${INSTALL_DIR_TESTS_DESCR}" FORCE) |
| 292 | endif() |
| 293 | else() |
| 294 | set (INSTALL_DIR_TESTS "tests" CACHE PATH "${INSTALL_DIR_TESTS_DESCR}") |
| 295 | endif() |
| 296 | endif() |
| 297 | |
| 298 | # OCCT doc |
| 299 | if (NOT DEFINED INSTALL_DIR_DOC) |
| 300 | if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") |
| 301 | set (INSTALL_DIR_DOC "share/doc/opencascade" CACHE PATH "${INSTALL_DIR_DOC_DESCR}") |
| 302 | if (INSTALL_DIR_WITH_VERSION) |
| 303 | set (INSTALL_DIR_DOC "share/doc/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_DIR_DOC_DESCR}" FORCE) |
| 304 | endif() |
| 305 | else() |
| 306 | set (INSTALL_DIR_DOC "doc" CACHE PATH "${INSTALL_DIR_DOC_DESCR}") |
| 307 | endif() |
| 308 | endif() |
| 309 | |
| 310 | # define folder contaning CMake configuration files |
| 311 | if (NOT DEFINED INSTALL_DIR_CMAKE) |
| 312 | if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") |
| 313 | if (INSTALL_DIR_WITH_VERSION) |
| 314 | set (INSTALL_DIR_CMAKE "lib/cmake/opencascade-${OCC_VERSION_STRING_EXT}" CACHE PATH "${INSTALL_DIR_CMAKE_DESCR}") |
| 315 | else() |
| 316 | set (INSTALL_DIR_CMAKE "lib/cmake/opencascade" CACHE PATH "${INSTALL_DIR_CMAKE_DESCR}") |
| 317 | endif() |
| 318 | else() |
| 319 | set (INSTALL_DIR_CMAKE "cmake" CACHE PATH "${INSTALL_DIR_CMAKE_DESCR}") |
| 320 | endif() |
| 321 | endif() |
| 322 | |
| 323 | # include occt macros |
| 324 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_resources") |
| 325 | |
| 326 | # install LICENSE_LGPL_21.txt and OCCT_LGPL_EXCEPTION.txt files |
| 327 | if ("${INSTALL_DIR_LAYOUT}" STREQUAL "Unix") |
| 328 | OCCT_INSTALL_FILE_OR_DIR ("LICENSE_LGPL_21.txt" "${INSTALL_DIR_DOC}") |
| 329 | OCCT_INSTALL_FILE_OR_DIR ("OCCT_LGPL_EXCEPTION.txt" "${INSTALL_DIR_DOC}") |
| 330 | else() |
| 331 | OCCT_INSTALL_FILE_OR_DIR ("LICENSE_LGPL_21.txt" ".") |
| 332 | OCCT_INSTALL_FILE_OR_DIR ("OCCT_LGPL_EXCEPTION.txt" ".") |
| 333 | endif() |
| 334 | |
| 335 | if(APPLE) |
| 336 | set (INSTALL_NAME_DIR "" CACHE STRING "install_name library suffix on OS X (e.g. @executable_path/../Frameworks)") |
| 337 | endif() |
| 338 | |
| 339 | # a directory recognized as a 'patch' for OCCT |
| 340 | set (BUILD_PATCH "" CACHE PATH "${BUILD_PATCH_DESCR}") |
| 341 | |
| 342 | # the list of being built toolkits |
| 343 | set (BUILD_ADDITIONAL_TOOLKITS "" CACHE STRING "${BUILD_ADDITIONAL_TOOLKITS_DESCR}") |
| 344 | separate_arguments (BUILD_ADDITIONAL_TOOLKITS) |
| 345 | |
| 346 | if (MSVC) |
| 347 | set (BUILD_MODULE_MfcSamples OFF CACHE BOOL "${BUILD_MODULE_MfcSamples_DESCR}") |
| 348 | endif() |
| 349 | |
| 350 | set (BUILD_Inspector OFF CACHE BOOL "${BUILD_Inspector_DESCR}") |
| 351 | |
| 352 | # uwp sample |
| 353 | if (MSVC) |
| 354 | if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore") |
| 355 | set (BUILD_MODULE_UwpSample OFF CACHE BOOL "${BUILD_MODULE_UwpSample_DESCR}") |
| 356 | else() |
| 357 | unset (BUILD_MODULE_UwpSample) |
| 358 | endif() |
| 359 | endif() |
| 360 | |
| 361 | # whether use optional 3rdparty or not |
| 362 | if (APPLE) |
| 363 | set (USE_GLX OFF CACHE BOOL "${USE_GLX_DESCR}") |
| 364 | endif() |
| 365 | |
| 366 | if (WIN32) |
| 367 | set (USE_D3D OFF CACHE BOOL "${USE_D3D_DESCR}") |
| 368 | endif() |
| 369 | |
| 370 | # Enable/Disable the floating point exceptions (FPE) during runtime. |
| 371 | if (NOT BUILD_ENABLE_FPE_SIGNAL_HANDLER) |
| 372 | set (BUILD_ENABLE_FPE_SIGNAL_HANDLER OFF CACHE BOOL "${BUILD_ENABLE_FPE_SIGNAL_HANDLER_DESCR}" FORCE) |
| 373 | endif() |
| 374 | |
| 375 | if (BUILD_ENABLE_FPE_SIGNAL_HANDLER) |
| 376 | set (BUILD_ENABLE_FPE_SIGNAL_HANDLER 1) |
| 377 | else() |
| 378 | set (BUILD_ENABLE_FPE_SIGNAL_HANDLER 0) |
| 379 | endif() |
| 380 | |
| 381 | # include the patched or original list of modules |
| 382 | # list <MODULENAME>_TOOLKITS is created foreach module and contains its toolkits |
| 383 | # list <OCCT_MODULES> will contain all modules |
| 384 | OCCT_MODULES_AND_TOOLKITS (OCCT_MODULES) |
| 385 | |
| 386 | foreach (OCCT_MODULE ${OCCT_MODULES}) |
| 387 | BUILD_MODULE (${OCCT_MODULE}) |
| 388 | endforeach() |
| 389 | |
| 390 | if (ANDROID AND BUILD_MODULE_Draw) |
| 391 | message (STATUS "Info. Draw module is turned off due to it is not supported on Android") |
| 392 | set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE) |
| 393 | endif() |
| 394 | if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore" AND BUILD_MODULE_Draw) |
| 395 | message (STATUS "Info. Draw module is turned off due to it is not supported on UWP") |
| 396 | set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE) |
| 397 | endif() |
| 398 | |
| 399 | # Overview |
| 400 | if (NOT DEFINED BUILD_DOC_Overview) |
| 401 | set (DO_ONLY_CHECK_FOR_DOXYGEN ON) |
| 402 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen") |
| 403 | set (DO_ONLY_CHECK_FOR_DOXYGEN OFF) |
| 404 | |
| 405 | if (CAN_DOXYGEN_BE_USED) |
| 406 | message (STATUS "Info. Overview building is turned on") |
| 407 | endif() |
| 408 | |
| 409 | set (BUILD_DOC_Overview ${CAN_DOXYGEN_BE_USED} CACHE BOOL "${BUILD_DOC_Overview_DESCR}") |
| 410 | endif() |
| 411 | |
| 412 | if (NOT USE_D3D) |
| 413 | list (REMOVE_ITEM Visualization_TOOLKITS TKD3DHost) |
| 414 | endif() |
| 415 | |
| 416 | # accumulate used toolkits (first level) in BUILD_TOOLKITS variable |
| 417 | list (APPEND BUILD_TOOLKITS ${BUILD_ADDITIONAL_TOOLKITS}) |
| 418 | |
| 419 | foreach (OCCT_MODULE ${OCCT_MODULES}) |
| 420 | if (BUILD_MODULE_${OCCT_MODULE}) |
| 421 | list (APPEND BUILD_TOOLKITS ${${OCCT_MODULE}_TOOLKITS}) |
| 422 | endif() |
| 423 | endforeach() |
| 424 | |
| 425 | # DRAWEXE excluded when library build is static |
| 426 | if (NOT BUILD_SHARED_LIBS) |
| 427 | list (REMOVE_ITEM BUILD_TOOLKITS DRAWEXE) |
| 428 | message (STATUS "Info: DRAWEXE is not included due to ${BUILD_LIBRARY_TYPE} build library type") |
| 429 | endif() |
| 430 | |
| 431 | # accumulate all used toolkits |
| 432 | list (REMOVE_DUPLICATES BUILD_TOOLKITS) |
| 433 | set (RAW_BUILD_TOOLKITS) |
| 434 | foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS}) |
| 435 | OCCT_TOOLKIT_FULL_DEP (${BUILD_TOOLKIT} TOOLKIT_FULL_DEPS) |
| 436 | list (APPEND RAW_BUILD_TOOLKITS ${BUILD_TOOLKIT} ${TOOLKIT_FULL_DEPS}) |
| 437 | endforeach() |
| 438 | |
| 439 | list (REMOVE_DUPLICATES RAW_BUILD_TOOLKITS) |
| 440 | set (BUILD_TOOLKITS ${RAW_BUILD_TOOLKITS}) |
| 441 | |
| 442 | # include the patched or original list of definitions and flags |
| 443 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_defs_flags") |
| 444 | |
| 445 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/3rdparty_macro") |
| 446 | |
| 447 | # search for TKIVtk and TKIVtkDraw in BUILD_TOOLKITS |
| 448 | list (FIND BUILD_TOOLKITS TKIVtk CAN_USE_VTK) |
| 449 | if (CAN_USE_VTK EQUAL -1) |
| 450 | list (FIND BUILD_TOOLKITS TKIVtkDraw CAN_USE_VTK) |
| 451 | endif() |
| 452 | |
| 453 | if (NOT CAN_USE_VTK EQUAL -1) |
| 454 | if (NOT DEFINED USE_VTK) |
| 455 | set (USE_VTK OFF CACHE BOOL "${USE_VTK_DESCR}") |
| 456 | endif() |
| 457 | else() |
| 458 | OCCT_CHECK_AND_UNSET (USE_VTK) |
| 459 | endif() |
| 460 | |
| 461 | # Rebuild *.yacc and *.lex files that are contained by TKMath toolkit |
| 462 | list (FIND BUILD_TOOLKITS TKMath CAN_REBUILD_PDC_FOR_TKMATH) |
| 463 | list (FIND BUILD_TOOLKITS StepFile CAN_REBUILD_PDC_FOR_STEPFILE) |
| 464 | |
| 465 | if (NOT ${CAN_REBUILD_PDC_FOR_TKMATH} EQUAL -1 OR NOT ${CAN_REBUILD_PDC_FOR_STEPFILE} EQUAL -1) |
| 466 | set (BUILD_YACCLEX OFF CACHE BOOL "${BUILD_YACCLEX_DESCR}") |
| 467 | else() |
| 468 | OCCT_CHECK_AND_UNSET (BUILD_YACCLEX) |
| 469 | endif() |
| 470 | |
| 471 | if (NOT DEFINED 3RDPARTY_DIR) |
| 472 | set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_DESCR}) |
| 473 | get_filename_component (3RDPARTY_DIR "${3RDPARTY_DIR}" ABSOLUTE) |
| 474 | else() |
| 475 | file (TO_CMAKE_PATH "${3RDPARTY_DIR}" 3RDPARTY_DIR) |
| 476 | set (3RDPARTY_DIR "${3RDPARTY_DIR}" CACHE PATH "${3RDPARTY_DIR_DESCR}" FORCE) |
| 477 | endif() |
| 478 | |
| 479 | # search for CSF variable in EXTERNLIB of each being used toolkit |
| 480 | OCCT_IS_PRODUCT_REQUIRED (CSF_FreeImagePlus CAN_USE_FREEIMAGE) |
| 481 | OCCT_IS_PRODUCT_REQUIRED (CSF_TclLibs USE_TCL) |
| 482 | OCCT_IS_PRODUCT_REQUIRED (CSF_FREETYPE USE_FREETYPE) |
| 483 | OCCT_IS_PRODUCT_REQUIRED (CSF_OpenGlLibs CAN_USE_GLES2) |
| 484 | OCCT_IS_PRODUCT_REQUIRED (CSF_GL2PS CAN_USE_GL2PS) |
| 485 | OCCT_IS_PRODUCT_REQUIRED (CSF_TBB CAN_USE_TBB) |
| 486 | OCCT_IS_PRODUCT_REQUIRED (CSF_EIGEN CAN_USE_EIGEN) |
| 487 | |
| 488 | # define CSF variable |
| 489 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_csf") |
| 490 | |
| 491 | if (USE_TCL) |
| 492 | message (STATUS "Info: TCL is used by OCCT") |
| 493 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl") |
| 494 | |
| 495 | message (STATUS "Info: TK is used by OCCT") |
| 496 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tk") |
| 497 | else() |
| 498 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TCL") |
| 499 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TK") |
| 500 | |
| 501 | OCCT_CHECK_AND_UNSET ("INSTALL_TCL") |
| 502 | OCCT_CHECK_AND_UNSET ("INSTALL_TK") |
| 503 | endif() |
| 504 | |
| 505 | if (USE_FREETYPE) |
| 506 | message (STATUS "Info: Freetype is used by OCCT") |
| 507 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype") |
| 508 | else() |
| 509 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE") |
| 510 | OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2") |
| 511 | OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build") |
| 512 | OCCT_CHECK_AND_UNSET ("INSTALL_FREETYPE") |
| 513 | endif() |
| 514 | |
| 515 | # VTK |
| 516 | if (USE_VTK) |
| 517 | add_definitions (-DHAVE_VTK) |
| 518 | set (OCCT_VTK_USED_TARGETS "" CACHE INTERNAL "" FORCE) |
| 519 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk") |
| 520 | else() |
| 521 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_VTK") |
| 522 | |
| 523 | if (NOT CAN_USE_VTK EQUAL -1) |
| 524 | message (STATUS "Info: TKIVtk and TKIVtkDraw toolkits excluded due to VTK usage is disabled") |
| 525 | |
| 526 | list (REMOVE_ITEM BUILD_TOOLKITS TKIVtk) |
| 527 | list (REMOVE_ITEM BUILD_TOOLKITS TKIVtkDraw) |
| 528 | endif() |
| 529 | endif() |
| 530 | |
| 531 | # D3D |
| 532 | if (USE_D3D) |
| 533 | add_definitions (-DHAVE_D3D) |
| 534 | #if(MSVC_VERSION LESS 1700) |
| 535 | #OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/d3d") |
| 536 | #endif() |
| 537 | endif() |
| 538 | |
| 539 | # GLX |
| 540 | if (USE_GLX) |
| 541 | add_definitions (-DMACOSX_USE_GLX) |
| 542 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/glx") |
| 543 | endif() |
| 544 | |
| 545 | # FREEIMAGE |
| 546 | |
| 547 | if (CAN_USE_FREEIMAGE) |
| 548 | set (USE_FREEIMAGE OFF CACHE BOOL "${USE_FREEIMAGE_DESCR}") |
| 549 | |
| 550 | if (USE_FREEIMAGE) |
| 551 | add_definitions (-DHAVE_FREEIMAGE) |
| 552 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage") |
| 553 | else() |
| 554 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE") |
| 555 | OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE") |
| 556 | endif() |
| 557 | else() |
| 558 | OCCT_CHECK_AND_UNSET ("USE_FREEIMAGE") |
| 559 | |
| 560 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE") |
| 561 | OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE") |
| 562 | endif() |
| 563 | |
| 564 | # FFmpeg |
| 565 | # search for CSF_FFmpeg variable in EXTERNLIB of each being used toolkit |
| 566 | OCCT_IS_PRODUCT_REQUIRED (CSF_FFmpeg CAN_USE_FFMPEG) |
| 567 | |
| 568 | if (CAN_USE_FFMPEG) |
| 569 | set (USE_FFMPEG OFF CACHE BOOL "${USE_FFMPEG_DESCR}") |
| 570 | |
| 571 | if (USE_FFMPEG) |
| 572 | add_definitions (-DHAVE_FFMPEG) |
| 573 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/ffmpeg") |
| 574 | else() |
| 575 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FFMPEG") |
| 576 | OCCT_CHECK_AND_UNSET ("INSTALL_FFMPEG") |
| 577 | endif() |
| 578 | else() |
| 579 | OCCT_CHECK_AND_UNSET ("USE_FFMPEG") |
| 580 | |
| 581 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FFMPEG") |
| 582 | OCCT_CHECK_AND_UNSET ("INSTALL_FFMPEG") |
| 583 | endif() |
| 584 | |
| 585 | # OpenGL ES 2.0 |
| 586 | if (WIN32 AND CAN_USE_GLES2) |
| 587 | if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore") |
| 588 | set (USE_GLES2 ON) |
| 589 | else() |
| 590 | set (USE_GLES2 OFF CACHE BOOL "${USE_GLES2_DESCR}") |
| 591 | endif() |
| 592 | |
| 593 | if (USE_GLES2) |
| 594 | add_definitions (-DHAVE_GLES2) |
| 595 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/egl") |
| 596 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gles2") |
| 597 | else() |
| 598 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EGL") |
| 599 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GLES2") |
| 600 | OCCT_CHECK_AND_UNSET ("INSTALL_EGL") |
| 601 | OCCT_CHECK_AND_UNSET ("INSTALL_GLES2") |
| 602 | endif() |
| 603 | else() |
| 604 | OCCT_CHECK_AND_UNSET ("USE_GLES2") |
| 605 | |
| 606 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EGL") |
| 607 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GLES2") |
| 608 | OCCT_CHECK_AND_UNSET ("INSTALL_EGL") |
| 609 | OCCT_CHECK_AND_UNSET ("INSTALL_GLES2") |
| 610 | endif() |
| 611 | |
| 612 | # GL2PS |
| 613 | if (NOT DEFINED ANDROID AND CAN_USE_GL2PS) |
| 614 | set (USE_GL2PS OFF CACHE BOOL "${USE_GL2PS_DESCR}") |
| 615 | |
| 616 | if (USE_GL2PS) |
| 617 | add_definitions (-DHAVE_GL2PS) |
| 618 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gl2ps") |
| 619 | else() |
| 620 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS") |
| 621 | OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS") |
| 622 | endif() |
| 623 | else() |
| 624 | OCCT_CHECK_AND_UNSET ("USE_GL2PS") |
| 625 | |
| 626 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS") |
| 627 | OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS") |
| 628 | endif() |
| 629 | |
| 630 | # TBB |
| 631 | if (NOT DEFINED ANDROID AND CAN_USE_TBB) |
| 632 | set (USE_TBB OFF CACHE BOOL "${USE_TBB_DESCR}") |
| 633 | |
| 634 | if (USE_TBB) |
| 635 | add_definitions (-DHAVE_TBB) |
| 636 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb") |
| 637 | else() |
| 638 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB") |
| 639 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC") |
| 640 | OCCT_CHECK_AND_UNSET ("INSTALL_TBB") |
| 641 | endif() |
| 642 | else() |
| 643 | OCCT_CHECK_AND_UNSET ("USE_TBB") |
| 644 | |
| 645 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB") |
| 646 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC") |
| 647 | OCCT_CHECK_AND_UNSET ("INSTALL_TBB") |
| 648 | endif() |
| 649 | |
| 650 | # EIGEN |
| 651 | if (CAN_USE_EIGEN) |
| 652 | set (USE_EIGEN OFF CACHE BOOL "${USE_EIGEN_DESCR}") |
| 653 | |
| 654 | if (USE_EIGEN) |
| 655 | add_definitions (-DHAVE_EIGEN) |
| 656 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/eigen") |
| 657 | else() |
| 658 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EIGEN") |
| 659 | OCCT_CHECK_AND_UNSET ("INSTALL_EIGEN") |
| 660 | endif() |
| 661 | else() |
| 662 | OCCT_CHECK_AND_UNSET ("USE_EIGEN") |
| 663 | |
| 664 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_EIGEN") |
| 665 | OCCT_CHECK_AND_UNSET ("INSTALL_EIGEN") |
| 666 | endif() |
| 667 | |
| 668 | # Doxygen |
| 669 | if (BUILD_DOC_Overview) |
| 670 | if (NOT DEFINED INSTALL_DOC_Overview) |
| 671 | set (INSTALL_DOC_Overview OFF CACHE BOOL "${INSTALL_DOC_Overview_DESCR}") |
| 672 | endif() |
| 673 | |
| 674 | if (INSTALL_DOC_Overview) |
| 675 | install (DIRECTORY "${CMAKE_BINARY_DIR}/doc/overview" DESTINATION "${INSTALL_DIR_DOC}") |
| 676 | |
| 677 | # create overview.html only for windows |
| 678 | if (WIN32 AND "${INSTALL_DIR_LAYOUT}" STREQUAL "Windows") |
| 679 | OCCT_INSTALL_FILE_OR_DIR ("dox/resources/overview.html" "${INSTALL_DIR_DOC}/..") |
| 680 | endif() |
| 681 | endif() |
| 682 | |
| 683 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen") |
| 684 | else() |
| 685 | OCCT_CHECK_AND_UNSET ("INSTALL_DOC_Overview") |
| 686 | |
| 687 | OCCT_CHECK_AND_UNSET ("3RDPARTY_DOXYGEN_EXECUTABLE") |
| 688 | OCCT_CHECK_AND_UNSET ("3RDPARTY_DOT_EXECUTABLE") |
| 689 | endif() |
| 690 | |
| 691 | # bison |
| 692 | if (BUILD_YACCLEX) |
| 693 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison") |
| 694 | else() |
| 695 | OCCT_CHECK_AND_UNSET ("3RDPARTY_BISON_EXECUTABLE") |
| 696 | endif() |
| 697 | |
| 698 | # flex |
| 699 | if (BUILD_YACCLEX) |
| 700 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/flex") |
| 701 | else() |
| 702 | OCCT_CHECK_AND_UNSET ("3RDPARTY_FLEX_EXECUTABLE") |
| 703 | endif() |
| 704 | |
| 705 | string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}") |
| 706 | |
| 707 | # check all 3rdparty paths |
| 708 | if (3RDPARTY_NOT_INCLUDED) |
| 709 | message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" ) |
| 710 | endif() |
| 711 | |
| 712 | if (3RDPARTY_INCLUDE_DIRS) |
| 713 | list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS) |
| 714 | string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}") |
| 715 | message (STATUS "Info: The directories of 3rdparty headers: \n\t${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}") |
| 716 | include_directories (${3RDPARTY_INCLUDE_DIRS}) |
| 717 | endif() |
| 718 | |
| 719 | # include <cmake binary folder>/inc |
| 720 | include_directories (${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE}) |
| 721 | |
| 722 | if (3RDPARTY_LIBRARY_DIRS AND BUILD_SHARED_LIBS) |
| 723 | list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS) |
| 724 | string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}") |
| 725 | message (STATUS "Info: The directories of 3rdparty libraries: \n\t${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}") |
| 726 | link_directories (${3RDPARTY_LIBRARY_DIRS}) |
| 727 | endif() |
| 728 | |
| 729 | # build directories |
| 730 | if (SINGLE_GENERATOR) |
| 731 | set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}") |
| 732 | set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}") |
| 733 | set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BIN_LETTER}") |
| 734 | if (WIN32) |
| 735 | set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BIN_LETTER}") |
| 736 | endif() |
| 737 | endif() |
| 738 | |
| 739 | set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib") |
| 740 | set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin") |
| 741 | set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/lib") |
| 742 | |
| 743 | set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi") |
| 744 | set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini") |
| 745 | set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libi") |
| 746 | |
| 747 | set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd") |
| 748 | set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind") |
| 749 | set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd") |
| 750 | |
| 751 | if (WIN32) |
| 752 | set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin") |
| 753 | set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini") |
| 754 | set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind") |
| 755 | endif() |
| 756 | |
| 757 | string(TIMESTAMP CURRENT_TIME "%H:%M:%S") |
| 758 | message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT header files into ${CMAKE_BINARY_DIR}/inc ...") |
| 759 | |
| 760 | # collect all the headers to <binary dir>/inc folder |
| 761 | COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}" "${CMAKE_SOURCE_DIR}/src" "${INSTALL_DIR_INCLUDE}") |
| 762 | |
| 763 | string(TIMESTAMP CURRENT_TIME "%H:%M:%S") |
| 764 | message (STATUS "Info: \(${CURRENT_TIME}\) End the collecting") |
| 765 | |
| 766 | list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX) |
| 767 | if (${DRAWEXE_INDEX} GREATER -1) |
| 768 | OCCT_INSTALL_FILE_OR_DIR ("data/" "${INSTALL_DIR_DATA}") |
| 769 | OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR_SAMPLES}") |
| 770 | endif() |
| 771 | |
| 772 | if (WIN32) |
| 773 | set (SCRIPT_EXT bat) |
| 774 | else() |
| 775 | set (SCRIPT_EXT sh) |
| 776 | endif() |
| 777 | |
| 778 | # OCCT tools |
| 779 | # include the patched or original list of tools |
| 780 | # list <TOOLNAME>_TOOLKITS is created foreach tool and contains its toolkits |
| 781 | # list <OCCT_TOOLS> will contain all tools |
| 782 | if (NOT BUILD_Inspector) |
| 783 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_QT") |
| 784 | OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TQTMALLOC") |
| 785 | OCCT_CHECK_AND_UNSET ("INSTALL_QT") |
| 786 | else() |
| 787 | OCCT_TOOLS_AND_TOOLKITS (OCCT_TOOLS) |
| 788 | foreach (OCCT_TOOL ${OCCT_TOOLS}) |
| 789 | list (APPEND BUILD_TOOL_TOOLKITS ${${OCCT_TOOL}_TOOL_TOOLKITS}) |
| 790 | endforeach() |
| 791 | |
| 792 | # collect all the headers to <binary dir>/inc folder |
| 793 | string(TIMESTAMP CURRENT_TIME "%H:%M:%S") |
| 794 | message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT tool header files into ${CMAKE_BINARY_DIR}/tools/inc ...") |
| 795 | COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOL_TOOLKITS}" "${CMAKE_SOURCE_DIR}/tools" "${INSTALL_DIR_INCLUDE}/inspector") |
| 796 | |
| 797 | |
| 798 | # check qt 3rdparty path |
| 799 | add_definitions (-DHAVE_QT) |
| 800 | OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt") |
| 801 | message (STATUS "Info: Qt is used by OCCT") |
| 802 | endif() |
| 803 | |
| 804 | # OCCT samples |
| 805 | # get absolute path from INSTALL_DIR |
| 806 | set (INSTALL_DIR_ABSOLUTE "${INSTALL_DIR}") |
| 807 | if(NOT IS_ABSOLUTE "${INSTALL_DIR_ABSOLUTE}") |
| 808 | get_filename_component(INSTALL_DIR_ABSOLUTE "${CMAKE_BINARY_DIR}/${INSTALL_DIR}" ABSOLUTE) |
| 809 | endif() |
| 810 | |
| 811 | if (INSTALL_SAMPLES) |
| 812 | OCCT_CONFIGURE ("adm/templates/env.samples.${SCRIPT_EXT}.in" "env.samples.${SCRIPT_EXT}") |
| 813 | if (WIN32) |
| 814 | OCCT_INSTALL_FILE_OR_DIR ("samples/CSharp" "${INSTALL_DIR_SAMPLES}") |
| 815 | OCCT_INSTALL_FILE_OR_DIR ("samples/mfc" "${INSTALL_DIR_SAMPLES}") |
| 816 | |
| 817 | if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore") |
| 818 | OCCT_INSTALL_FILE_OR_DIR ("samples/xaml" "${INSTALL_DIR_SAMPLES}") |
| 819 | endif() |
| 820 | |
| 821 | install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/CSharp" RENAME "env.${SCRIPT_EXT}") |
| 822 | install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/mfc/standard" RENAME "env.${SCRIPT_EXT}") |
| 823 | endif() |
| 824 | |
| 825 | OCCT_INSTALL_FILE_OR_DIR ("samples/java" "${INSTALL_DIR_SAMPLES}") |
| 826 | OCCT_INSTALL_FILE_OR_DIR ("samples/ocafsamples" "${INSTALL_DIR_SAMPLES}") |
| 827 | OCCT_INSTALL_FILE_OR_DIR ("samples/qt" "${INSTALL_DIR_SAMPLES}") |
| 828 | |
| 829 | install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/FuncDemo" RENAME "env.${SCRIPT_EXT}") |
| 830 | install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/IESample" RENAME "env.${SCRIPT_EXT}") |
| 831 | install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/Tutorial" RENAME "env.${SCRIPT_EXT}") |
| 832 | endif() |
| 833 | |
| 834 | if (INSTALL_TEST_CASES) |
| 835 | OCCT_INSTALL_FILE_OR_DIR ("tests/" "${INSTALL_DIR_TESTS}") |
| 836 | endif() |
| 837 | |
| 838 | list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX) |
| 839 | if (${DRAWEXE_INDEX} GREATER -1) |
| 840 | # copy data and samples/tcl folders to install script folder |
| 841 | OCCT_INSTALL_FILE_OR_DIR ("data/" "${INSTALL_DIR_DATA}") |
| 842 | OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR_SAMPLES}") |
| 843 | |
| 844 | # copy draw script to install script folder |
| 845 | if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}") |
| 846 | install (FILES "${BUILD_PATCH}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}" |
| 847 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE) |
| 848 | else() |
| 849 | install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}" |
| 850 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE) |
| 851 | endif() |
| 852 | |
| 853 | # copy draw script to CMake binary folder |
| 854 | OCCT_COPY_FILE_OR_DIR ("adm/templates/draw.${SCRIPT_EXT}" "${CMAKE_BINARY_DIR}") |
| 855 | endif() |
| 856 | |
| 857 | set (SUB_CUSTOM_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.${SCRIPT_EXT}") |
| 858 | |
| 859 | if (WIN32) |
| 860 | set (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM_NAME}\" (\n call \"%~dp0${SUB_CUSTOM_NAME}\" %1 %2 %3 \n)") |
| 861 | else() |
| 862 | set (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" ]; then\n source \"\${aScriptPath}/${SUB_CUSTOM_NAME}\" \"\$1\" \"\$2\" \nfi") |
| 863 | endif() |
| 864 | |
| 865 | # change custom.bat/sh |
| 866 | if (EXISTS "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}") |
| 867 | file (READ "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT) |
| 868 | |
| 869 | set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}") |
| 870 | |
| 871 | file (WRITE "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}") |
| 872 | else() |
| 873 | OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "custom.${SCRIPT_EXT}" "${INSTALL_DIR_SCRIPT}") |
| 874 | endif() |
| 875 | |
| 876 | if (WIN32) |
| 877 | set (THIRDPARTY_DIR_REPLACE "%THIRDPARTY_DIR%") |
| 878 | else() |
| 879 | set (THIRDPARTY_DIR_REPLACE "\${THIRDPARTY_DIR}") |
| 880 | endif() |
| 881 | get_cmake_property(USED_3RDPARTY_CACHE_VARIABLES VARIABLES) |
| 882 | string (REGEX MATCHALL "(^|;)USED_3RDPARTY_[^;]+_DIR[^;]*" USED_3RDPARTY_CACHE_VARIABLES "${USED_3RDPARTY_CACHE_VARIABLES}") |
| 883 | file (TO_CMAKE_PATH "${3RDPARTY_DIR}" 3RDPARTY_DIR) |
| 884 | foreach (USED_3RDPARTY_CACHE_VARIABLE ${USED_3RDPARTY_CACHE_VARIABLES}) |
| 885 | file (TO_CMAKE_PATH "${${USED_3RDPARTY_CACHE_VARIABLE}}" ${USED_3RDPARTY_CACHE_VARIABLE}) |
| 886 | string (REPLACE "${3RDPARTY_DIR}" "${THIRDPARTY_DIR_REPLACE}" ${USED_3RDPARTY_CACHE_VARIABLE} "${${USED_3RDPARTY_CACHE_VARIABLE}}") |
| 887 | if (NOT WIN32) |
| 888 | string (REGEX REPLACE ";" ":" ${USED_3RDPARTY_CACHE_VARIABLE} "${${USED_3RDPARTY_CACHE_VARIABLE}}") |
| 889 | endif() |
| 890 | endforeach() |
| 891 | |
| 892 | # write current custom.bat/sh (for install directory) |
| 893 | set (SUB_CUSTOM_BUILD_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.install.${SCRIPT_EXT}") |
| 894 | OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.install.${SCRIPT_EXT}.in" "${SUB_CUSTOM_BUILD_NAME}" "${SUB_CUSTOM_NAME}" "${INSTALL_DIR_SCRIPT}") |
| 895 | |
| 896 | # write current custom.bat/sh (for build directory) |
| 897 | OCCT_CONFIGURE ("adm/templates/custom.build.${SCRIPT_EXT}.in" "${SUB_CUSTOM_NAME}") |
| 898 | |
| 899 | if (BUILD_MODULE_MfcSamples) |
| 900 | OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.bat" "${INSTALL_DIR_SCRIPT}") |
| 901 | OCCT_COPY_FILE_OR_DIR ("adm/templates/sample.bat" "${CMAKE_BINARY_DIR}") |
| 902 | endif() |
| 903 | |
| 904 | # env script for draw in building environment |
| 905 | OCCT_CONFIGURE ("adm/templates/env.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}") |
| 906 | |
| 907 | # install env script |
| 908 | install (FILES "${CMAKE_BINARY_DIR}/env.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}") |
| 909 | |
| 910 | # copy DrawAppliInit from OCCT source to build directory |
| 911 | if (NOT EXISTS "${CMAKE_BINARY_DIR}/DrawAppliInit") |
| 912 | OCCT_COPY_FILE_OR_DIR (DrawAppliInit "${CMAKE_BINARY_DIR}") |
| 913 | endif() |
| 914 | |
| 915 | # RESOURCES |
| 916 | FILE_TO_LIST ("adm/RESOURCES" RESOURCES) |
| 917 | foreach(RESOURCE ${RESOURCES}) |
| 918 | get_filename_component(RESOURCE_FOLDER ${RESOURCE} DIRECTORY) |
| 919 | if(NOT "${RESOURCE_FOLDER}" STREQUAL "") |
| 920 | get_filename_component(RESOURCE_FOLDER ${RESOURCE_FOLDER} NAME) |
| 921 | OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR_RESOURCE}/${RESOURCE_FOLDER}") |
| 922 | else() |
| 923 | OCCT_INSTALL_FILE_OR_DIR ("src/${RESOURCE}" "${INSTALL_DIR_RESOURCE}") |
| 924 | endif() |
| 925 | endforeach() |
| 926 | |
| 927 | # patch installed DrawDefault file if BUILD_SHARED_LIBRARY_NAME_POSTFIX is changed |
| 928 | if (NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "") |
| 929 | OCCT_UPDATE_DRAW_DEFAULT_FILE() |
| 930 | endif() |
| 931 | |
| 932 | # include patched toolkit projects or original ones |
| 933 | foreach (BUILD_TOOLKIT ${BUILD_TOOLKITS}) |
| 934 | OCCT_ADD_SUBDIRECTORY ("src/${BUILD_TOOLKIT}") |
| 935 | endforeach() |
| 936 | |
| 937 | if (BUILD_DOC_Overview) |
| 938 | OCCT_ADD_SUBDIRECTORY (dox) |
| 939 | endif() |
| 940 | |
| 941 | # patch DRAWEXE |
| 942 | if (MSVC AND 3RDPARTY_DLL_DIRS) |
| 943 | list (FIND BUILD_TOOLKITS DRAWEXE DRAWEXE_INDEX) |
| 944 | if (${DRAWEXE_INDEX} GREATER -1) |
| 945 | list (REMOVE_DUPLICATES 3RDPARTY_DLL_DIRS) |
| 946 | set (3RDPARTY_DLL_DIRS_FOR_PATH "") |
| 947 | |
| 948 | foreach (3RDPARTY_DLL_DIR ${3RDPARTY_DLL_DIRS}) |
| 949 | set (3RDPARTY_DLL_DIRS_FOR_PATH "${3RDPARTY_DLL_DIRS_FOR_PATH};${3RDPARTY_DLL_DIR}") |
| 950 | endforeach() |
| 951 | |
| 952 | OCCT_MAKE_COMPILER_BITNESS() |
| 953 | set (X_COMPILER_BITNESS "x64") |
| 954 | if ("${COMPILER_BITNESS}" STREQUAL "32") |
| 955 | set (X_COMPILER_BITNESS "Win32") |
| 956 | endif() |
| 957 | |
| 958 | OCCT_CONFIGURE ("adm/templates/DRAWEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/src/DRAWEXE/DRAWEXE.vcxproj.user") |
| 959 | endif() |
| 960 | endif() |
| 961 | |
| 962 | # include patched toolkit projects or original ones |
| 963 | if (BUILD_TOOL_TOOLKITS) |
| 964 | foreach (BUILD_TOOL_TOOLKIT ${BUILD_TOOL_TOOLKITS}) |
| 965 | OCCT_ADD_SUBDIRECTORY ("tools/${BUILD_TOOL_TOOLKIT}") |
| 966 | endforeach() |
| 967 | endif() |
| 968 | |
| 969 | message (STATUS "Info: \(${CURRENT_TIME}\) OCCT toolkits processed") |
| 970 | # samples do not support patch usage |
| 971 | if (BUILD_MODULE_MfcSamples) |
| 972 | set (OCCT_ROOT ${CMAKE_SOURCE_DIR}) |
| 973 | |
| 974 | set (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard) |
| 975 | set (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp) |
| 976 | |
| 977 | add_subdirectory(samples/mfc/standard/mfcsample) |
| 978 | add_subdirectory(samples/mfc/standard/01_Geometry) |
| 979 | add_subdirectory(samples/mfc/standard/02_Modeling) |
| 980 | add_subdirectory(samples/mfc/standard/03_Viewer2d) |
| 981 | add_subdirectory(samples/mfc/standard/04_Viewer3d) |
| 982 | add_subdirectory(samples/mfc/standard/05_ImportExport) |
| 983 | add_subdirectory(samples/mfc/standard/06_Ocaf) |
| 984 | add_subdirectory(samples/mfc/standard/07_Triangulation) |
| 985 | add_subdirectory(samples/mfc/standard/08_HLR) |
| 986 | add_subdirectory(samples/mfc/standard/09_Animation) |
| 987 | add_subdirectory(samples/mfc/standard/10_Convert) |
| 988 | |
| 989 | message (STATUS "Info: \(${CURRENT_TIME}\) MFC Sample projects added") |
| 990 | endif() |
| 991 | |
| 992 | if (BUILD_MODULE_UwpSample) |
| 993 | add_subdirectory(samples/xaml) |
| 994 | endif() |
| 995 | |
| 996 | if (BUILD_TOOL_TOOLKITS) |
| 997 | # copy tinspector script to install script folder |
| 998 | if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/adm/templates/inspector.${SCRIPT_EXT}") |
| 999 | install (FILES "${BUILD_PATCH}/adm/templates/inspector.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}" |
| 1000 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE) |
| 1001 | else() |
| 1002 | install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/inspector.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}" |
| 1003 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE) |
| 1004 | endif() |
| 1005 | |
| 1006 | set (BUILD_SAMPLE_TOOLKITS TInspectorEXE) |
| 1007 | foreach (BUILD_SAMPLE_TOOL_TOOLKIT ${BUILD_SAMPLE_TOOLKITS}) |
| 1008 | OCCT_ADD_SUBDIRECTORY ("samples/tools/${BUILD_SAMPLE_TOOL_TOOLKIT}") |
| 1009 | endforeach() |
| 1010 | |
| 1011 | # patch TInspectorEXE |
| 1012 | OCCT_CONFIGURE ("adm/templates/TInspectorEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/samples/tools/TInspectorEXE/TInspectorEXE.vcxproj.user") |
| 1013 | endif() |
| 1014 | |
| 1015 | # Prepare variables for configuration of OpenCASCADE cmake config file |
| 1016 | set (OCCT_MODULES_ENABLED) |
| 1017 | set (OCCT_LIBRARIES) |
| 1018 | set (SET_OpenCASCADE_MODULES_TOOLKITS "\n# List of available OpenCASCADE libraries for each module\n") |
| 1019 | set (OCCT_COMPILE_DEFINITIONS) |
| 1020 | |
| 1021 | foreach (OCCT_TOOLKIT ${BUILD_TOOLKITS}) |
| 1022 | if (TARGET ${OCCT_TOOLKIT}) |
| 1023 | |
| 1024 | # get all libraries |
| 1025 | get_target_property (${OCCT_TOOLKIT}_TYPE ${OCCT_TOOLKIT} "TYPE") |
| 1026 | if ("${${OCCT_TOOLKIT}_TYPE}" STREQUAL "STATIC_LIBRARY" OR "${${OCCT_TOOLKIT}_TYPE}" STREQUAL "SHARED_LIBRARY" ) |
| 1027 | list (APPEND OCCT_LIBRARIES ${OCCT_TOOLKIT}) |
| 1028 | |
| 1029 | # get all modules |
| 1030 | get_target_property (${OCCT_TOOLKIT}_MODULE ${OCCT_TOOLKIT} "MODULE") |
| 1031 | list (APPEND OCCT_MODULES_ENABLED ${${OCCT_TOOLKIT}_MODULE}) |
| 1032 | list (APPEND OpenCASCADE_${${OCCT_TOOLKIT}_MODULE}_TOOLKITS ${OCCT_TOOLKIT}) |
| 1033 | |
| 1034 | # get compile definitions of target directory |
| 1035 | get_directory_property (COMPILE_DEFINITIONS DIRECTORY "${${OCCT_TOOLKIT}_SOURCE_DIR}" "COMPILE_DEFINITIONS") |
| 1036 | list (APPEND OCCT_COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS}) |
| 1037 | endif() |
| 1038 | endif() |
| 1039 | endforeach() |
| 1040 | list (REMOVE_DUPLICATES OCCT_MODULES_ENABLED) |
| 1041 | list (REMOVE_DUPLICATES OCCT_COMPILE_DEFINITIONS) |
| 1042 | |
| 1043 | # export compile definitions and C/C++ flags for each configuration to OpenCASCADE config files |
| 1044 | foreach (OCCT_CONFIGURATION ${CMAKE_CONFIGURATION_TYPES}) |
| 1045 | set (SET_OpenCASCADE_COMPILE_DEFINITIONS) |
| 1046 | string (TOUPPER "${OCCT_CONFIGURATION}" OCCT_CONFIGURATION_UPPER) |
| 1047 | string (TOLOWER "${OCCT_CONFIGURATION}" OCCT_CONFIGURATION_LOWER) |
| 1048 | foreach(COMPILE_DEFINITION ${OCCT_COMPILE_DEFINITIONS}) |
| 1049 | string(REPLACE "(" "\\(" COMPILE_DEFINITION "${COMPILE_DEFINITION}") |
| 1050 | string(REPLACE ")" "\\)" COMPILE_DEFINITION "${COMPILE_DEFINITION}") |
| 1051 | set (SET_OpenCASCADE_COMPILE_DEFINITIONS "${SET_OpenCASCADE_COMPILE_DEFINITIONS}set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:${OCCT_CONFIGURATION}>:${COMPILE_DEFINITION}>)\n") |
| 1052 | endforeach() |
| 1053 | set (SET_OpenCASCADE_CMAKE_C_FLAGS "${CMAKE_C_FLAGS_${OCCT_CONFIGURATION_UPPER}}") |
| 1054 | set (SET_OpenCASCADE_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_${OCCT_CONFIGURATION_UPPER}}") |
| 1055 | configure_file("${CMAKE_SOURCE_DIR}/adm/templates/OpenCASCADECompileDefinitionsAndFlags.cmake.in" "OpenCASCADECompileDefinitionsAndFlags-${OCCT_CONFIGURATION_LOWER}.cmake" @ONLY) |
| 1056 | endforeach() |
| 1057 | # install OpenCASCADE config file with compile definitions and C/C++ flags ONLY for current configuration |
| 1058 | install (CODE "string (TOLOWER \"\${CMAKE_INSTALL_CONFIG_NAME}\" CMAKE_INSTALL_CONFIG_NAME_LOWER)") |
| 1059 | install (CODE "configure_file(\"${CMAKE_BINARY_DIR}/OpenCASCADECompileDefinitionsAndFlags-\${CMAKE_INSTALL_CONFIG_NAME_LOWER}.cmake\" \"${INSTALL_DIR}/${INSTALL_DIR_CMAKE}/OpenCASCADECompileDefinitionsAndFlags-\${CMAKE_INSTALL_CONFIG_NAME_LOWER}.cmake\" COPYONLY)") |
| 1060 | |
| 1061 | foreach (OCCT_MODULE ${OCCT_MODULES}) |
| 1062 | if (BUILD_MODULE_${OCCT_MODULE}) |
| 1063 | set (SET_OpenCASCADE_MODULES_TOOLKITS "${SET_OpenCASCADE_MODULES_TOOLKITS}set (OpenCASCADE_${OCCT_MODULE}_LIBRARIES ${OpenCASCADE_${OCCT_MODULE}_TOOLKITS})\n") |
| 1064 | endif() |
| 1065 | |
| 1066 | # sort enabled modules for correct work of OpenCASCADE config file |
| 1067 | list(FIND OCCT_MODULES_ENABLED "${OCCT_MODULE}" OCCT_MODULE_INDEX) |
| 1068 | if (NOT ${OCCT_MODULE_INDEX} EQUAL -1) |
| 1069 | list (APPEND OCCT_MODULES_ENABLED_SORTED ${OCCT_MODULE}) |
| 1070 | endif() |
| 1071 | endforeach() |
| 1072 | set (OCCT_MODULES_ENABLED ${OCCT_MODULES_ENABLED_SORTED}) |
| 1073 | |
| 1074 | # Add all targets to the build-tree export set |
| 1075 | export (TARGETS ${OCCT_LIBRARIES} FILE "${CMAKE_BINARY_DIR}/OpenCASCADETargets.cmake") |
| 1076 | |
| 1077 | # Export the package for use from the build-tree |
| 1078 | # (this registers the build-tree with a global CMake-registry) |
| 1079 | export(PACKAGE OpenCASCADE) |
| 1080 | |
| 1081 | if (CMAKE_BUILD_TYPE) |
| 1082 | set (SET_OpenCASCADE_BUILD_TYPE "set (OpenCASCADE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")") |
| 1083 | endif() |
| 1084 | |
| 1085 | if (BUILD_SHARED_LIBS) |
| 1086 | set (SET_OpenCASCADE_LINKER_FLAGS "set (OpenCASCADE_LINKER_FLAGS \"${CMAKE_SHARED_LINKER_FLAGS}\")") |
| 1087 | else() |
| 1088 | set (SET_OpenCASCADE_LINKER_FLAGS "set (OpenCASCADE_LINKER_FLAGS \"${CMAKE_STATIC_LINKER_FLAGS}\")") |
| 1089 | endif() |
| 1090 | |
| 1091 | if (WIN32) |
| 1092 | set (SET_OpenCASCADE_WITH_D3D "set (OpenCASCADE_WITH_D3D ${USE_D3D})") |
| 1093 | endif() |
| 1094 | if (APPLE) |
| 1095 | set (SET_OpenCASCADE_WITH_GLX "set (OpenCASCADE_WITH_GLX ${USE_GLX})") |
| 1096 | endif() |
| 1097 | |
| 1098 | if (NOT SINGLE_GENERATOR) |
| 1099 | OCCT_INSERT_CODE_FOR_TARGET() |
| 1100 | endif() |
| 1101 | |
| 1102 | # Configure and install cmake config file |
| 1103 | configure_file("${CMAKE_SOURCE_DIR}/adm/templates/OpenCASCADEConfig.cmake.in" "OpenCASCADEConfig.cmake" @ONLY) |
| 1104 | install(FILES "${CMAKE_BINARY_DIR}/OpenCASCADEConfig.cmake" DESTINATION "${INSTALL_DIR_CMAKE}") |
| 1105 | |
| 1106 | # Configure cmake version file |
| 1107 | include(CMakePackageConfigHelpers) |
| 1108 | write_basic_package_version_file( ${CMAKE_BINARY_DIR}/OpenCASCADEConfigVersion.cmake |
| 1109 | VERSION ${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE} |
| 1110 | COMPATIBILITY ExactVersion ) |
| 1111 | |
| 1112 | # Install cmake version file |
| 1113 | install (FILES "${CMAKE_BINARY_DIR}/OpenCASCADEConfigVersion.cmake" DESTINATION "${INSTALL_DIR_CMAKE}") |
| 1114 | |
| 1115 | # Install the export set for use with the install-tree for each configuration |
| 1116 | foreach (OCCT_MODULE ${OCCT_MODULES_ENABLED}) |
| 1117 | install(EXPORT OpenCASCADE${OCCT_MODULE}Targets DESTINATION "${INSTALL_DIR_CMAKE}") |
| 1118 | endforeach() |
| 1119 | |
| 1120 | # Update generated OpenCASCADETargets-*.cmake files |
| 1121 | # to have correct paths to libraries depending on the configuration |
| 1122 | OCCT_UPDATE_TARGET_FILE () |
| 1123 | |
| 1124 | message (STATUS "Info: \(${CURRENT_TIME}\) OCCT configuration files prepared") |