[cmake-developers] Cmake configure unicode?

J Decker d3ck0r at gmail.com
Thu Oct 10 00:34:54 EDT 2013


Should cmake be able to configure unicode, if the unicode file has
appropriate byte order indicators maybe?

I know it doesn't... for windows (and a bad test for if windows at that)

  macro( DO_CONFIGURE_FILE input output )
    if( $ENV{COMSPEC} MATCHES cmd )
      STRING( REPLACE "/" "\\" s1 ${CMAKE_CURRENT_SOURCE_DIR}/${input} )
      STRING( REPLACE "/" "\\" s2 ${CMAKE_BINARY_DIR}/${output} )
      STRING( REPLACE "/" "\\" finalout
${CMAKE_INSTALL_PREFIX}/${INTERFACE_OUTPUT_DIR}/${output} )
      STRING( REPLACE "/" "\\" leader
${CMAKE_CURRENT_SOURCE_DIR}\\BlankUnicode.txt )
      EXECUTE_PROCESS(COMMAND cmd /c type ${s1} OUTPUT_FILE ${s2}.tmp )
      configure_file( ${s2}.tmp ${s2}.configured )
      EXECUTE_PROCESS(COMMAND cmd /U /C type ${s2}.configured
OUTPUT_FILE ${s2}.configured.unicode )
      EXECUTE_PROCESS(COMMAND cmd /c copy /b
${leader}+${s2}.configured.unicode ${finalout} )
    else()
      message( "NO METHOD TO CONFIGURE INTERFACE FILES" )
      abort()
    endif( $ENV{COMSPEC} MATCHES cmd )
  endmacro( DO_CONFIGURE_FILE )

Seems to work using a few temporary files and command prompt's copy
command to do the translation.



More information about the cmake-developers mailing list