| 
      
      
      From: <ai...@us...> - 2013-12-03 23:56:33
      
     | 
| Revision: 12807
          http://sourceforge.net/p/plplot/code/12807
Author:   airwin
Date:     2013-12-03 23:56:24 +0000 (Tue, 03 Dec 2013)
Log Message:
-----------
Create the first build configuration using the new add_subdirectory
paradigm for epa_build.
Tested by Alan W. Irwin <ai...@us...> on Linux using
the -DBUILD_THE_BUILDTOOLS=ON configuration of epa_build and the
build_tcl target.
N.B. the tcl build configuration has no dependencies so the dependency
processing was not tested by this test.
Modified Paths:
--------------
    trunk/cmake/epa_build/CMakeLists.txt
    trunk/cmake/epa_build/tcl/CMakeLists.txt
Modified: trunk/cmake/epa_build/CMakeLists.txt
===================================================================
--- trunk/cmake/epa_build/CMakeLists.txt	2013-12-03 13:03:26 UTC (rev 12806)
+++ trunk/cmake/epa_build/CMakeLists.txt	2013-12-03 23:56:24 UTC (rev 12807)
@@ -1,6 +1,7 @@
-# Top-level CMakeLists.txt file for a project that simply builds
-# and installs external projects using epa.cmake include fragments
-# representing the build and test instructions for several different projects.
+# Top-level CMakeLists.txt file for the epa_build project that simply builds
+# and installs external projects configured in the subdirectories
+# below this one using ExternalProject_Add commands configured with
+# the appropriate build, test, and dependency information.
 
 # Copyright (C) 2013 Alan W. Irwin
 
@@ -29,8 +30,12 @@
 
 set(EPA_BASE ${CMAKE_BINARY_DIR}/epa_build)
 message(STATUS "EPA_BASE = ${EPA_BASE}")
-set_directory_properties(PROPERTIES EPA_BASE ${EPA_BASE})
+# We keep the variable name as EPA_BASE (to be used in the subdirectories
+# along with all the other variables with EPA_ suffix.  But the property
+# name must be EP_BASE in order for ExternalProject_Add to work correctly.
 
+set_directory_properties(PROPERTIES EP_BASE ${EPA_BASE})
+
 # Set epa_build variables to control builds in general
 
 # Test whether there is access to the MSYS platform on the PATH.  Note
@@ -57,10 +62,6 @@
 message(STATUS "MSYS_PLATFORM = ${MSYS_PLATFORM}")
 message(STATUS "CYGWIN = ${CYGWIN}")
 
-if(CYGWIN)
-  message(FATAL_ERROR "epa_build does not work correctly on the Cygwin platform.  Use the MinGW compiler and MSYS platform instead.")
-endif(CYGWIN)
-
 if(WIN32 AND NOT MSYS_PLATFORM)
   message(FATAL_ERROR "epa_build does not work correctly on Windows without the MSYS platform.  Install the MSYS platform (perhaps without sh.exe depending on CMake generator) on Windows.")
 endif(WIN32 AND NOT MSYS_PLATFORM)
@@ -157,6 +158,109 @@
   endfunction(determine_msys_path)
 endif(MSYS_PLATFORM)
 
