0024580: CMake doesn't unset becoming unused variables when 3rdparty's usage is switc...
authoribs <ibs@opencascade.com>
Tue, 28 Jan 2014 15:17:50 +0000 (19:17 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 30 Jan 2014 10:07:04 +0000 (14:07 +0400)
unset becoming unused variables when freeimage, opencl, tbb and gl2ps are switched off

CMakeLists.txt

index 1468ea7..e7cfe1d 100644 (file)
@@ -209,6 +209,19 @@ SET(USE_OPENCL OFF CACHE BOOL "whether use OpenCL or not")
 
 SET(INSTALL_TESTS OFF CACHE BOOL "Is tests copy to install directory")
 
+MACRO (CHECK_AND_UNSET VARNAME)
+  IF(DEFINED ${VARNAME})
+    UNSET(${VARNAME} CACHE)
+  ENDIF()
+ENDMACRO()
+
+MACRO (CHECK_AND_UNSET_GROUP VARNAME)
+  CHECK_AND_UNSET ("${VARNAME}_DIR")
+  CHECK_AND_UNSET ("${VARNAME}_INCLUDE_DIR")
+  CHECK_AND_UNSET ("${VARNAME}_DLL")
+  CHECK_AND_UNSET ("${VARNAME}_LIBRARY")
+ENDMACRO()
+
 MACRO(THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_NAME)
   IF(NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_DIR)
     SET(3RDPARTY_${PRODUCT_NAME}_DIR "" CACHE PATH "Directory contains ${PRODUCT_NAME} product")
@@ -382,12 +395,20 @@ IF(USE_FREEIMAGE)
     THIRDPARTY_PRODUCT("FREEIMAGEPLUS" "FreeImagePlus.h" "freeimageplus${BUILD_SUFFIX}")
 
   ENDIF()
+ELSE()
+  CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
+  CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
+  CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
+  CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
 ENDIF()
 
 # GL2PS
 IF(USE_GL2PS)
   ADD_DEFINITIONS(-DHAVE_GL2PS)
   THIRDPARTY_PRODUCT("GL2PS" "gl2ps.h" "gl2ps${BUILD_SUFFIX}")
+ELSE()
+  CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
+  CHECK_AND_UNSET ("INSTALL_GL2PS")
 ENDIF()
 
 # OPENCL
@@ -418,6 +439,11 @@ IF(USE_OPENCL)
   # if CL/cl.h isn't found (and 3RDPARTY_OPENCL_INCLUDE_DIR isn't defined)
   # then try to find OpenCL/cl.h (all other variable won't be changed)
   THIRDPARTY_PRODUCT("OPENCL" "OpenCL/cl.h" "OpenCL${BUILD_SUFFIX}")
+ELSE()
+  CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENCL")
+  CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB")
+  CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB")
+  CHECK_AND_UNSET ("INSTALL_OPENCL")
 ENDIF()
 
 # TBB
@@ -435,6 +461,11 @@ IF (USE_TBB)
     GET_FILENAME_COMPONENT(3RDPARTY_TBB_DLL_DIR "${3RDPARTY_TBB_DLL}" PATH)
     GET_FILENAME_COMPONENT(3RDPARTY_TBB_MALLOC_DLL_DIR "${3RDPARTY_TBB_MALLOC_DLL}" PATH)
   ENDIF()
+ELSE()
+  CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
+  CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB_MALLOC")
+  CHECK_AND_UNSET ("3RDPARTY_TBB_DIR_NAME")
+  CHECK_AND_UNSET ("INSTALL_TBB")
 ENDIF()
 
 string( REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")