That's what I'm doing:
1) In my CMakeLists.txt file, I have the following:
IF (APPLE) SET_TARGET_PROPERTIES( MyFramework PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES( MyFramework PROPERTIES XCODE_ATTRIBUTE_INSTALL_PATH @executable_path/../Frameworks/ ) ENDIF (APPLE)
The second line of "set_target_properties" sets up the structure for always searching in the application set in the Frameworks subfolder.
2) In my top-level CMakeLists.txt file, I add the unified binary setting to the output directory:
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin) SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin ) SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin )
3) Then in my application file “CMakeLists.txt” I have the following:
IF (APPLE) ADD_CUSTOM_COMMAND( TARGET MyApp POST_BUILD COMMAND ${PYTHON_EXECUTABLE} ARGS ${CMAKE_HOME_DIRECTORY}/CopyFramework.py --binary ${PROJECT_BINARY_DIR}/Bin --framework MyFramework.framework --app MyApp.app ) ENDIF (APPLE)
This calls my python script, which builds the src and dest path, and actually copies the Framework.
The final trick is that since this is only a Mac, I can rely on the Xcode environment variable in a Python script:
config= os.environ["CONFIGURATION"]
This allows me to compile the full path to the actual binary location of the framework and the application.
The only thing I wish for was that there was a CMake variable that went to the current Configuration in the context of ADD_CUSTOM_COMMAND ... It would be nice not to resort to using Xcode.
source share