[CMake] Need cmake help for MacOsX

Michael Wild themiwi at gmail.com
Sat May 22 07:01:26 EDT 2010


On 22. May, 2010, at 9:27 , Jerome Vernet wrote:

> Le 22/05/10 09:11, Michael Wild a écrit :
>> You're not thinking far enough ;-)
>> 
>> set(APP_RSRCS_FRENCH French.lproj/SDLMain.nib ...)
>> 
>> set_source_files_properties(${APP_RSRCS_FRENCH} PROPERTIES
>>   MACOSX_PACKAGE_LOCATION Resources/French.lproj)
>> 
>>   
> Yes, but I need to do that for each file in each .lproj folder.
> 
> I've resolved my problem by doing something like that:
> 
> # Create Hatari.app bundle
> 
>    add_custom_target( osx_bundle_dirs
>                COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/hatari.app/Contents/Resources
>                COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/hatari.app/Contents/MacOS
>                COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/gui-osx/${MACOSX_BUNDLE_ICON_FILE}
>                    ${CMAKE_CURRENT_BINARY_DIR}/Hatari.app/Contents/Resources/${MACOSX_BUNDLE_ICON_FILE}
> 
>            # Copy Localized .nib to Bundle
>                COMMAND cp -R ${CMAKE_CURRENT_SOURCE_DIR}/gui-osx/*.lproj ${CMAKE_CURRENT_BINARY_DIR}/Hatari.app/Contents/Resources/
>       )
>    add_dependencies(hatari osx_bundle_dirs)
>    set_source_files_properties(${GUIOSX_RSRCS}
>            PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
> 
> It will create the bundle if not exist, then copy every .lproj folder inside. That what I want. I'm not sure it's the best way to do that, maybe cmake have function that are supposed to do that, but i'm bored.
> 
> Thanks for help !
> 
> 
> Jerome

Well, you are also listing all the source files, aren't you. So it's no real hardship to list all language files, isn't it? I would do it like this:

# common language resource files
set(COMMON_LANG_RSCRCS SDLMain.nib ...)
# language resource files not common to all languages
set(French_LANG_RSRCS ...)
set(English_LANG_RSRCS ...)
set(German_LANG_RSRCS ...)

set(LANG_RSRCS)
# loop over languages
foreach(lang French English German)
  # loop over common language files and append to list of language resources
  foreach(r IN LISTS COMMON_LANG_RSCRCS)
    list(APPEND ${lang}_LANG_RSRCS ${lang}.lproj/${r})
  endforeach()
  # specify bundle-location of these language-resources
  set_source_files_properties(${${lang}_LANG_RSRCS} PROPERTIES
    MACOSX_PACKAGE_LOCATION Resources/${lang}.lproj)
  # append language resources to a list containing all files for all languages
  list(APPEND LANG_RSRCS ${lang}_LANG_RSRCS)
endforeach()



HTH

Michael


More information about the CMake mailing list