aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorJörg Mayer <jmayer@loplof.de>2013-08-12 22:17:06 +0000
committerJörg Mayer <jmayer@loplof.de>2013-08-12 22:17:06 +0000
commit3b5aaefce36a806f3a2407fd366825d06db5ff45 (patch)
tree3708ff4725b57fa6ada2d15f7e940f16b40cfd01 /cmake
parent50eb826406b246d69593afabfac29b0d78ee970e (diff)
- Extract variables from Makefile.common.
- Apply this to asn1/c1222/ svn path=/trunk/; revision=51324
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/UseMakefileCommon.cmake53
1 files changed, 53 insertions, 0 deletions
diff --git a/cmake/modules/UseMakefileCommon.cmake b/cmake/modules/UseMakefileCommon.cmake
new file mode 100644
index 0000000000..62bc8f5cc7
--- /dev/null
+++ b/cmake/modules/UseMakefileCommon.cmake
@@ -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()
+