+function(epa_boilerplate
+    _ignored_dependencies_LIST
+    _PACKAGE
+    _dependencies_LIST
+    _dependencies_targets
+    _EPA_visited_subdirectories_LIST
+    _EPA_processed_subdirectories_LIST
+    _EPA_needed_subdirectories_LIST
+    _EPA_build_target_LIST
+    _EPA_PATH
+    _source_PATH
+    _IF_RETURN
+    )
+
+  #message(STATUS "DEBUG: ${_ignored_dependencies_LIST} = ${${_ignored_dependencies_LIST}}")
+  #message(STATUS "DEBUG: ${_PACKAGE} = ${${_PACKAGE}}")
+  #message(STATUS "DEBUG: ${_dependencies_LIST} = ${${_dependencies_LIST}}")
+  #message(STATUS "DEBUG: ${_dependencies_targets} = ${${_dependencies_targets}}")
+  #message(STATUS "DEBUG: ${_EPA_visited_subdirectories_LIST} = ${${_EPA_visited_subdirectories_LIST}}")
+  #message(STATUS "DEBUG: ${_EPA_processed_subdirectories_LIST} = ${${_EPA_processed_subdirectories_LIST}}")
+  #message(STATUS "DEBUG: ${_EPA_needed_subdirectories_LIST} = ${${_EPA_needed_subdirectories_LIST}}")
+  #message(STATUS "DEBUG: ${_EPA_build_target_LIST} = ${${_EPA_build_target_LIST}}")
+  #message(STATUS "DEBUG: ${_EPA_PATH} = ${${_EPA_PATH}}")
+  #message(STATUS "DEBUG: ${_source_PATH} = ${${_source_PATH}}")
+  #message(STATUS "DEBUG: ${_IF_RETURN} = ${${_IF_RETURN}}")
+  list(APPEND ${_EPA_visited_subdirectories_LIST} ${${_PACKAGE}})
+
+  # Remove dependencies that should be ignored.
+  if(${_dependencies_LIST} AND ${_ignored_dependencies_LIST})
+    list(REMOVE_ITEM ${_dependencies_LIST} ${${_ignored_dependencies_LIST}})
+  endif(${_dependencies_LIST} AND ${_ignored_dependencies_LIST})
+
+# Check for missing configurations and eliminate those from ${_dependencies_LIST}.
+  foreach(build_configuration ${${_dependencies_LIST}})
+    if(NOT EXISTS ${CMAKE_SOURCE_DIR}/${build_configuration}/CMakeLists.txt)
+      message(STATUS "Warning: A build_configuration for ${build_configuration} does not exist so it is assumed this dependency of ${${_PACKAGE}} has been installed on your platform by means other than epa_build.")
+      list(REMOVE_ITEM ${_dependencies_LIST} ${build_configuration})
+    endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/${build_configuration}/CMakeLists.txt)
+  endforeach(build_configuration ${${_dependences_LIST}})
+
+  # remaining_dependencies_LIST are the dependencies left over from the above
+  # removals that have not already been processed.
+  set(remaining_dependencies_LIST ${${_dependencies_LIST}})
+  if(remaining_dependencies_LIST AND ${_EPA_processed_subdirectories_LIST})
+    list(REMOVE_ITEM remaining_dependencies_LIST ${${_EPA_processed_subdirectories_LIST}})
+  endif(remaining_dependencies_LIST AND ${_EPA_processed_subdirectories_LIST})
+
+  if(remaining_dependencies_LIST)
+    list(FIND ${_EPA_visited_subdirectories_LIST} ${${_PACKAGE}} index)
+    if(index GREATER -1)
+      message(FATAL_ERROR "Circular dependency: ${_PACKAGE} = ${${_PACKAGE}} has been visited before without subsequently resolving all dependencies.")
+    endif(index GREATER -1)
+    # Put the remaining dependencies at the top of the list so they
+    # will be processed before the current subdirectory.
+    list(APPEND ${_EPA_needed_subdirectories_LIST} ${remaining_dependencies_LIST})
+    # Propagate changed output arguments to parent scope of function.
+    # There is no need to propagate ${_dependencies_LIST} for this case because
+    # there will be an immediate return from the calling subdirectory to
+    # the top-level directory where ${_dependencies_LIST} does not propagate.
+    set(${_EPA_visited_subdirectories_LIST} ${${_EPA_visited_subdirectories_LIST}} PARENT_SCOPE)
+    set(${_EPA_needed_subdirectories_LIST} ${${_EPA_needed_subdirectories_LIST}} PARENT_SCOPE)
+    # parent subdirectory should make immediate return to top-level directory.
+    set(${_IF_RETURN} ON PARENT_SCOPE)
+    return()
+  endif(remaining_dependencies_LIST)
+
+  # Add this subdirectory to the list of subdirectories that have
+  # already been processed by the top-level CMakeLists.txt logic.
+  list(APPEND ${_EPA_processed_subdirectories_LIST} ${${_PACKAGE}})
+
+  set(${_dependencies_targets})
+  foreach(build_configuration ${${_dependencies_LIST}})
+    list(APPEND ${_dependencies_targets} build_${build_configuration})
+  endforeach(build_configuration ${${_dependences_LIST}})
+
+  list(APPEND ${_EPA_build_target_LIST} build_${${_PACKAGE}})
+
+  # Data that is related to the PATH that must be used.
+  if(MSYS_PLATFORM)
+    determine_msys_path(${_EPA_PATH} "${${_EPA_PATH}}")
+    # Must have all elements of env command in MSYS platform form
+    determine_msys_path(${_source_PATH} "${EPA_BASE}/Source/build_${${_PACKAGE}}")
+  else(MSYS_PLATFORM)
+    set(${_source_PATH} "${EPA_BASE}/Source/build_${${_PACKAGE}}")
+  endif(MSYS_PLATFORM)
+  #message(STATUS "DEBUG: (modified for ${${_PACKAGE}}) ${_EPA_PATH} = ${${_EPA_PATH}}")
+
+  # Propagate changed output arguments to parent scope of function.
+  set(${_dependencies_LIST} ${${_dependencies_LIST}} PARENT_SCOPE)
+  set(${_dependencies_targets} ${${_dependencies_targets}} PARENT_SCOPE)
+  set(${_EPA_visited_subdirectories_LIST} ${${_EPA_visited_subdirectories_LIST}} PARENT_SCOPE)
+  set(${_EPA_processed_subdirectories_LIST} ${${_EPA_processed_subdirectories_LIST}} PARENT_SCOPE)
+  set(${_EPA_needed_subdirectories_LIST} ${${_EPA_needed_subdirectories_LIST}} PARENT_SCOPE)
+  set(${_EPA_build_target_LIST} ${${_EPA_build_target_LIST}} PARENT_SCOPE)
+  set(${_EPA_PATH} ${${_EPA_PATH}} PARENT_SCOPE)
+  set(${_source_PATH} ${${_source_PATH}} PARENT_SCOPE)
+  # Parent subdirectory should continue processing rather than immediately
+  # returning to top-level directory.
+  set(${_IF_RETURN} OFF PARENT_SCOPE)
+  message(STATUS "Processed ${${_PACKAGE}}")
+
+endfunction(epa_boilerplate)
+
 # This gives the full pathname of the associated build tool for at
 # least the "Unix Makefiles", "Ninja", "MSYS Makefiles", "MinGW
 # Makefiles", and "NMake Makefiles JOM" CMake generators.
