On Tue, Jul 30, 2013 at 11:41:09AM -0700, Gerald Combs wrote:
> BTW, it looks like you can pull Makefile-style definitions into CMake.
> This would make maintenance easier everywhere, not just in ui/qt:
>
> https://github.com/berenm/xoreos/blob/a187e94eca041c7c53c76e943483fcaa612cbf4a/cmake/CMakeAM.cmake
It looks like it does not really what I want - it seems to read configure.ac
and Makefile.am files and create the targets from that. Doing that would be
"not helpful (tm)", as we would loose all the features that prompted me to
start the cmake stuff in the first place.
Reading Makefile.common is an entirely different thing and I started to
write an importer for that when I did the asn1/ stuff. It didn't really
work though. When I looked at the like above I got the idea that replacing
the macros by functions might solve that problem.
I've attached my original implementation. I won't be able to work on that
for the next 10 days or so due to paid work.
Ciao
Jörg
--
Joerg Mayer <jmayer@xxxxxxxxx>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.
Index: cmake/modules/UseMakefileCommon.cmake
===================================================================
--- cmake/modules/UseMakefileCommon.cmake (revision 0)
+++ cmake/modules/UseMakefileCommon.cmake (revision 0)
@@ -0,0 +1,59 @@
+#
+# $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> )
+
+MACRO( 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_tmp
+ "${_use_mc_content}"
+ )
+
+ # '(' -> '{', ')' -> '}'
+ string( REGEX REPLACE
+ "\\("
+ "{"
+ _use_mc_tmp
+ "${_use_mc_tmp}"
+ )
+ string( REGEX REPLACE
+ "\\)"
+ "}"
+ _use_mc_tmp
+ "${_use_mc_tmp}"
+ )
+ # message( STATUS "${_use_mc_tmp}" )
+
+ foreach( _use_mc_varname ${ARGN} )
+ string( REGEX MATCH
+ ".*${_use_mc_varname}[ \t]*=[ \t]*([^\n]*)\r?[\n].*"
+ _use_mc_tmp1
+ "${_use_mc_tmp}"
+ )
+ set( _use_mc_tmp1 ${CMAKE_MATCH_1} )
+ string( REGEX REPLACE
+ "[ \t]+"
+ ";"
+ ${_use_mc_varname}
+ "${_use_mc_tmp1}"
+ )
+ message( STATUS "${_path_to_mc}/Makefile.common: ${_use_mc_varname}=${${_use_mc_varname}}" )
+ endforeach()
+
+ENDMACRO()
+
Property changes on: cmake/modules/UseMakefileCommon.cmake
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Index: asn1/c1222/CMakeLists.txt
===================================================================
--- asn1/c1222/CMakeLists.txt (revision 51032)
+++ asn1/c1222/CMakeLists.txt (working copy)
@@ -21,30 +21,40 @@
# 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
+)
+
+#set( PROTOCOL_NAME c1222 )
set( PROTO_OPT )
set( EXT_ASN_FILE_LIST
)
-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( SRC_FILES
- ${EXTRA_DIST}
- ${EXT_ASN_FILE_LIST}
-)
+#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( SRC_FILES
+# ${EXTRA_DIST}
+# ${EXT_ASN_FILE_LIST}
+#)
-set( A2W_FLAGS -b )
+#set( A2W_FLAGS -b )
set( EXTRA_CNF
)