diff --git a/adm/cmake/draco.cmake b/adm/cmake/draco.cmake index 755391fa52..cebc75df99 100644 --- a/adm/cmake/draco.cmake +++ b/adm/cmake/draco.cmake @@ -3,10 +3,6 @@ OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros") -if (NOT DEFINED INSTALL_DRACO) - set (INSTALL_DRACO OFF CACHE BOOL "${INSTALL_DRACO_DESCR}") -endif() - if (NOT DEFINED 3RDPARTY_DRACO_DIR) set (3RDPARTY_DRACO_DIR "" CACHE PATH "The directory containing Draco") endif() @@ -15,14 +11,24 @@ if (NOT DEFINED 3RDPARTY_DRACO_INCLUDE_DIR) set (3RDPARTY_DRACO_INCLUDE_DIR "" CACHE PATH "The directory containing headers of the Draco") endif() -if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY OR NOT 3RDPARTY_DRACO_LIBRARY_DIR OR NOT EXISTS "${3RDPARTY_DRACO_LIBRARY_DIR}") - set (3RDPARTY_DRACO_LIBRARY "" CACHE FILEPATH "Draco library" FORCE) +if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY) + set (3RDPARTY_DRACO_LIBRARY "" CACHE FILEPATH "Draco library") endif() if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY_DIR) set (3RDPARTY_DRACO_LIBRARY_DIR "" CACHE PATH "The directory containing Draco library") endif() +if (WIN32) + if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY_DEBUG) + set (3RDPARTY_DRACO_LIBRARY_DEBUG "" CACHE FILEPATH "Draco debug library") + endif() + + if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY_DIR_DEBUG) + set (3RDPARTY_DRACO_LIBRARY_DIR_DEBUG "" CACHE PATH "The directory containing Draco debug library") + endif() +endif() + if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}") if (NOT 3RDPARTY_DRACO_DIR OR NOT EXISTS "${3RDPARTY_DRACO_DIR}") FIND_PRODUCT_DIR("${3RDPARTY_DIR}" draco DRACO_DIR_NAME) @@ -32,20 +38,19 @@ if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}") endif() endif() -if (3RDPARTY_DRACO_DIR AND EXISTS "${3RDPARTY_DRACO_DIR}") - set (DRACO_INCLUDE_PATH "${3RDPARTY_DRACO_DIR}/include") - set (DRACO_LIBRARY_PATH "${3RDPARTY_DRACO_DIR}/lib") -endif() +# header +if (NOT 3RDPARTY_DRACO_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_DRACO_INCLUDE_DIR}") + set (HEADER_NAMES draco) -if (NOT 3RDPARTY_DRACO_INCLUDE_DIR) - if (DRACO_INCLUDE_PATH AND EXISTS "${DRACO_INCLUDE_PATH}") - set (3RDPARTY_DRACO_INCLUDE_DIR "${DRACO_INCLUDE_PATH}" CACHE FILEPATH "The directory containing headers of DRACO" FORCE) - endif() -endif() + # set 3RDPARTY_DRACO_INCLUDE_DIR as notfound, otherwise find_path can't assign a new value to 3RDPARTY_DRACO_INCLUDE_DIR + set (3RDPARTY_DRACO_INCLUDE_DIR "3RDPARTY_DRACO_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "The directory containing headers of the Draco" FORCE) -if (NOT 3RDPARTY_DRACO_LIBRARY_DIR) - if (DRACO_LIBRARY_PATH AND EXISTS "${DRACO_LIBRARY_PATH}") - set (3RDPARTY_DRACO_LIBRARY_DIR "${DRACO_LIBRARY_PATH}" CACHE FILEPATH "The directory containing DRACO library" FORCE) + if (3RDPARTY_DRACO_DIR AND EXISTS "${3RDPARTY_DRACO_DIR}") + find_path (3RDPARTY_DRACO_INCLUDE_DIR NAMES ${HEADER_NAMES} + PATHS ${3RDPARTY_DRACO_DIR} + PATH_SUFFIXES "include" + CMAKE_FIND_ROOT_PATH_BOTH + NO_DEFAULT_PATH) endif() endif() @@ -57,11 +62,11 @@ endif() if (3RDPARTY_DRACO_DIR AND EXISTS "${3RDPARTY_DRACO_DIR}") if (NOT 3RDPARTY_DRACO_LIBRARY OR NOT EXISTS "${3RDPARTY_DRACO_LIBRARY}") - set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .so .dylib .a) + set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .a) set (3RDPARTY_DRACO_LIBRARY "3RDPARTY_DRACO_LIBRARY-NOTFOUND" CACHE FILEPATH "The path to Draco library" FORCE) find_library (3RDPARTY_DRACO_LIBRARY NAMES ${CSF_Draco} - PATHS "${3RDPARTY_DRACO_LIBRARY_DIR}" + PATHS "${3RDPARTY_DRACO_DIR}" PATH_SUFFIXES lib CMAKE_FIND_ROOT_PATH_BOTH NO_DEFAULT_PATH) @@ -70,27 +75,19 @@ if (3RDPARTY_DRACO_DIR AND EXISTS "${3RDPARTY_DRACO_DIR}") set (3RDPARTY_DRACO_LIBRARY_DIR "${3RDPARTY_DRACO_LIBRARY_DIR}" CACHE FILEPATH "The directory containing Draco library" FORCE) endif() endif() -endif() -if (3RDPARTY_DRACO_LIBRARY_DIR AND EXISTS "${3RDPARTY_DRACO_LIBRARY_DIR}") - list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_DRACO_LIBRARY_DIR}") -else() - list (APPEND 3RDPARTY_NO_LIBS 3RDPARTY_DRACO_LIBRARY_DIR) -endif() + if (WIN32 AND (NOT 3RDPARTY_DRACO_LIBRARY_DEBUG OR NOT EXISTS "${3RDPARTY_DRACO_LIBRARY_DEBUG}")) + set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .a) + set (3RDPARTY_DRACO_LIBRARY_DEBUG "3RDPARTY_DRACO_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "The path to debug Draco library" FORCE) -if (INSTALL_DRACO) - get_filename_component(3RDPARTY_DRACO_LIBRARY_REALPATH ${3RDPARTY_DRACO_LIBRARY} REALPATH) - if (SINGLE_GENERATOR) - install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH} DESTINATION "${INSTALL_DIR_LIB}") - else() - install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH} - CONFIGURATIONS Release - DESTINATION "${INSTALL_DIR_LIB}") - install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH} - CONFIGURATIONS RelWithDebInfo - DESTINATION "${INSTALL_DIR_LIB}i") - install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH} - CONFIGURATIONS Debug - DESTINATION "${INSTALL_DIR_LIB}d") + find_library (3RDPARTY_DRACO_LIBRARY_DEBUG NAMES ${CSF_Draco} + PATHS "${3RDPARTY_DRACO_DIR}" + PATH_SUFFIXES libd + CMAKE_FIND_ROOT_PATH_BOTH + NO_DEFAULT_PATH) + if (3RDPARTY_DRACO_LIBRARY_DEBUG AND EXISTS "${3RDPARTY_DRACO_LIBRARY_DEBUG}") + get_filename_component (3RDPARTY_DRACO_LIBRARY_DIR_DEBUG "${3RDPARTY_DRACO_LIBRARY_DEBUG}" PATH) + set (3RDPARTY_DRACO_LIBRARY_DIR_DEBUG "${3RDPARTY_DRACO_LIBRARY_DIR_DEBUG}" CACHE FILEPATH "The directory containing debug Draco library" FORCE) + endif() endif() endif() diff --git a/adm/cmake/occt_toolkit.cmake b/adm/cmake/occt_toolkit.cmake index 517d1b47fa..132890bc84 100644 --- a/adm/cmake/occt_toolkit.cmake +++ b/adm/cmake/occt_toolkit.cmake @@ -370,6 +370,10 @@ foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS}) add_definitions (-DHAVE_GLES2) endif() + if ("${CURRENT_CSF}" STREQUAL "${CSF_Draco}") + set (CURRENT_CSF "") + set (USED_DRACO 1) + endif() set (LIBRARY_FROM_CACHE 0) separate_arguments (CURRENT_CSF) foreach (CSF_LIBRARY ${CURRENT_CSF}) @@ -397,7 +401,7 @@ foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS}) endforeach() endforeach() - if (NOT ${LIBRARY_FROM_CACHE}) + if (NOT ${LIBRARY_FROM_CACHE} AND NOT "${CURRENT_CSF}" STREQUAL "") # prepare a list from a string with whitespaces separate_arguments (CURRENT_CSF) list (APPEND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT ${CURRENT_CSF}) @@ -408,6 +412,28 @@ foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS}) endif() endforeach() +if (USE_DRACO) + if (USED_DRACO) + set (USED_LIB_RELEASE ${3RDPARTY_DRACO_LIBRARY}) + if (WIN32) + set (USED_LIB_DEBUG ${3RDPARTY_DRACO_LIBRARY_DEBUG}) + else() + set (USED_LIB_DEBUG ${3RDPARTY_DRACO_LIBRARY}) + endif() + set (USED_LIB_CONF) + if (EXISTS ${USED_LIB_DEBUG}) + set (USED_LIB_CONF "$<$:${USED_LIB_DEBUG}>;${USED_LIB_CONF}") + endif() + if (EXISTS ${USED_LIB_RELEASE}) + set (USED_LIB_CONF "$<$:${USED_LIB_RELEASE}>;${USED_LIB_CONF}") + set (USED_LIB_CONF "$<$:${USED_LIB_RELEASE}>;${USED_LIB_CONF}") + endif() + if (DEFINED USED_LIB_CONF) + set_property (TARGET ${PROJECT_NAME} APPEND PROPERTY LINK_LIBRARIES "${USED_LIB_CONF}") + endif() + endif() +endif() + if (APPLE) list (FIND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT X11 IS_X11_FOUND) if (NOT ${IS_X11_FOUND} EQUAL -1)