Revision: 44597
          http://brlcad.svn.sourceforge.net/brlcad/?rev=44597&view=rev
Author:   starseeker
Date:     2011-05-10 14:56:25 +0000 (Tue, 10 May 2011)

Log Message:
-----------
Add some comments to the third party logic.

Modified Paths:
--------------
    brlcad/trunk/misc/CMake/ThirdParty.cmake

Modified: brlcad/trunk/misc/CMake/ThirdParty.cmake
===================================================================
--- brlcad/trunk/misc/CMake/ThirdParty.cmake    2011-05-10 13:25:45 UTC (rev 
44596)
+++ brlcad/trunk/misc/CMake/ThirdParty.cmake    2011-05-10 14:56:25 UTC (rev 
44597)
@@ -1,19 +1,26 @@
 #-----------------------------------------------------------------------------
 MACRO(THIRD_PARTY_OPTION upper lower)
+       # Set up local forcing functions, if not already set up.
        OPTION(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_ON "Force the 
building of the local ${upper} library." OFF)
        MARK_AS_ADVANCED(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_ON)
        OPTION(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_OFF "Force 
disabling the local ${upper} library build." OFF)
        MARK_AS_ADVANCED(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_OFF)
+
+       # Deal with the case where both FORCE_ON and FORCE_OFF are enabled
        IF(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_ON AND 
${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_OFF)
                MESSAGE("Warning - both force options for ${upper} found - 
going with enable")
                SET(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_OFF OFF 
CACHE BOOL "Force disabling the local ${upper} library build." FORCE)
        ENDIF(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_ON AND 
${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_OFF)
+
+       # Set BUILD_LOCAL variable based on FORCE options, if enabled
        IF(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_ON)
                SET(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper} ON CACHE BOOL 
"Build the local ${upper} library." FORCE)
        ENDIF(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_ON)
        IF(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_OFF)
                SET(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper} OFF CACHE BOOL 
"Build the local ${upper} library." FORCE)
        ENDIF(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_OFF)
+
+       # Handle ENABLE_ALL option
        IF(${CMAKE_PROJECT_NAME}-ENABLE_ALL_LOCAL_LIBS)
                OPTION(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper} "Build the 
local ${upper} library." ON)
                IF(NOT ${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_OFF)
@@ -25,37 +32,41 @@
                        SET(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper} OFF 
CACHE BOOL "Build the local ${upper} library." FORCE)
                ENDIF(NOT ${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper}_FORCE_ON)
        ENDIF(${CMAKE_PROJECT_NAME}-ENABLE_ALL_LOCAL_LIBS)
+
+       # Main search logic
        IF(NOT ${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper} OR 
${CMAKE_PROJECT_NAME}-ENABLE_SYSTEM_LIBS_ONLY)
+               # Initialize (or rather, uninitialize) variables in preparation 
for search
                SET(${upper}_FOUND "${upper}-NOTFOUND" CACHE STRING 
"${upper}_FOUND" FORCE)
                MARK_AS_ADVANCED(${upper}_FOUND)
                SET(${upper}_LIBRARY "${upper}-NOTFOUND" CACHE STRING 
"${upper}_LIBRARY" FORCE)
                SET(${upper}_INCLUDE_DIR "${upper}-NOTFOUND" CACHE STRING 
"${upper}_INCLUDE_DIR" FORCE)
+               # Include the Find module for the library in question
                IF(EXISTS ${${CMAKE_PROJECT_NAME}_CMAKE_DIR}/Find${upper}.cmake)
                        
INCLUDE(${${CMAKE_PROJECT_NAME}_CMAKE_DIR}/Find${upper}.cmake)
                ELSE(EXISTS 
${${CMAKE_PROJECT_NAME}_CMAKE_DIR}/Find${upper}.cmake)
                        INCLUDE(${CMAKE_ROOT}/Modules/Find${upper}.cmake)
                ENDIF(EXISTS 
${${CMAKE_PROJECT_NAME}_CMAKE_DIR}/Find${upper}.cmake)
+               # If we didn't find it, and options allow it, enable the local 
copy
                IF(NOT ${upper}_FOUND)
                        IF(NOT ${CMAKE_PROJECT_NAME}-ENABLE_SYSTEM_LIBS_ONLY) 
                                SET(${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper} 
ON CACHE BOOL "Build the local ${upper} library." FORCE)
                                SET(${upper}_LIBRARY "${lower}" CACHE STRING 
"set by THIRD_PARTY macro" FORCE)
                        ENDIF(NOT 
${CMAKE_PROJECT_NAME}-ENABLE_SYSTEM_LIBS_ONLY) 
-      ELSE(NOT ${upper}_FOUND)
-               # We have to remove any previously built output from enabled 
local copies of the
-               # library in question, or the linker will get confused - a 
system lib was found and
-               # system libraries are to be preferred with current options.  
This is unfortunate in
-               # that it may introduce extra build work just from trying 
configure options, but appears
-               # to be essential to ensuring that the build "just works" each 
time.
-               STRING(REGEX REPLACE "lib" "" rootname "${lower}")
-               FILE(GLOB STALE_FILES 
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_SHARED_LIBRARY_PREFIX}${rootname}*${CMAKE_SHARED_LIBRARY_SUFFIX}*")
-               FOREACH(stale_file ${STALE_FILES})
-                  EXEC_PROGRAM(
-                          ${CMAKE_COMMAND} ARGS -E remove ${stale_file}
-                                        OUTPUT_VARIABLE rm_out
-                                        RETURN_VALUE rm_retval
-                                )
-               ENDFOREACH(stale_file ${STALE_FILES})
-
+               ELSE(NOT ${upper}_FOUND)
+                       # We have to remove any previously built output from 
enabled local copies of the
+                       # library in question, or the linker will get confused 
- a system lib was found and
+                       # system libraries are to be preferred with current 
options.  This is unfortunate in
+                       # that it may introduce extra build work just from 
trying configure options, but appears
+                       # to be essential to ensuring that the build "just 
works" each time.
+                       STRING(REGEX REPLACE "lib" "" rootname "${lower}")
+                       FILE(GLOB STALE_FILES 
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_SHARED_LIBRARY_PREFIX}${rootname}*${CMAKE_SHARED_LIBRARY_SUFFIX}*")
+                       FOREACH(stale_file ${STALE_FILES})
+                               EXEC_PROGRAM(
+                                       ${CMAKE_COMMAND} ARGS -E remove 
${stale_file}
+                                       OUTPUT_VARIABLE rm_out
+                                       RETURN_VALUE rm_retval
+                                       )
+                       ENDFOREACH(stale_file ${STALE_FILES})
                ENDIF(NOT ${upper}_FOUND)
        ELSE(NOT ${CMAKE_PROJECT_NAME}_BUILD_LOCAL_${upper} OR 
${CMAKE_PROJECT_NAME}-ENABLE_SYSTEM_LIBS_ONLY)
                SET(${upper}_LIBRARY "${lower}" CACHE STRING "set by 
THIRD_PARTY macro" FORCE)


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to