[asterisk-scf-commits] asterisk-scf/integration/cmake.git branch "disintegrated-build" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Mar 30 15:42:36 CDT 2011


branch "disintegrated-build" has been created
        at  f9d445d4e4ed62e1b57c4f7deefb1000a843340d (commit)

- Log -----------------------------------------------------------------
commit f9d445d4e4ed62e1b57c4f7deefb1000a843340d
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Mon Mar 28 15:25:46 2011 -0700

    Various cleanups in preparation for disintegration. The only functional
    change here is that the library type can now be specified to
    asterisk_scf_build_library(), instead of calling a function to set the
    type before calling it.

diff --git a/AsteriskSCF.cmake b/AsteriskSCF.cmake
index 3c20b08..f64952f 100644
--- a/AsteriskSCF.cmake
+++ b/AsteriskSCF.cmake
@@ -44,6 +44,8 @@
 #   to set the variable value in the directory the function was called
 #   from (and it will be inherited by child directories automatically).
 # * Use the list() function for manipulating lists.
+# * Functions intended for private use by this module should not have an
+#   "asterisk_scf_" prefix, but should have an "__" prefix.
 #
 
 set(MIN_BOOST_VERSION 1.40)
@@ -152,11 +154,11 @@ elseif(UNIX AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
     add_custom_target(pull COMMAND git pull WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" COMMENT "Updating clone")
 endif()
 
-macro(set_cache_var)
+macro(__set_cache_var)
     set(${ARGV} CACHE INTERNAL Bob FORCE)
 endmacro()
 
-macro(append_to_var VAR)
+macro(__append_to_var VAR)
     unset(_altv)
     foreach(item ${ARGN})
         set(_altv "${_altv} ${item}")
@@ -164,7 +166,7 @@ macro(append_to_var VAR)
     set(${VAR} "${${VAR}} ${_altv}" PARENT_SCOPE)
 endmacro()
 
-macro(set_cache_var_list VAR LIST TYPE DESCRIPTION)
+macro(__set_cache_var_list VAR LIST TYPE DESCRIPTION)
     unset(_scvl)
     foreach(item IN LISTS ${LIST})
         set(_scvl "${_scvl} ${item}")
@@ -177,7 +179,7 @@ function(asterisk_scf_project NAME ICE_VERSION)
     message(STATUS "Setting up project ${NAME} for Ice version ${ICE_VERSION}")
 
     # On Windows, IceBox C++ services must be compiled with some symbols exported;
-    # the source code should use ASTERISK_SCF_ICEBOX_EXPORT to accomplish this, and this
+    # the source code should use ASTERISK_SCF_ICEBOX_EXPORT to accomplish this
     if(WIN32)
         message(STATUS "Setting ASTERISK_SCF_ICEBOX_EXPORT definition for Windows IceBox services")
         add_definitions(-DASTERISK_SCF_ICEBOX_EXPORT=__declspec\(dllexport\))
@@ -185,13 +187,14 @@ function(asterisk_scf_project NAME ICE_VERSION)
         add_definitions(-DASTERISK_SCF_ICEBOX_EXPORT=)
     endif()
 
-    # On Windows, 'debug' libraries should have a "d" suffix to indicate that they
-    # are debug libraries
+    # On Windows, 'debug' executables should have a "d" suffix to indicate that they
+    # are debug versions
     if(WIN32)
-        set_cache_var(CMAKE_DEBUG_POSTFIX "d")
+        __set_cache_var(CMAKE_DEBUG_POSTFIX "d")
     endif()
 
-    message(STATUS "Performing requirement checks for components")
+    message(STATUS "Checking for required components")
+
     # set(Ice_DEBUG on)
     find_package(Ice 3.4 REQUIRED Ice IceUtil)
 
@@ -222,7 +225,7 @@ function(asterisk_scf_project NAME ICE_VERSION)
         endif()
     endif()
 
-    # Use a compile test to see if shared_ptr is supported. If present then C++0x support exists.
+    # Use a compile test to see if std::shared_ptr<> is supported. If present then basic C++11 support exists.
     if(CMAKE_COMPILER_IS_GNUCXX)
         try_compile(SHARED_PTR_PRESENT
 	            ${CMAKE_BINARY_DIR}
@@ -231,11 +234,11 @@ function(asterisk_scf_project NAME ICE_VERSION)
 		    OUTPUT_VARIABLE OUTPUT
 		    )
         if(SHARED_PTR_PRESENT)
-            message(STATUS "Support for C++0x Enabled")
+            message(STATUS "Support for C++11 Enabled")
             add_definitions("-DCPP_ZEROX_SUPPORT")
 	    list(APPEND cxx_flags "-std=c++0x")
         else()
-            message(STATUS "Support for C++0x Disabled")
+            message(STATUS "Support for C++11 Disabled")
         endif()
     endif()
 
@@ -254,19 +257,19 @@ function(asterisk_scf_project NAME ICE_VERSION)
         list(APPEND cxx_flags "-pthreads")
     endif()
 
-    append_to_var(CMAKE_C_FLAGS ${c_flags})
-    append_to_var(CMAKE_C_FLAGS_DEBUG ${c_flags_debug})
-    append_to_var(CMAKE_C_FLAGS_PROFILE ${c_flags_profile} ${c_flags_debug})
+    __append_to_var(CMAKE_C_FLAGS ${c_flags})
+    __append_to_var(CMAKE_C_FLAGS_DEBUG ${c_flags_debug})
+    __append_to_var(CMAKE_C_FLAGS_PROFILE ${c_flags_profile} ${c_flags_debug})
 
-    append_to_var(CMAKE_CXX_FLAGS ${cxx_flags})
-    append_to_var(CMAKE_CXX_FLAGS_DEBUG ${cxx_flags_debug})
-    append_to_var(CMAKE_CXX_FLAGS_PROFILE ${cxx_flags_profile} ${cxx_flags_debug})
+    __append_to_var(CMAKE_CXX_FLAGS ${cxx_flags})
+    __append_to_var(CMAKE_CXX_FLAGS_DEBUG ${cxx_flags_debug})
+    __append_to_var(CMAKE_CXX_FLAGS_PROFILE ${cxx_flags_profile} ${cxx_flags_debug})
 
-    append_to_var(CMAKE_EXE_LINKER_FLAGS ${linker_flags})
-    append_to_var(CMAKE_MODULE_LINKER_FLAGS ${linker_flags})
-    append_to_var(CMAKE_SHARED_LINKER_FLAGS ${linker_flags})
+    __append_to_var(CMAKE_EXE_LINKER_FLAGS ${linker_flags})
+    __append_to_var(CMAKE_MODULE_LINKER_FLAGS ${linker_flags})
+    __append_to_var(CMAKE_SHARED_LINKER_FLAGS ${linker_flags})
 
-    message(STATUS "Passed requirement checks for CXX components")
+    message(STATUS "Required components found")
 endfunction()
 
 # Function which initializes a component for building
@@ -276,7 +279,7 @@ function(asterisk_scf_component_init COMPONENT)
 endfunction()
 
 # Find a Boost library.
-function(find_Boost_library LIBRARY)
+function(__find_boost_library LIBRARY)
     if(NOT Boost_FOUND)
         set(Boost_ADDITIONAL_VERSIONS "1.39" "1.39.0" "1.40" "1.40.0" "1.41" "1.41.0" "1.42" "1.42.0" "1.44" "1.44.0")
         find_package(Boost ${MIN_BOOST_VERSION})
@@ -289,6 +292,8 @@ function(find_Boost_library LIBRARY)
     string(TOUPPER ${LIBRARY} libtag)
     if(NOT Boost_${libtag}_FOUND)
         find_package(Boost REQUIRED ${LIBRARY})
+	include_directories(SYSTEM ${Boost_INCLUDE_DIR})
+	link_directories(${Boost_LIBRARY_DIRS})
     endif()
 endfunction()
 
@@ -302,14 +307,12 @@ function(asterisk_scf_add_boost_libraries)
     # By default we are disabling boost auto-linking and specifying dynamic linking.
     add_definitions(-DBOOST_ALL_NO_LIB -DBOOST_ALL_DYN_LINK)
     foreach(lib ${ARGN})
-        find_Boost_library(${lib})
+        __find_boost_library(${lib})
 	string(TOUPPER "${lib}" lib)
         list(APPEND libs ${lib})
     endforeach()
     list(REMOVE_DUPLICATES libs)
     set(ASTERISK_SCF_BOOST_LIBRARIES ${libs} PARENT_SCOPE)
-    include_directories(SYSTEM ${Boost_INCLUDE_DIR})
-    link_directories(${Boost_LIBRARY_DIRS})
 endfunction()
 
 # Function which adds Boost libraries needed by a component
@@ -321,18 +324,16 @@ function(asterisk_scf_component_add_boost_libraries COMPONENT)
     # By default we are disabling boost auto-linking and specifying dynamic linking.
     add_definitions(-DBOOST_ALL_NO_LIB -DBOOST_ALL_DYN_LINK)
     foreach(lib ${ARGN})
-        find_Boost_library(${lib})
+        __find_boost_library(${lib})
 	string(TOUPPER "${lib}" lib)
         list(APPEND libs ${lib})
     endforeach()
     list(REMOVE_DUPLICATES libs)
     set(${COMPONENT}_BOOST_LIBRARIES ${libs} PARENT_SCOPE)
-    include_directories(SYSTEM ${Boost_INCLUDE_DIR})
-    link_directories(${Boost_LIBRARY_DIRS})
 endfunction()
 
 # Ensures that a list of paths are all absolute paths.
-macro(ensure_abs_paths pathlist)
+macro(__ensure_abs_paths pathlist)
     unset(eap_temp)
     foreach(p ${${pathlist}})
         get_filename_component(newpath "${p}" ABSOLUTE)
@@ -345,7 +346,7 @@ endmacro()
 # Function which remembers include directories needed for a particular Slice target
 function(asterisk_scf_slice_include_directories)
     set(paths ${ARGN})
-    ensure_abs_paths(paths)
+    __ensure_abs_paths(paths)
     if(SLICE_INCLUDE_DIRECTORIES)
         list(INSERT paths 0 ${SLICE_INCLUDE_DIRECTORIES})
     endif()
@@ -427,15 +428,14 @@ function(asterisk_scf_component_add_ice_libraries COMPONENT)
     set(${COMPONENT}_ICE_LIBRARIES ${libs} PARENT_SCOPE)
 endfunction()
 
-# 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.
+# Function to remember Slice files used by a component. The Slice files
+# will be translated when the component is built.
 #
 # 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.
+# searching.  If you want to include subdirectories in the glob search, pass
+# in GLOB_RECURSE as an argument to the function, before the glob that
+# should search recursively.
 #
 # For example:
 #   asterisk_scf_component_add_slice(comp-name GLOB_RECURSE "*.ice")
@@ -443,7 +443,27 @@ endfunction()
 # 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
+    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()
+            message(FATAL_ERROR "Failed to find Slice compiler")
+        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()
+    endif()
+
+    # 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})
@@ -453,37 +473,17 @@ function(asterisk_scf_component_add_slice COMPONENT)
         else()
             # expand the glob into a list of files
             file(${glob_style} slices RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
-                ${slice_glob})
+                 ${slice_glob})
 
             foreach(slice ${slices})
-                asterisk_scf_component_add_one_slice(${COMPONENT} ${slice})
+                __component_add_one_slice(${COMPONENT} ${slice})
             endforeach()
         endif()
     endforeach()
     set(${COMPONENT}_SOURCES ${${COMPONENT}_SOURCES} PARENT_SCOPE)
 endfunction()
 
-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()
-            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()
-
+function(__component_add_one_slice COMPONENT SLICE)
     # Append the needed include directories for Slice definitions
     foreach(include ${SLICE_INCLUDE_DIRECTORIES})
         # Each directory in this list will be in the source tree,
@@ -505,32 +505,17 @@ function(asterisk_scf_component_add_one_slice COMPONENT SLICE)
       endforeach()
     endif()
 
-    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
-    # since we can't control them, treat them as system includes
-    include_directories(SYSTEM "${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(SYSTEM "${slice_out_dir}")
+    message(STATUS "Adding ${slice_basename} to ${COMPONENT}")
 
     # fully specify SLICE's path
-    set(SLICE "${CMAKE_CURRENT_SOURCE_DIR}/${SLICE}")
+    set(slice_full_path "${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}
+        COMMAND ${SLICE_COMPILER} ${slice_compiler_arguments} --depend ${slice_full_path}
         OUTPUT_VARIABLE raw_dependencies
         ERROR_VARIABLE slice_errors)
     if(slice_errors)
@@ -555,7 +540,7 @@ function(asterisk_scf_component_add_one_slice COMPONENT SLICE)
             # parse sources
 	    string(REGEX MATCHALL  "^[^:]+" targstart "${dep}")
 	    string(REGEX REPLACE "^${targstart}:" "" dep_sources "${dep}")
-	    # replace the escaped spaces, leave the space separater.
+	    # replace the escaped spaces, leave the space separator
             string(REPLACE "\\ " "%20%" dep_sources "${dep_sources}") 
             string(REGEX MATCHALL "[^ ]+" dep_sources "${dep_sources}")
 	    list(APPEND expsources ${dep_sources})
@@ -568,12 +553,26 @@ function(asterisk_scf_component_add_one_slice COMPONENT SLICE)
     	list(APPEND sources ${source})
     endforeach()
 
+    # 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")
+    # headers are generated, so add them to the include path
+    # since we can't control them, treat them as system includes
+    include_directories(SYSTEM "${slice_out_dir}")
+    # 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}")
+	# add this directory to the include path as well
+	include_directories(SYSTEM "${slice_out_dir}")
+    endif()
+
     # 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
+    # slice2cpp doesn't generate a dep for the .h file, so add one
     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)
@@ -589,18 +588,18 @@ function(asterisk_scf_component_add_one_slice COMPONENT SLICE)
     file(MAKE_DIRECTORY ${slice_out_dir})
     add_custom_command(
         OUTPUT ${generated_files}
-        COMMAND ${SLICE_COMPILER} ${slice_compiler_arguments} ${SLICE}
+        COMMAND ${SLICE_COMPILER} ${slice_compiler_arguments} ${slice_full_path}
         --output-dir ${slice_out_dir}
         COMMENT "slice2cpp translating ${SLICE}"
 	DEPENDS ${sources} ${SLICE_COMPILER})
 
     # the Slice and generated_files are sources for the component
-    list(APPEND ${COMPONENT}_SOURCES ${SLICE} ${generated_files})
+    list(APPEND ${COMPONENT}_SOURCES ${slice_full_path} ${generated_files})
     set(${COMPONENT}_SOURCES ${${COMPONENT}_SOURCES} PARENT_SCOPE)
 endfunction()
 
-# Function which collects libraries needed by a component
-function(asterisk_scf_component_libraries COMPONENT)
+# Function which links component against libraries previously collected
+function(__component_link_libraries COMPONENT)
     list(APPEND icelibs ${ASTERISK_SCF_ICE_LIBRARIES} ${${COMPONENT}_ICE_LIBRARIES})
     list(REMOVE_DUPLICATES icelibs)
     foreach(lib ${icelibs})
@@ -613,7 +612,7 @@ function(asterisk_scf_component_libraries COMPONENT)
             list(APPEND target_libs "${Boost_${lib}_LIBRARY}")
         endforeach()
     endif()
-    set(component_libs ${target_libs} PARENT_SCOPE)
+    target_link_libraries(${COMPONENT} ${target_libs})
 endfunction()
 
 # Function which builds a component as an IceBox service
@@ -622,42 +621,39 @@ function(asterisk_scf_component_build_icebox COMPONENT)
     set(${COMPONENT}_TYPE icebox PARENT_SCOPE)
     find_package(Ice REQUIRED IceBox)
     list(APPEND icelibs ${${COMPONENT}_ICE_LIBRARIES} ICEBOX)
-    asterisk_scf_component_libraries(${COMPONENT})
 
     # Now we actually create the shared module
     add_library(${COMPONENT} MODULE ${${COMPONENT}_SOURCES})
     # Link required libraries
-    target_link_libraries(${COMPONENT} ${component_libs})
+    __component_link_libraries(${COMPONENT})
 endfunction()
 
 # Function which builds a component standalone
 function(asterisk_scf_component_build_standalone COMPONENT)
     message(STATUS "Building component ${COMPONENT} as a standalone executable")
     set(${COMPONENT}_TYPE standalone PARENT_SCOPE)
-    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_set_libtype COMPONENT TYPE)
-    set("${COMPONENT}_LIBTYPE" ${TYPE} PARENT_SCOPE)
+    __component_link_libraries(${COMPONENT})
 endfunction()
 
 function(asterisk_scf_component_build_library COMPONENT)
-    message(STATUS "Building component ${COMPONENT} as a ${${COMPONENT}_LIBTYPE} library")
+    set(libtype SHARED)
+    if(ARGN)
+      set(libtype "${ARG2}")
+    endif()
+    message(STATUS "Building component ${COMPONENT} as a ${libtype} library")
     set(${COMPONENT}_TYPE library PARENT_SCOPE)
-    asterisk_scf_component_libraries(${COMPONENT})
 
     # Now we actually create the component
-    add_library(${COMPONENT} ${${COMPONENT}_LIBTYPE} ${${COMPONENT}_SOURCES})
+    add_library(${COMPONENT} ${libtype} ${${COMPONENT}_SOURCES})
     # Link required libraries
-    target_link_libraries(${COMPONENT} ${component_libs})
+    __component_link_libraries(${COMPONENT})
 endfunction()
 
-# Install the given component to their proper location
+# Install the given component to its proper location
 function(asterisk_scf_component_install COMPONENT)
     if(${COMPONENT}_TYPE STREQUAL "icebox")
         install(TARGETS ${COMPONENT}

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


-- 
asterisk-scf/integration/cmake.git



More information about the asterisk-scf-commits mailing list