mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
Configuration - Optimize include copy logic #155
Avoiding re-copying the existed header file.
This commit is contained in:
parent
0744d56fee
commit
4ebc468140
@ -419,13 +419,37 @@ function (COLLECT_AND_INSTALL_OCCT_HEADER_FILES THE_ROOT_TARGET_OCCT_DIR THE_OCC
|
|||||||
endforeach()
|
endforeach()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
# Check that copying is done and match the include installation type.
|
||||||
|
# Check by first file in list.
|
||||||
|
list(GET OCCT_HEADER_FILES_COMPLETE 0 FIRST_OCCT_HEADER_FILE)
|
||||||
|
get_filename_component (FIRST_OCCT_HEADER_FILE ${FIRST_OCCT_HEADER_FILE} NAME)
|
||||||
|
set (TO_FORCE_COPY FALSE)
|
||||||
|
if (NOT EXISTS "${THE_ROOT_TARGET_OCCT_DIR}/${THE_OCCT_INSTALL_DIR_PREFIX}/${FIRST_OCCT_HEADER_FILE}")
|
||||||
|
set (TO_FORCE_COPY TRUE)
|
||||||
|
else()
|
||||||
|
# get content and check the number of lines inside file.
|
||||||
|
# If more then 1 then it is a symlink.
|
||||||
|
file (STRINGS "${THE_ROOT_TARGET_OCCT_DIR}/${THE_OCCT_INSTALL_DIR_PREFIX}/${FIRST_OCCT_HEADER_FILE}" FIRST_OCCT_HEADER_FILE_CONTENT)
|
||||||
|
list (LENGTH FIRST_OCCT_HEADER_FILE_CONTENT FIRST_OCCT_HEADER_FILE_CONTENT_LEN)
|
||||||
|
if (${FIRST_OCCT_HEADER_FILE_CONTENT_LEN} EQUAL 1 AND BUILD_INCLUDE_SYMLINK)
|
||||||
|
set (TO_FORCE_COPY TRUE)
|
||||||
|
elseif(${FIRST_OCCT_HEADER_FILE_CONTENT_LEN} GREATER 1 AND NOT BUILD_INCLUDE_SYMLINK)
|
||||||
|
set (TO_FORCE_COPY TRUE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
foreach (OCCT_HEADER_FILE ${OCCT_HEADER_FILES_COMPLETE})
|
foreach (OCCT_HEADER_FILE ${OCCT_HEADER_FILES_COMPLETE})
|
||||||
get_filename_component (HEADER_FILE_NAME ${OCCT_HEADER_FILE} NAME)
|
get_filename_component (HEADER_FILE_NAME ${OCCT_HEADER_FILE} NAME)
|
||||||
if (BUILD_INCLUDE_SYMLINK)
|
set(TARGET_FILE "${THE_ROOT_TARGET_OCCT_DIR}/${THE_OCCT_INSTALL_DIR_PREFIX}/${HEADER_FILE_NAME}")
|
||||||
file (CREATE_LINK "${OCCT_HEADER_FILE}" "${THE_ROOT_TARGET_OCCT_DIR}/${THE_OCCT_INSTALL_DIR_PREFIX}/${HEADER_FILE_NAME}" SYMBOLIC)
|
|
||||||
else()
|
# Check if the file already exists in the target directory
|
||||||
set (OCCT_HEADER_FILE_CONTENT "#include \"${OCCT_HEADER_FILE}\"")
|
if (TO_FORCE_COPY OR NOT EXISTS "${TARGET_FILE}")
|
||||||
configure_file ("${TEMPLATE_HEADER_PATH}" "${THE_ROOT_TARGET_OCCT_DIR}/${THE_OCCT_INSTALL_DIR_PREFIX}/${HEADER_FILE_NAME}" @ONLY)
|
if (BUILD_INCLUDE_SYMLINK)
|
||||||
|
file (CREATE_LINK "${OCCT_HEADER_FILE}" "${TARGET_FILE}" SYMBOLIC)
|
||||||
|
else()
|
||||||
|
set (OCCT_HEADER_FILE_CONTENT "#include \"${OCCT_HEADER_FILE}\"")
|
||||||
|
configure_file ("${TEMPLATE_HEADER_PATH}" "${TARGET_FILE}" @ONLY)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user