[asterisk-scf-commits] asterisk-scf/release/cmake.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Jan 19 17:00:51 CST 2011


branch "master" has been updated
       via  66640ddef1ebc5209a2f4cf4660b30ec9c21b77a (commit)
       via  604a1398788ad8c8af2ccf8962666841e474c05b (commit)
       via  a00c61f2e1322dd57647b39d57167733b4f385d9 (commit)
       via  4adddee7a420564706ad492054ea08c43292ccef (commit)
      from  02faccc91efe3c5337e4264552575f20692192f8 (commit)

Summary of changes:
 AsteriskSCF.cmake |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)


- Log -----------------------------------------------------------------
commit 66640ddef1ebc5209a2f4cf4660b30ec9c21b77a
Merge: 604a139 02faccc
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Wed Jan 19 16:59:26 2011 -0600

    Merge branch 'master' into slice-plugins
    
    Conflicts:
    	AsteriskSCF.cmake

diff --cc AsteriskSCF.cmake
index 3abbeb5,1fd2add..e85b9a5
--- a/AsteriskSCF.cmake
+++ b/AsteriskSCF.cmake
@@@ -436,12 -349,6 +349,20 @@@ function(asterisk_scf_slice_include_dir
      set(SLICE_INCLUDE_DIRECTORIES ${paths} PARENT_SCOPE)
  endfunction()
  
- # Function which remembers definitions needed by a Slice target
- function(asterisk_scf_slice_compile_definitions SLICE_FILE)
-     get_filename_component(SLICE ${SLICE_FILE} NAME_WE)
-     set(SLICE_COMPILE_DEFINITIONS_${SLICE} ${ARGN} PARENT_SCOPE)
++# Function which remembers Slice plugins to be used for all targets in the
++# current directory and below
++function(asterisk_scf_slice_plugins)
++    if(NOT ARGN)
++        message(FATAL_ERROR "You must pass at least one plugin to this function")
++    endif()
++    set(plugins ${SLICE_PLUGINS})
++    foreach(plugin ${ARGN})
++      list(APPEND plugins ${plugin})
++    endforeach()
++    list(REMOVE_DUPLICATES plugins)
++    set(SLICE_PLUGINS ${plugins} PARENT_SCOPE)
 +endfunction()
 +
  # Function which remembers Ice libraries needed by a Slice target
  function(asterisk_scf_slice_add_ice_libraries TARGET)
      if(NOT ARGN)
@@@ -856,135 -406,209 +420,217 @@@ function(asterisk_scf_component_add_ice
          list(APPEND libs ${lib})
      endforeach()
      list(REMOVE_DUPLICATES libs)
-     set(${COMPONENT}_BOOST_LIBRARIES ${libs} PARENT_SCOPE)
-     include_directories(${Boost_INCLUDE_DIR})
-     link_directories(${Boost_LIBRARY_DIRS})
+     set(${COMPONENT}_ICE_LIBRARIES ${libs} PARENT_SCOPE)
  endfunction()
  
- # Function which builds a component as an IceBox service
- function(asterisk_scf_component_build_icebox COMPONENT)
-     set(lang ${ASTERISK_SCF_${COMPONENT}_LANG})
-     message(STATUS "Building component ${COMPONENT} (${lang}) as IceBox service")
-     if(lang STREQUAL "CXX")
-         find_ICE_CXX_library(IceBox)
-     elseif(lang STREQUAL "CSharp")
-         find_ICE_CSharp_library(IceBox)
-     elseif(lang STREQUAL "Java")
-         find_ICE_Java_library(IceBox)
-     else()
-         message(FATAL_ERROR "IceBox services are not supported in the ${lang} language")
-     endif()
-     list(APPEND icelibs IceBox ${ASTERISK_SCF_ICE_LIBRARIES_${lang}} ${${COMPONENT}_ICE_LIBRARIES})
-     list(REMOVE_DUPLICATES icelibs)
-     foreach(lib ${icelibs})
-         if(UNIX)
-             list(APPEND target_libs "${lib}")
+ # Adds Slice files to a target.  This handles all the magic of creating the
+ # rules to run slice2cpp, adding the generated headers to the include path,
+ # adding the generated .cpp file to the component, etc.  The generated files
+ # are placed in ${CMAKE_CURRENT_BINARY_DIR}/generated.
+ #
+ # The Slice files are passed in as a list of globs, relative to
+ # the current source directory.  The globs default to regular non-recursive
+ # globs.  If you want to include subdirectories in you glob search, also
+ # pass in GLOB_RECURSE.
+ #
+ # For example:
+ #   asterisk_scf_component_add_slice(comp-name GLOB_RECURSE "*.ice")
+ #
+ # See http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:file for more
+ # details on the globbing syntax.
+ function(asterisk_scf_component_add_slice COMPONENT)
+     # default to glob syntax by default.  not as useful as GLOB_RECURSE, but
+     # follows the principle of least surprise
+     set(glob_style GLOB)
+     foreach(slice_glob ${ARGN})
+         if(${slice_glob} STREQUAL GLOB OR ${slice_glob} STREQUAL GLOB_RECURSE)
+             # change our globbing style
+             set(glob_style ${slice_glob})
          else()
-             list(APPEND target_libs "${ICE_${lang}_LIB_${lib}}")
-         endif()
-     endforeach()
+             # expand the glob into a list of files
+             file(${glob_style} slices RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+                 ${slice_glob})
  
-     if(lang STREQUAL "CXX")
-         # Now we actually create the library
-         # while one would think that MODULE would be the right setting, it
-         # has to be shared due to how icebox finds these libraries on a Mac
-         # (it loads .dylib instead of loading .so)
-         add_library(${COMPONENT} SHARED ${${COMPONENT}_SOURCES})
-         # Link required libraries and Slice libraries
-         list(APPEND boostlibs ${ASTERISK_SCF_BOOST_LIBRARIES} ${${COMPONENT}_BOOST_LIBRARIES})
-         if(boostlibs)
-             list(REMOVE_DUPLICATES boostlibs)
-             foreach(lib ${boostlibs})
- 	        string(TOUPPER ${lib} libtag)
- 	        list(APPEND target_libs "${Boost_${libtag}_LIBRARY}")
+             foreach(slice ${slices})
+                 asterisk_scf_component_add_one_slice(${COMPONENT} ${slice})
              endforeach()
          endif()
-         if(UNIX)
-             list(FIND target_libs Ice _Ice_FOUND)
-             if(_Ice_FOUND GREATER -1)
-                 list(APPEND target_libs "IceUtil")
- 	        list(APPEND target_libs "pthread")
-             endif()
-         endif()
-         target_link_libraries(${COMPONENT} ${${COMPONENT}_SLICES} ${target_libs})
-     elseif(lang STREQUAL "CSharp")
-         csharp_add_library(${COMPONENT} ${${COMPONENT}_SOURCES} REFERENCES ${${COMPONENT}_SLICES} ${target_libs})
-     endif()
+     endforeach()
+     set(${COMPONENT}_SOURCES ${${COMPONENT}_SOURCES} PARENT_SCOPE)
  endfunction()
  
- # Function which builds a component standalone
- function(asterisk_scf_component_build_standalone COMPONENT)
-     set(lang ${ASTERISK_SCF_${COMPONENT}_LANG})
-     message(STATUS "Building component ${COMPONENT} (${lang}) as standalone executable")
-     list(APPEND icelibs ${ASTERISK_SCF_ICE_LIBRARIES_${lang}} ${${COMPONENT}_ICE_LIBRARIES})
-     list(REMOVE_DUPLICATES icelibs)
-     foreach(lib ${icelibs})
-         if(UNIX)
-             list(APPEND target_libs "${lib}")
+ function(asterisk_scf_component_add_one_slice COMPONENT SLICE)
+     if(NOT SLICE_COMPILER)
+         # Find the actual Slice compiler
+         find_program(SLICE_COMPILER slice2cpp PATHS "${ICE_DIR}/bin"
+             NO_DEFAULT_PATH)
+ 
+         # If we fail to find it we have to abort here, we can go no further
+         if(SLICE_COMPILER)
+             message(STATUS "Found Slice compiler at ${SLICE_COMPILER}")
+ 	    mark_as_advanced(SLICE_COMPILER)
          else()
-             list(APPEND target_libs "${ICE_${lang}_LIB_${lib}}")
+             message(FATAL_ERROR "Failed to find Slice compiler")
          endif()
+     endif()
+ 
+     if(MSVC_IDE)
+         # This makes the Slice definitions display in their own folder in the
+ 	# Visual Studio IDE
+ 	source_group("Slice Definitions" REGULAR_EXPRESSION "\\.ice$")
+     endif()
+ 
+     # Append the needed include directories for Slice definitions
+     foreach(include ${SLICE_INCLUDE_DIRECTORIES})
+         # Each directory in this list will be in the source tree,
+         # which is what the Slice compiler will need
+         list(APPEND slice_compiler_arguments "-I${include}")
      endforeach()
  
-     if(lang STREQUAL "CXX")
-         # Now we actually create the component
-         add_executable(${COMPONENT} ${${COMPONENT}_SOURCES})
-         # Link required libraries and Slice libraries
-         list(APPEND boostlibs ${ASTERISK_SCF_BOOST_LIBRARIES} ${${COMPONENT}_BOOST_LIBRARIES})
-         if(boostlibs)
-             list(REMOVE_DUPLICATES boostlibs)
-             foreach(lib ${boostlibs})
- 	        string(TOUPPER ${lib} libtag)
- 	        list(APPEND target_libs "${Boost_${libtag}_LIBRARY}")
-             endforeach()
-         endif()
-         if(UNIX)
-             list(FIND target_libs Ice _Ice_FOUND)
-             if(_Ice_FOUND GREATER -1)
-                 list(APPEND target_libs "IceUtil")
-                 list(APPEND target_libs "pthread")
-             endif()
-         endif()
-         target_link_libraries(${COMPONENT} ${${COMPONENT}_SLICES} ${target_libs})
-     elseif(lang STREQUAL "CSharp")
-         csharp_add_executable(${COMPONENT} ${${COMPONENT}_SOURCES} REFERENCES ${${COMPONENT}_SLICES} ${target_libs})
++    # If any Slice plugins are to be used, include them in the
++    # compiler arguments
++    if(SLICE_PLUGINS)
++      foreach(plugin ${SLICE_PLUGINS})
++	list(APPEND slice_compiler_arguments "--plugin=${plugin}")
++      endforeach()
 +    endif()
- endfunction()
 +
- function(asterisk_scf_component_build_library COMPONENT)
-     set(lang ${ASTERISK_SCF_${COMPONENT}_LANG})
-     message(STATUS "Building component ${COMPONENT} (${lang}) as standalone executable")
-     list(APPEND icelibs ${ASTERISK_SCF_ICE_LIBRARIES_${lang}} ${${COMPONENT}_ICE_LIBRARIES})
+     message(STATUS "Adding ${SLICE} to ${COMPONENT}")
+     # get subdirectory slice is in
+     get_filename_component(slice_subdir "${SLICE}" PATH)
+ 
+     # get the directory in which to put the generated code
+     set(slice_out_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
+     # if the slice file is in a subdirectory, maintain that structure
+     if(slice_subdir AND NOT ${slice_subdir} MATCHES "\\.\\.")
+         set(slice_out_dir "${slice_out_dir}/${slice_subdir}")
+     endif()
+     get_filename_component(slice_basename "${SLICE}" NAME_WE)
+     # headers are generated, so add them to the include path
+     include_directories("${CMAKE_CURRENT_BINARY_DIR}/generated")
+     # generated .cpp files #include <.h> directly, which requires the out_dir
+     # itself to be in the include path
+     include_directories("${slice_out_dir}")
+ 
+     # fully specify SLICE's path
+     set(SLICE "${CMAKE_CURRENT_SOURCE_DIR}/${SLICE}")
+ 
+     # Look for the dependencies for this Slice definition, we have to do it now
+     # since the target was just added
+     message(STATUS "Determining dependencies for ${slice_basename}")
+     execute_process(
+         COMMAND ${SLICE_COMPILER} ${slice_compiler_arguments} --depend ${SLICE}
+         OUTPUT_VARIABLE raw_dependencies
+         ERROR_VARIABLE slice_errors)
+     if(slice_errors)
+         message(FATAL_ERROR "Slice compiler produced errors:\n ${slice_errors}")
+     endif()
+ 
+     if(raw_dependencies)
+         # get rid of folded newlines
+         string(REPLACE "\\\n" "" raw_dependencies "${raw_dependencies}")
+         # turn newlines into item separators
+         string(REPLACE "\n" ";" raw_dependencies "${raw_dependencies}")
+ 
+         foreach(dep ${raw_dependencies})
+             # each dep is of the form:
+             #target1 target2 [...] target_n: source1 source2 [...] source_n
+ 
+             # parse targets
+             string(REGEX MATCHALL "^[^:]+" dep_targets "${dep}")
+             string(REGEX MATCHALL "[^ ]+" dep_targets "${dep_targets}")
+             list(APPEND targets ${dep_targets})
+ 
+             # parse sources
+             string(REGEX MATCHALL "[^:]+$" dep_sources "${dep}")
+             string(REGEX MATCHALL "[^ ]+" dep_sources "${dep_sources}")
+             list(APPEND sources ${dep_sources})
+         endforeach()
+     endif()
  
-     list(LENGTH icelibs numicelibs)
-     if(numicelibs GREATER 0)
-         list(REMOVE_DUPLICATES icelibs)
+     # prepend the slice_out_dir to the targets
+     foreach(target ${targets})
+         list(APPEND generated_files "${slice_out_dir}/${target}")
+     endforeach()
+     # you would think that would be enough, but slice2cpp doesn't generate a
+     # dep for the .h file
+     list(APPEND generated_files "${slice_out_dir}/${slice_basename}.h")
+     # and be resilient in case it does so in the future...
+     list(REMOVE_DUPLICATES generated_files)
+     set_source_files_properties(${generated_files} PROPERTIES GENERATED 1)
+ 
+     # create a preprocessor definition in the generated CXX files that enables
+     # the generated classes to be exported from the library (only necessary on
+     # Windows)
+     if(WIN32)
+         list(APPEND slice_compiler_arguments "--dll-export" "ASTERISK_SCF_ICEBOX_EXPORT")
      endif()
  
+     file(MAKE_DIRECTORY ${slice_out_dir})
+     add_custom_command(
+         OUTPUT ${generated_files}
+         COMMAND ${SLICE_COMPILER} ${slice_compiler_arguments} ${SLICE}
+         --output-dir ${slice_out_dir}
+         COMMENT "slice2cpp translating ${SLICE}"
+         DEPENDS ${sources})
+ 
+     # the Slice and generated_files are sources for the component
+     list(APPEND ${COMPONENT}_SOURCES ${SLICE} ${generated_files})
+     set(${COMPONENT}_SOURCES ${${COMPONENT}_SOURCES} PARENT_SCOPE)
+ endfunction()
+ 
+ # Function which collects libraries needed by a component
+ function(asterisk_scf_component_libraries COMPONENT)
+     list(APPEND icelibs ${ASTERISK_SCF_ICE_LIBRARIES} ${${COMPONENT}_ICE_LIBRARIES})
+     list(REMOVE_DUPLICATES icelibs)
      foreach(lib ${icelibs})
-         if(UNIX)
-             list(APPEND target_libs "${lib}")
-         else()
-             list(APPEND target_libs "${ICE_${lang}_LIB_${lib}}")
-         endif()
+         list(APPEND target_libs "${ICE_${lib}_LIBRARY}")
      endforeach()
- 
-     if(lang STREQUAL "CXX")
-         # Now we actually create the component
-         add_library(${COMPONENT} ${${COMPONENT}_SOURCES})
-         # Link required libraries and Slice libraries
-         list(APPEND boostlibs ${ASTERISK_SCF_BOOST_LIBRARIES} ${${COMPONENT}_BOOST_LIBRARIES})
-         if(boostlibs)
-             list(REMOVE_DUPLICATES boostlibs)
-             foreach(lib ${boostlibs})
- 	        string(TOUPPER ${lib} libtag)
- 	        list(APPEND target_libs "${Boost_${libtag}_LIBRARY}")
-             endforeach()
-         endif()
-         target_link_libraries(${COMPONENT} ${${COMPONENT}_SLICES} ${target_libs})
-     elseif(lang STREQUAL "CSharp")
-         csharp_add_library(${COMPONENT} ${${COMPONENT}_SOURCES} REFERENCES ${${COMPONENT}_SLICES} ${target_libs})
+     list(APPEND boostlibs ${ASTERISK_SCF_BOOST_LIBRARIES} ${${COMPONENT}_BOOST_LIBRARIES})
+     if(boostlibs)
+         list(REMOVE_DUPLICATES boostlibs)
+         foreach(lib ${boostlibs})
+             list(APPEND target_libs "${Boost_${lib}_LIBRARY}")
+         endforeach()
      endif()
+     set(component_libs ${target_libs} PARENT_SCOPE)
+ endfunction()
+ 
+ # Function which builds a component as an IceBox service
+ function(asterisk_scf_component_build_icebox COMPONENT)
+     message(STATUS "Building component ${COMPONENT} as an IceBox service")
+     find_package(Ice REQUIRED IceBox)
+     list(APPEND icelibs ${${COMPONENT}_ICE_LIBRARIES} ICEBOX)
+     asterisk_scf_component_libraries(${COMPONENT})
+ 
+     # Now we actually create the library
+     # while one would think that MODULE would be the right setting, it
+     # has to be shared due to how icebox finds these libraries on a Mac
+     # (it loads .dylib instead of loading .so)
+     add_library(${COMPONENT} SHARED ${${COMPONENT}_SOURCES})
+     # Link required libraries
+     target_link_libraries(${COMPONENT} ${component_libs})
+ endfunction()
+ 
+ # Function which builds a component standalone
+ function(asterisk_scf_component_build_standalone COMPONENT)
+     message(STATUS "Building component ${COMPONENT} as a standalone executable")
+     asterisk_scf_component_libraries(${COMPONENT})
+ 
+     # Now we actually create the component
+     add_executable(${COMPONENT} ${${COMPONENT}_SOURCES})
+     # Link required libraries
+     target_link_libraries(${COMPONENT} ${component_libs})
+ endfunction()
+ 
+ function(asterisk_scf_component_build_library COMPONENT)
+     message(STATUS "Building component ${COMPONENT} as a library")
+     asterisk_scf_component_libraries(${COMPONENT})
+ 
+     # Now we actually create the component
+     add_library(${COMPONENT} ${${COMPONENT}_SOURCES})
+     # Link required libraries
+     target_link_libraries(${COMPONENT} ${component_libs})
  endfunction()
  
  # Function which adds information for installing a component

commit 604a1398788ad8c8af2ccf8962666841e474c05b
Merge: a00c61f 0d4c696
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Fri Jan 7 11:09:40 2011 -0600

    Merge branch 'master' into slice-plugins


commit a00c61f2e1322dd57647b39d57167733b4f385d9
Merge: 4adddee 5f41415
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Fri Jan 7 11:07:35 2011 -0600

    Merge remote branch 'origin/master' into slice-plugins


commit 4adddee7a420564706ad492054ea08c43292ccef
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Tue Jan 4 06:58:33 2011 -0600

    Add support for Slice translator plugins.

diff --git a/AsteriskSCF.cmake b/AsteriskSCF.cmake
index 73dfa67..3abbeb5 100644
--- a/AsteriskSCF.cmake
+++ b/AsteriskSCF.cmake
@@ -413,7 +413,19 @@ macro(ensure_abs_paths pathlist)
     set(${pathlist} ${eap_temp})
 endmacro()
 
-# Function which remembers include directories needed for a particular Slice target
+function(asterisk_scf_slice_plugins)
+    if(NOT ARGN)
+        message(FATAL_ERROR "You must pass at least one plugin to this function")
+    endif()
+    set(plugins ${SLICE_PLUGINS})
+    foreach(plugin ${ARGN})
+      list(APPEND plugins ${plugin})
+    endforeach()
+    list(REMOVE_DUPLICATES plugins)
+    set(SLICE_PLUGINS ${plugins} PARENT_SCOPE)
+endfunction()
+
+# Function which remembers include directories needed by a Slice target
 function(asterisk_scf_slice_include_directories)
     set(paths ${ARGN})
     ensure_abs_paths(paths)
@@ -424,7 +436,7 @@ function(asterisk_scf_slice_include_directories)
     set(SLICE_INCLUDE_DIRECTORIES ${paths} PARENT_SCOPE)
 endfunction()
 
-# Function which remembers definitions needed for a particular Slice target
+# Function which remembers definitions needed by a Slice target
 function(asterisk_scf_slice_compile_definitions SLICE_FILE)
     get_filename_component(SLICE ${SLICE_FILE} NAME_WE)
     set(SLICE_COMPILE_DEFINITIONS_${SLICE} ${ARGN} PARENT_SCOPE)
@@ -452,7 +464,7 @@ function(asterisk_scf_slice_add_ice_libraries TARGET)
     set(${TARGET}_ICE_LIBRARIES ${libs} PARENT_SCOPE)
 endfunction()
 
-# Function which adds a dependency for a Slice definition
+# Function which remembers dependencies for a Slice target
 function(asterisk_scf_slice_add_dependencies TARGET)
     if(NOT ARGN)
         message(FATAL_ERROR "You must pass at least one dependency to this function")
@@ -548,6 +560,11 @@ function(asterisk_scf_compile_slice TARGET_IN DIR_IN DESC_IN GROUP_IN)
     if(ICE_SLICE_DIR)
         list(APPEND slice_compiler_arguments "-I${ICE_SLICE_DIR}")
     endif()
+    if(SLICE_PLUGINS)
+      foreach(plugin ${SLICE_PLUGINS})
+	list(APPEND slice_compiler_arguments "--plugin=${plugin}")
+      endforeach()
+    endif()
     foreach(include ${SLICE_INCLUDE_DIRECTORIES})
         # Each directory in this list will be in the source tree,
         # which is what the Slice compiler will need

-----------------------------------------------------------------------


-- 
asterisk-scf/release/cmake.git



More information about the asterisk-scf-commits mailing list