0027351: Custom OCCT DLL name suffixes
authorski <ski@opencascade.com>
Fri, 8 Apr 2016 13:55:24 +0000 (16:55 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 14 Apr 2016 10:13:05 +0000 (13:13 +0300)
Added generation of libraries with postfix.

CMakeLists.txt
adm/cmake/occt_macros.cmake
adm/cmake/occt_toolkit.cmake
adm/cmake/vardescr.cmake

index b0851c1..db60f33 100644 (file)
@@ -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")
 
index b8c8359..057cac0 100644 (file)
@@ -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()
index a7cd3b9..6b33c45 100644 (file)
@@ -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)
index 9ffa0bb..0c49d40 100644 (file)
@@ -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),