Patch to add two more automoc4 convenience macros

Matthias Kretz kretz at kde.org
Tue Jul 29 17:02:52 CEST 2008


Hi,

for all the automoc4 users that cannot use KDE4Macros.cmake I'd like to add 
the following two macros:

macro(ADD_AUTOMOC4_EXECUTABLE _target_NAME)
   set(_SRCS ${ARGN})

   set(_add_executable_param)
   foreach(_argName "WIN32" "MACOSX_BUNDLE" "EXCLUDE_FROM_ALL")
      list(GET _SRCS 0 _arg)
      if(_arg STREQUAL _argName)
         list(APPEND _add_executable_param ${_argName})
         list(REMOVE_AT _SRCS 0)
      endif(_arg STREQUAL _argName)
   endforeach(_argName)

   if(MSVC)
      add_automoc4_target("${_target_NAME}_automoc" _SRCS)
   else(MSVC)
      automoc4(${_target_NAME} _SRCS)
   endif(MSVC)
   add_executable(${_target_NAME} ${_add_executable_param} ${_SRCS})
   if(MSVC)
      add_dependencies(${_target_NAME} "${_target_NAME}_automoc")
   endif(MSVC)
endmacro(ADD_AUTOMOC4_EXECUTABLE)

macro(ADD_AUTOMOC4_LIBRARY _target_NAME)
   set(_SRCS ${ARGN})

   set(_add_executable_param)
   foreach(_argName "STATIC" "SHARED" "MODULE" "EXCLUDE_FROM_ALL")
      list(GET _SRCS 0 _arg)
      if(_arg STREQUAL _argName)
         list(APPEND _add_executable_param ${_argName})
         list(REMOVE_AT _SRCS 0)
      endif(_arg STREQUAL _argName)
   endforeach(_argName)

   if(MSVC)
      add_automoc4_target("${_target_NAME}_automoc" _SRCS)
   else(MSVC)
      automoc4(${_target_NAME} _SRCS)
   endif(MSVC)
   add_library(${_target_NAME} ${_add_executable_param} ${_SRCS})
   if(MSVC)
      add_dependencies(${_target_NAME} "${_target_NAME}_automoc")
   endif(MSVC)
endmacro(ADD_AUTOMOC4_LIBRARY)

AFAICS we could then also switch the macros in KDE4Macros.cmake to use this.

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de



More information about the Kde-buildsystem mailing list