Skip to content

Commit

Permalink
- Extract variables from Makefile.common.
Browse files Browse the repository at this point in the history
- Apply this to asn1/c1222/

svn path=/trunk/; revision=51324
  • Loading branch information
Jörg Mayer committed Aug 12, 2013
1 parent 50eb826 commit 3b5aaef
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 17 deletions.
50 changes: 33 additions & 17 deletions asn1/c1222/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,49 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#

set( PROTOCOL_NAME c1222 )
include(UseMakefileCommon)
VARS_FROM_MAKEFILE_COMMON(
"."
PROTOCOL_NAME
ASN_FILE_LIST
EXTRA_DIST
SRC_FILES
A2W_FLAGS
EXTRA_CNF
)

#message( STATUS "Values used in c1222\n PROTOCOL_NAME: ${PROTOCOL_NAME}\n ASN_FILE_LIST: ${ASN_FILE_LIST}\n EXTRA_DIST: ${EXTRA_DIST}\n SRC_FILES: ${SRC_FILES}\n A2W_FLAGS: ${A2W_FLAGS}\n")
#foreach(v2 ${EXTRA_DIST})
# message(STATUS "::${v2}::")
#endforeach()

#set( PROTOCOL_NAME c1222 )

set( PROTO_OPT )

set( EXT_ASN_FILE_LIST
)

set( ASN_FILE_LIST
${PROTOCOL_NAME}.asn
)
#set( ASN_FILE_LIST
# ${PROTOCOL_NAME}.asn
#)

set( EXTRA_DIST
${ASN_FILE_LIST}
packet-${PROTOCOL_NAME}-template.c
packet-${PROTOCOL_NAME}-template.h
${PROTOCOL_NAME}.cnf
)
#set( EXTRA_DIST
# ${ASN_FILE_LIST}
# packet-${PROTOCOL_NAME}-template.c
# packet-${PROTOCOL_NAME}-template.h
# ${PROTOCOL_NAME}.cnf
#)

set( SRC_FILES
${EXTRA_DIST}
${EXT_ASN_FILE_LIST}
)
#set( SRC_FILES
# ${EXTRA_DIST}
# ${EXT_ASN_FILE_LIST}
#)

set( A2W_FLAGS -b )
#set( A2W_FLAGS -b )

set( EXTRA_CNF
)
#set( EXTRA_CNF
#)

ASN2WRS()

53 changes: 53 additions & 0 deletions cmake/modules/UseMakefileCommon.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# $Id$
#

# Pick one or more variables from the Makefile.common file
# with a path relative to the current CMakeLists.txt and provide
# their values as cmake variables of identical names.

# Usage:
# include(UseMakefileCommon)
# VAR_FROM_MAKEFILE_COMMON( <PATH> <VAR-1> ... <VAR-N> )

function( VARS_FROM_MAKEFILE_COMMON _path_to_mc )
file( READ
${CMAKE_CURRENT_SOURCE_DIR}/${_path_to_mc}/Makefile.common
_use_mc_content
)

# Fold long lines
string( REGEX REPLACE
"(\\\\\r?[\n^][ \t]*)"
" "
_use_mc_content
"${_use_mc_content}"
)

foreach( _use_mc_varname ${ARGN} )
string( REGEX MATCH
".*${_use_mc_varname}[ \t]*=[ \t]*([^\n]*)\r?[\n].*"
_use_mc_var
"${_use_mc_content}"
)
set( _use_mc_var ${CMAKE_MATCH_1} )
string( REGEX REPLACE
"[ \t]+"
";"
_use_mc_var
"${_use_mc_var}"
)
set ( ${_use_mc_varname} )
foreach ( _v ${_use_mc_var} )
string( REGEX MATCH "\\$\\((.*)\\)" _matchres "${_v}" )
if ( _matchres)
string ( REGEX REPLACE "\\$\\((.*)\\)" "${${CMAKE_MATCH_1}}" _new_val "${_v}" )
list( APPEND ${_use_mc_varname} "${_new_val}" )
else()
list( APPEND ${_use_mc_varname} "${_v}" )
endif()
endforeach()
set( ${_use_mc_varname} ${${_use_mc_varname}} PARENT_SCOPE )
endforeach()
endfunction()

0 comments on commit 3b5aaef

Please sign in to comment.