How to add_executable(targetB MACOSX_BUNDLE targetB.cc targetA) ?

include(CPack)

set(MACOSX_BUNDLE TRUE)
set(MACOSX_BUNDLE_BUNDLE_NAME targetB)
set(MACOSX_BUNDLE_ICON_FILE iconfile.icns)
set(MACOSX_BUNDLE_STARTUP_COMMAND targetB)
add_executable(targetA targetA.cc)
add_executable(targetB MACOSX_BUNDLE targetB.cc)
add_dependency(targetB targetA)

I have a C++ exe targetB on Mac OS X, and I am trying to get a previous dependent targetA (not a library, another executable) into it’s sources so that it will be put into the same bundle. If I leave out targetA from the sources in the add_executable command it doesn’t get in the bundle. However, if I leave it in it won’t build because cmake says the targetA doesn’t exist.

Any ideas?

You shouldn’t need the add_dependencies, but it probably doesn’t hurt too much either. You probably need a install(TARGETS targetA) with the appropriate destination. You’ll want it to come after the install for targetB though so that the directory structure exists.

If I may jump in here for a sec. This is very similar to my question here. So, what you are suggesting is to build one of the executables as MACOSX_BUNDLE and install the second on in the Contents/MacOS folder next to it, right?

Yes, I think that works. It may not be the best solution though, but I don’t know of one right now.