diff --git a/CMakeLists.txt b/CMakeLists.txt index b0851c131c..db60f336d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,9 +24,14 @@ endif() if ("${BUILD_LIBRARY_TYPE}" STREQUAL "Shared") set (BUILD_SHARED_LIBS ON) + + if (NOT DEFINED BUILD_SHARED_LIBRARY_NAME_POSTFIX) + set (BUILD_SHARED_LIBRARY_NAME_POSTFIX "" CACHE STRING "${BUILD_SHARED_LIBRARY_NAME_POSTFIX_DESCR}" FORCE) + endif() else() unset (BUILD_SHARED_LIBS) message (STATUS "Info: Only 3rdparty's header files are used for building of static OCCT libraries") + unset (BUILD_SHARED_LIBRARY_NAME_POSTFIX) endif() # the name of the project @@ -724,6 +729,11 @@ foreach(RESOURCE ${RESOURCES}) endif() endforeach() +# patch installed DrawDefault file if BUILD_SHARED_LIBRARY_NAME_POSTFIX is changed +if (NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "") + OCCT_UPDATE_DRAW_DEFAULT_FILE() +endif() + # define CSF variable OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_csf") diff --git a/adm/cmake/occt_macros.cmake b/adm/cmake/occt_macros.cmake index b8c8359e54..057cac0acf 100644 --- a/adm/cmake/occt_macros.cmake +++ b/adm/cmake/occt_macros.cmake @@ -576,3 +576,26 @@ macro (OCCT_INSERT_CODE_FOR_TARGET) set (OCCT_INSTALL_BIN_LETTER \"d\") endif()") endmacro() + +macro (OCCT_UPDATE_DRAW_DEFAULT_FILE) + install(CODE "cmake_policy(PUSH) + cmake_policy(SET CMP0007 NEW) + set (DRAW_DEFAULT_FILE_NAME \"${INSTALL_DIR}/${INSTALL_DIR_RESOURCE}/DrawResources/DrawPlugin\") + file (STRINGS \"\${DRAW_DEFAULT_FILE_NAME}\" DRAW_DEFAULT_CONTENT) + file (REMOVE \"\${DRAW_DEFAULT_FILE_NAME}\") + foreach (line IN LISTS DRAW_DEFAULT_CONTENT) + string (REGEX MATCH \": TK\([a-zA-Z]+\)$\" IS_TK_LINE \"\${line}\") + string (REGEX REPLACE \": TK\([a-zA-Z]+\)$\" \": TK\${CMAKE_MATCH_1}${BUILD_SHARED_LIBRARY_NAME_POSTFIX}\" line \"\${line}\") + file (APPEND \"\${DRAW_DEFAULT_FILE_NAME}\" \"\${line}\\n\") + endforeach() + cmake_policy(POP)") +endmacro() + +macro (OCCT_CREATE_SYMLINK_TO_FILE LIBRARY_NAME LINK_NAME) + if (NOT WIN32) + install (CODE "if (EXISTS \"${LIBRARY_NAME}\") + execute_process (COMMAND ln -s \"${LIBRARY_NAME}\" \"${LINK_NAME}\") + endif() + ") + endif() +endmacro() diff --git a/adm/cmake/occt_toolkit.cmake b/adm/cmake/occt_toolkit.cmake index a7cd3b98eb..6b33c45b38 100644 --- a/adm/cmake/occt_toolkit.cmake +++ b/adm/cmake/occt_toolkit.cmake @@ -152,11 +152,25 @@ else() CONFIGURATIONS Debug DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}") endif() + + if (BUILD_SHARED_LIBS AND NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "") + set (CMAKE_SHARED_LIBRARY_SUFFIX_DEFAULT ${CMAKE_SHARED_LIBRARY_SUFFIX}) + set (CMAKE_SHARED_LIBRARY_SUFFIX "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif() + install (TARGETS ${PROJECT_NAME} EXPORT OpenCASCADE${CURRENT_MODULE}Targets RUNTIME DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}" ARCHIVE DESTINATION "${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}" LIBRARY DESTINATION "${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}") + + if (NOT WIN32) + if (BUILD_SHARED_LIBS AND NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "") + set (LINK_NAME "${INSTALL_DIR}/${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX_DEFAULT}") + set (LIBRARY_NAME "${INSTALL_DIR}/${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}") + OCCT_CREATE_SYMLINK_TO_FILE (${LIBRARY_NAME} ${LINK_NAME}) + endif() + endif() endif() if (CURRENT_MODULE) diff --git a/adm/cmake/vardescr.cmake b/adm/cmake/vardescr.cmake index 9ffa0bb5e5..0c49d40c5a 100644 --- a/adm/cmake/vardescr.cmake +++ b/adm/cmake/vardescr.cmake @@ -22,6 +22,9 @@ set (BUILD_WITH_DEBUG_DESCR "Enables extended messages of many OCCT algorithms, usually printed to cout. These include messages on internal errors and special cases encountered, timing etc") +set (BUILD_SHARED_LIBRARY_NAME_POSTFIX_DESCR +"Append the postfix to names of output libraries") + # install variables set (INSTALL_DIR_DESCR "The place where built OCCT libraries, headers, test cases (INSTALL_TEST_CASES variable),