INSTALL_DIR is synced with CMAKE_INSTALL_PREFIX . Change of any of these vars resets... V7_0_0_beta
authoribs <ibs@opencascade.com>
Thu, 24 Dec 2015 15:22:35 +0000 (18:22 +0300)
committerabv <abv@opencascade.com>
Fri, 25 Dec 2015 07:57:44 +0000 (10:57 +0300)
CMakeLists.txt

index 6bc670e..e2dad95 100644 (file)
@@ -72,10 +72,35 @@ if (NOT DEFINED INSTALL_DIR)
   set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}")
 endif()
 
-if ("${INSTALL_DIR}" STREQUAL "")
-  get_filename_component (CMAKE_BINARY_DIR_PARENT ${CMAKE_BINARY_DIR} DIRECTORY)
-  set (INSTALL_DIR "${CMAKE_BINARY_DIR_PARENT}/install" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
-  message (STATUS "Info: INSTALL_DIR has been set as ${INSTALL_DIR}")
+if (NOT DEFINED CMAKE_INSTALL_PREFIX_PREV)
+  set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE)
+elseif (NOT "${CMAKE_INSTALL_PREFIX_PREV}" STREQUAL "${CMAKE_INSTALL_PREFIX}")
+  # CMAKE_INSTALL_PREFIX has been changed at previous step
+  set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE)
+  
+  # INSTALL_DIR is required to be updated
+  set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
+endif()
+
+if (NOT DEFINED INSTALL_DIR_PREV)
+  set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
+elseif (NOT "${INSTALL_DIR_PREV}" STREQUAL "${INSTALL_DIR}")
+  # INSTALL_DIR has been changed at previous step
+  set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
+
+  # sync CMAKE_INSTALL_PREFIX with INSTALL_DIR 
+  set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
+
+  # set CMAKE_INSTALL_PREFIX_PREV to avoid the reset of structure of the install folder 
+  set (CMAKE_INSTALL_PREFIX_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
+
+  # The structure of install folder should be reset
+  OCCT_CHECK_AND_UNSET (INSTALL_BIN_DIR)
+  OCCT_CHECK_AND_UNSET (INSTALL_SCRIPT_DIR)
+  OCCT_CHECK_AND_UNSET (INSTALL_LIB_DIR)
+  OCCT_CHECK_AND_UNSET (INSTALL_INCLUDE_DIR)
+  OCCT_CHECK_AND_UNSET (INSTALL_OCCT_RESOURCE_DIR)
+  OCCT_CHECK_AND_UNSET (INSTALL_SHARE_DIR)
 endif()
 
 # hide CMAKE_INSTALL_PREFIX from a user