@@ -259,12 +363,6 @@
 # Now include the build configurations for certain targets and their
 # dependencies.
 
-# Each (directly or indirectly) included build configuration
-# that is judged to be working should append its target to build_target_LIST
-# so that in the logic below we can creat a "build_all" target that depends
-# on those individual build targets
-set(build_target_LIST)
-
 option(BUILD_THE_BUILDTOOLS "Build the buildtools (such as cmake) used for the rest of the builds" OFF)
 
 if(BUILD_THE_BUILDTOOLS)
@@ -282,39 +380,59 @@
     endif(NOT ${EXECUTABLE}_EXECUTABLE)
   endforeach(executable ${executables_LIST})
 
-  set(build_configuration_LIST
-    #cmake
-    pkg-config
-    #subversion
-    swig
+  set(EPA_needed_subdirectories_LIST
+    ##cmake
+    #pkg-config
+    ##subversion
+    #swig
     tcl
-    tk
     # itcl version 4 is integrated into tcl
     # itk version 4 is not integrated into tk (or tcl).
-    itk
+    #itk
     # itcl version 3 is an independent project
-    itcl3
+    #itcl3
     # itk version 3 is an independent project
-    itk3
+    #itk3
     # iwidgets subdirectory contains build configurations for both
     # iwidgets (version 4.1) and iwidgets4.0 (version 4.0).
-    iwidgets
+    #iwidgets
     )
 else(BUILD_THE_BUILDTOOLS)
   # List of all configurations.  Order doesn't matter because multiple
   # attempts to include the same configuration (via dependencies) are ignored.
-  set(build_configuration_LIST
+  set(EPA_needed_subdirectories_LIST
     ndiff
-    plplot
-    wxwidgets
-    glib
-    pango
+    #plplot
+    #wxwidgets
+    #pango
     )
 endif(BUILD_THE_BUILDTOOLS)
 
-foreach(build_configuration ${build_configuration_LIST})
-  include(${build_configuration}/CMakeLists.txt)
-endforeach(build_configuration ${build_configuration_LIST})
+set(EPA_visited_subdirectories_LIST)
+set(EPA_processed_subdirectories_LIST)
+set(EPA_build_targets_LIST)
 
+message(STATUS "DEBUG: EPA_needed_subdirectories_LIST = ${EPA_needed_subdirectories_LIST}")
+message(STATUS "DEBUG: EPA_visited_subdirectories_LIST = ${EPA_visited_subdirectories_LIST}")
+message(STATUS "DEBUG: EPA_processed_subdirectories_LIST = ${EPA_processed_subdirectories_LIST}")
+message(STATUS "DEBUG: EPA_build_targets_LIST = ${EPA_build_targets_LIST}")
+# Use add_subdirectory on all directories in EPA_needed_subdirectories_LIST,
+# but the subdirectories have the potential to add to that list so use
+# a while loop to check on the length of that list.
+list(LENGTH EPA_needed_subdirectories_LIST LENGTH_EPA_needed_subdirectories_LIST)
+while(LENGTH_EPA_needed_subdirectories_LIST GREATER 0)
+  list(GET EPA_needed_subdirectories_LIST 0 subdirectory)
+  # This updates EPA_needed_subdirectories_LIST,
+  # EPA_processed_subdirectories_LIST, and EPA_build_targets_LIST.
+  add_subdirectory(${subdirectory})
+  list(REMOVE_ITEM EPA_needed_subdirectories_LIST ${EPA_processed_subdirectories_LIST})
+  message(STATUS "DEBUG: visited ${subdirectory}")
+  message(STATUS "DEBUG: EPA_needed_subdirectories_LIST = ${EPA_needed_subdirectories_LIST}")
+  message(STATUS "DEBUG: EPA_visited_subdirectories_LIST = ${EPA_visited_subdirectories_LIST}")
+  message(STATUS "DEBUG: EPA_processed_subdirectories_LIST = ${EPA_processed_subdirectories_LIST}")
+  message(STATUS "DEBUG: EPA_build_targets_LIST = ${EPA_build_targets_LIST}")
+  list(LENGTH EPA_needed_subdirectories_LIST LENGTH_EPA_needed_subdirectories_LIST)
+endwhile(LENGTH_EPA_needed_subdirectories_LIST GREATER 0)
+
 add_custom_target(build_all)
-add_dependencies(build_all ${build_target_LIST})
+add_dependencies(build_all ${EPA_build_targets_LIST})
Modified: trunk/cmake/epa_build/tcl/CMakeLists.txt
===================================================================
--- trunk/cmake/epa_build/tcl/CMakeLists.txt	2013-12-03 13:03:26 UTC (rev 12806)
+++ trunk/cmake/epa_build/tcl/CMakeLists.txt	2013-12-03 23:56:24 UTC (rev 12807)
@@ -1,6 +1,7 @@
 # tcl/CMakeLists.txt
-# CMakeLists.txt file to configure the build of tcl.
 
+# Configure the build of tcl.
+
 # Copyright (C) 2013 Alan W. Irwin
 
 # This file is free software; you can redistribute it and/or
@@ -17,54 +18,43 @@
 # License along with this file; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
-# The top-level CMakeLists.txt file that includes this file should
-# have run "include(ExternalProject)" and set EPA_BASE variable (and
-# corresponding directory property) as well as various EPA variables
-# used below that configure how the External_Project functions
-# operate.
-
 # These build configuration details for Tcl adapted from information in
 # <http://www.linuxfromscratch.org/blfs/view/svn/general/tcl.html>.
 
-# Protect against configuring a build twice in one CMake call
-if(tcl_configured)
-  return()
-endif(tcl_configured)
-set(tcl_configured ON)
+set(PACKAGE tcl)
 
 # List of dependencies (most of which are build tools) which should be
 # ignored.
 set(EPA_ignored_dependencies_LIST ${extra_ignored_dependencies_list})
 
-set(tcl_dependencies_LIST)
-# Remove dependencies that should be ignored.
-if(tcl_dependencies_LIST)
-  list(REMOVE_ITEM tcl_dependencies_LIST ${EPA_ignored_dependencies_LIST})
-endif(tcl_dependencies_LIST)
+set(dependencies_LIST)
 
-set(tcl_dependencies_targets)
-foreach(build_configuration ${tcl_dependencies_LIST})
-  if(EXISTS ${CMAKE_SOURCE_DIR}/${build_configuration}/CMakeLists.txt)
-    include(${build_configuration}/CMakeLists.txt)
-    list(APPEND tcl_dependencies_targets build_${build_configuration})
-  else(EXISTS ${CMAKE_SOURCE_DIR}/${build_configuration}/CMakeLists.txt)
-    message(STATUS "Warning: A build_configuration for ${build_configuration} does not exist so it is assumed this dependency of tcl has been installed another way.")
-  endif(EXISTS ${CMAKE_SOURCE_DIR}/${build_configuration}/CMakeLists.txt)
-endforeach(build_configuration ${tcl_dependences_LIST})
+# Do boilerplate tasks that must be done for each different project
+# that is configured as part of epa_build.
+epa_boilerplate(
+  ignored_dependencies_LIST
+  PACKAGE
+  dependencies_LIST
+  dependencies_targets
+  EPA_visited_subdirectories_LIST
+  EPA_processed_subdirectories_LIST
+  EPA_needed_subdirectories_LIST
+  EPA_build_targets_LIST
+  EPA_PATH
+  source_PATH
+  IF_RETURN
+  ) 
 
-# This can be safely done only after above includes.
-set(PACKAGE tcl)
+# Propagate list changes to parent scope.
+set(EPA_visited_subdirectories_LIST ${EPA_visited_subdirectories_LIST} PARENT_SCOPE)
+set(EPA_processed_subdirectories_LIST ${EPA_processed_subdirectories_LIST} PARENT_SCOPE)
+set(EPA_needed_subdirectories_LIST ${EPA_needed_subdirectories_LIST} PARENT_SCOPE)
+set(EPA_build_targets_LIST ${EPA_build_targets_LIST} PARENT_SCOPE)
 
-# These variables are also used by tk (and accessible to that
-# build configuration because it depends on this one).
-set(TCL_TK_VERSION 8.6.1)
-string(REGEX REPLACE "\\.[0-9]$" "" TCL_TK_LIBVERSION ${TCL_TK_VERSION})
+if(IF_RETURN)
+  return()
+endif(IF_RETURN)
 
-# Data that is related to downloads.
-set(URL http://downloads.sourceforge.net/project/tcl/Tcl/${TCL_TK_VERSION}/tcl${TCL_TK_VERSION}-src.tar.gz)
-set(${PACKAGE}_DOWNLOAD_HASH_TYPE MD5)
-set(${PACKAGE}_DOWNLOAD_HASH aae4b701ee527c6e4e1a6f9c7399882e)
-
 # Data that is related to the PATH that must be used.
 # N.B. note below that we always use the unix subdirectory of the
 # source tree to find the configure script.  Note, there is a macosx
@@ -73,28 +63,36 @@
 # version of configure may be good enough for our needs for all
 # platforms.
 if(MSYS_PLATFORM)
-  #set(EPA_PATH_NODLL "${EPA_PATH}")
-  #set(EPA_PATH "${EPA_BASE}/Build/build_${PACKAGE}/dll;${EPA_PATH_NODLL}")
-  determine_msys_path(EPA_PATH "${EPA_PATH}")
-  # Must have all elements of env command in MSYS platform form
-  determine_msys_path(source_PATH "${EPA_BASE}/Source/build_${PACKAGE}/unix")
-  set(${PACKAGE}_SET_CFLAGS "CFLAGS=$ENV{CFLAGS}")
+  set(source_PATH ${source_PATH}\unix)
 else(MSYS_PLATFORM)
-  set(source_PATH "${EPA_BASE}/Source/build_${PACKAGE}/unix")
-  set(${PACKAGE}_SET_CFLAGS "CFLAGS=$ENV{CFLAGS}")
+  set(source_PATH ${source_PATH}/unix)
 endif(MSYS_PLATFORM)
-#message(STATUS "modified EPA_PATH for ${PACKAGE} = ${EPA_PATH}")
 
+set(CFLAGS "$ENV{CFLAGS}")
+set(CXXFLAGS "-I${EPA_CMAKE_INSTALL_PREFIX}/include $ENV{CXXFLAGS}")
+
+# Drop -fvisibility=hidden since that option may not work for this package.
+string(REGEX REPLACE "-fvisibility=hidden" "" CFLAGS "${CFLAGS}")
+string(REGEX REPLACE "-fvisibility=hidden" "" CXXFLAGS "${CXXFLAGS}")
+
+set(TCL_TK_VERSION 8.6.1)
+string(REGEX REPLACE "\\.[0-9]$" "" TCL_TK_LIBVERSION ${TCL_TK_VERSION})
+
+# Data that is related to downloads.
+set(URL http://downloads.sourceforge.net/project/tcl/Tcl/${TCL_TK_VERSION}/tcl${TCL_TK_VERSION}-src.tar.gz)
+set(DOWNLOAD_HASH_TYPE MD5)
+set(DOWNLOAD_HASH aae4b701ee527c6e4e1a6f9c7399882e)
+
 if(EPA_HAVE_64_BIT_OS)
-  set(TCL_ENABLE_64_BIT --enable-64bit)
+  set(ENABLE_64_BIT --enable-64bit)
 endif(EPA_HAVE_64_BIT_OS)
 
 ExternalProject_Add(
   build_${PACKAGE}
-  DEPENDS ${${PACKAGE}_dependencies_targets}
+  DEPENDS ${dependencies_targets}
   URL ${URL}
-  URL_HASH ${${PACKAGE}_DOWNLOAD_HASH_TYPE}=${${PACKAGE}_DOWNLOAD_HASH}
-  CONFIGURE_COMMAND ${ENV_EXECUTABLE} PATH=${EPA_PATH} ${${PACKAGE}_SET_CFLAGS} ${source_PATH}/${EPA_CONFIGURE_COMMAND} --mandir=${EPA_CMAKE_INSTALL_PREFIX}/share/man ${TCL_ENABLE_64_BIT}
+  URL_HASH ${DOWNLOAD_HASH_TYPE}=${DOWNLOAD_HASH}
+  CONFIGURE_COMMAND ${ENV_EXECUTABLE} PATH=${EPA_PATH} "CFLAGS=${CFLAGS}" "CXXFLAGS=${CXXFLAGS}" ${source_PATH}/${EPA_CONFIGURE_COMMAND} --mandir=${EPA_CMAKE_INSTALL_PREFIX}/share/man ${ENABLE_64_BIT}
   BUILD_COMMAND ${ENV_EXECUTABLE} PATH=${EPA_PATH} ${EPA_PARALLEL_MAKE_COMMAND}
   INSTALL_COMMAND ${ENV_EXECUTABLE} PATH=${EPA_PATH} ${EPA_PARALLEL_MAKE_COMMAND} install
   )
@@ -119,8 +117,3 @@
   COMMAND ${CHMOD_EXECUTABLE} -v ${SO_NUMERICAL_PERMISSIONS} ${EPA_CMAKE_INSTALL_PREFIX}/lib/libtcl${TCL_TK_LIBVERSION}.so
   APPEND
   )
-
-list(APPEND build_target_LIST build_${PACKAGE})
-# Restore EPA_PATH to original state.
-set(EPA_PATH "${EPA_ORIGINAL_NATIVE_PATH}")
-#message(STATUS "${PACKAGE} restored original EPA_PATH = ${EPA_PATH}")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |