diff options
author | Miguel A. Figueroa-Villanueva <miguelf@ieee.org> | 2007-12-02 00:30:11 (GMT) |
---|---|---|
committer | Miguel A. Figueroa-Villanueva <miguelf@ieee.org> | 2007-12-02 00:30:11 (GMT) |
commit | 4cee09fd4cee423f3b95137273c15779e1ba1835 (patch) | |
tree | bd9f91e4393bc58910e80afc8a698e1af80764b3 /Modules/FindwxWidgets.cmake | |
parent | dd7a655b601416036f956ff6496d6378858ed433 (diff) | |
download | CMake-4cee09fd4cee423f3b95137273c15779e1ba1835.zip CMake-4cee09fd4cee423f3b95137273c15779e1ba1835.tar.gz CMake-4cee09fd4cee423f3b95137273c15779e1ba1835.tar.bz2 |
ENH: Added macro support for compiling xrc resources to cpp code.
Diffstat (limited to 'Modules/FindwxWidgets.cmake')
-rw-r--r-- | Modules/FindwxWidgets.cmake | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 5ff9217..a294a02 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -640,3 +640,80 @@ DBG_MSG("wxWidgets_USE_FILE : ${wxWidgets_USE_FILE}") #===================================================================== INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(wxWidgets DEFAULT_MSG wxWidgets_FOUND) + +#===================================================================== +# Macros for use in wxWidgets apps. +# - This module will not fail to find wxWidgets based on the code +# below. Hence, it's required to check for validity of: +# +# wxWidgets_wxrc_EXECUTABLE +#===================================================================== + +# Resource file compiler. +FIND_PROGRAM(wxWidgets_wxrc_EXECUTABLE wxrc + ${wxWidgets_ROOT_DIR}/utils/wxrc/vc_msw + ) + +# +# WXWIDGETS_ADD_RESOURCES(<sources> <xrc_files>) +# +# Adds a custom command for resource file compilation of the +# <xrc_files> and appends the output files to <sources>. +# +# Example usage: WXWIDGETS_ADD_RESOURCES(sources xrc/main_frame.xrc) +# +MACRO(WXWIDGETS_ADD_RESOURCES outfiles) + SET(_RC_INFILES) + SET(_RC_DEPENDS) + FOREACH(it ${ARGN}) + GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) + GET_FILENAME_COMPONENT(rc_path ${infile} PATH) + LIST(APPEND _RC_INFILES ${infile}) + + # parse file for dependencies; all files are absolute paths or + # relative to the location of the rc file + FILE(READ "${infile}" _RC_FILE_CONTENTS) + + # get bitmap/bitmap2 files + STRING(REGEX MATCHALL "<bitmap[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}") + FOREACH(_RC_FILE ${_RC_FILES}) + STRING(REGEX REPLACE "^<bitmap[^>]*>" "" _RC_FILE "${_RC_FILE}") + STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}") + IF(NOT _ABS_PATH_INDICATOR) + SET(_RC_FILE "${rc_path}/${_RC_FILE}") + ENDIF(NOT _ABS_PATH_INDICATOR) + LIST(APPEND _RC_DEPENDS "${_RC_FILE}") + ENDFOREACH(_RC_FILE) + + # get url files + STRING(REGEX MATCHALL "<url[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}") + FOREACH(_RC_FILE ${_RC_FILES}) + STRING(REGEX REPLACE "^<url[^>]*>" "" _RC_FILE "${_RC_FILE}") + STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}") + IF(NOT _ABS_PATH_INDICATOR) + SET(_RC_FILE "${rc_path}/${_RC_FILE}") + ENDIF(NOT _ABS_PATH_INDICATOR) + LIST(APPEND _RC_DEPENDS "${_RC_FILE}") + ENDFOREACH(_RC_FILE) + + # get wxIcon files + STRING(REGEX MATCHALL "<object[^>]*class=\"wxIcon\"[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}") + FOREACH(_RC_FILE ${_RC_FILES}) + STRING(REGEX REPLACE "^<object[^>]*>" "" _RC_FILE "${_RC_FILE}") + STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}") + IF(NOT _ABS_PATH_INDICATOR) + SET(_RC_FILE "${rc_path}/${_RC_FILE}") + ENDIF(NOT _ABS_PATH_INDICATOR) + LIST(APPEND _RC_DEPENDS "${_RC_FILE}") + ENDFOREACH(_RC_FILE) + ENDFOREACH (it) + + SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/wxrc_resources.cxx) + ADD_CUSTOM_COMMAND( + OUTPUT ${outfile} + COMMAND ${wxWidgets_wxrc_EXECUTABLE} + --cpp-code --output=${outfile} ${_RC_INFILES} + DEPENDS ${_RC_INFILES} ${_RC_DEPENDS} + ) + LIST(APPEND ${outfiles} ${outfile}) +ENDMACRO(WXWIDGETS_ADD_RESOURCES) |