[CMake] MacOS bundle using MACOS_PACKAGE_LOCATION with XCode - files not copied

clinton at elemtech.com clinton at elemtech.com
Wed May 29 23:37:45 EDT 2013



----- Original Message -----
> Hello,
> 
> I'm using cmake to generate an Xcode project which is supposed to build a
> bundle. Thus, I use the source file property MACOSX_PACKAGE_LOCATION to
> place my data (database, GUI, localization files, …) in the correct
> directory in my bundle.
> 
> I used to have a general CMakeLists.txt with several commands like follows:
> 
> file(GLOB VAR_GUI
> 	${RESOURCE_PATH}/GUI/*
> 	)
> set_source_files_properties(
> 	${VAR_GUI}
> 	PROPERTIES
> 	MACOSX_PACKAGE_LOCATION Resources/GUI
> 	)
> 
> Then one command to concatenate all the independent variables (used to
> separate the different directories)
> set(RESOURCES "${VAR_GUI};…")
> 
> Finally, in my main CMakeLists.txt i wrote :
> add_executable(${CMAKE_PROJECT_NAME} MACOSX_BUNDLE ${SOURCES} ${HEADERS}
> ${RESOURCES})
> 
> So every data of my project was more or else added by hand. I wanted to
> automated the process so i wrote a python script that does the job for me.
> The script proceeds by writing a file in which each directory of my resource
> directory has its own variable listing the files in it (semi-colon separated
> element list). It also generate a set of 'source_group' command to organize
> resources in the IDE.
> The generated file is included in my main CMakeLists.txt using the 'include'
> command.
> 
> The generated file use commands like follows:
> 
> set(RESOURCE_GUI
> 	<path_to_file_1>;<path_to_file_2>;…
> 	)
> 
> set_source_files_properties(
> 	${RESOURCE_GUI}
> 	PROPERTIES
> 	MACOSX_PACKAGE_LOCATION Resources/GUI
> 	)
> 
> Unfortunately, with this new generated included file, the resources are
> successfully added to the Xcode project but when I build the project, the
> resources are no longer copied into the bundle.
> 
> I checked that the include command wasn't the issue since my old commands
> (hand written) works when i put them in the included file (in place of the
> generated commands).
> Trying to figure out the issue, I notice that in Xcode, the only difference
> between resources added by my generated file and the old ones is that the
> old commands were in the end marking my resources file as target member
> (target membership is checked in Xcode). With the generated file, the
> resources are in the project but not marked as member of the target.
> I thought maybe the 'file' command was setting other source file properties
> like EXTERNAL_OBJECT so i tried setting it up by hand, but it doesn't work
> either.


Does your add_executable() include ${RESOURCE_GUI} after your changes?

Clint


More information about the CMake mailing list