Cmake & OSX .framework libs


#1

I’m trying to use a cinder block which depends on a pre-built .framework library. I’m using cmake as build tool; is there any way to specify in the cmake config files to copy this .framework into my .app bundle?

The block’s cmake file already refers to the framework (see CINDER_SYPHON_LIBRARIES);

if ( NOT TARGET Cinder-Syphon )
	get_filename_component( CINDER_SYPHON_PATH "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE )
    get_filename_component( CINDER_PATH "${CMAKE_CURRENT_LIST_DIR}/../../../.." ABSOLUTE )

	set( CINDER_SYPHON_INCLUDES
		${CINDER_SYPHON_PATH}/src
		${CINDER_SYPHON_PATH}/lib
	)
	set( CINDER_SYPHON_SOURCES
		${CINDER_SYPHON_PATH}/lib/SyphonNameboundClient.m
		${CINDER_SYPHON_PATH}/src/syphonClient.mm
		${CINDER_SYPHON_PATH}/src/syphonServer.mm
		${CINDER_SYPHON_PATH}/src/syphonServerDirectory.mm
	)
	set_source_files_properties( ${CINDER_SYPHON_SOURCES}
		PROPERTIES COMPILE_FLAGS "-x objective-c++"
	)
	set( CINDER_SYPHON_LIBRARIES
		${CINDER_SYPHON_PATH}/lib/Syphon.framework
	)

	add_library( Cinder-Syphon ${CINDER_SYPHON_SOURCES} )
	target_link_libraries( Cinder-Syphon PUBLIC ${CINDER_SYPHON_LIBRARIES} )

	target_include_directories( Cinder-Syphon PUBLIC "${CINDER_SYPHON_INCLUDES}" )
	target_include_directories( Cinder-Syphon SYSTEM BEFORE PUBLIC "${CINDER_PATH}/include" )

    if ( NOT TARGET cinder )
		include( "${CINDER_PATH}/proj/cmake/configure.cmake" )
		find_package( cinder REQUIRED PATHS
			"${CINDER_PATH}/${CINDER_LIB_DIRECTORY}"
			"$ENV{CINDER_PATH}/${CINDER_LIB_DIRECTORY}" )
    endif()
	target_link_libraries( Cinder-Syphon PRIVATE cinder )
endif()

But when I do the usual build workflow in my app;

mkdir build
cd build
cmake ../proj/cmake
make -j4

The created .app bundle doesn’t contain a copy of Syphon.framework (for now I’ve resolved this with a custom build script which manually copies the .framework into the .app after calling make, but this is less then ideal for a lot of reasons).

This is my app’s cmake file;

cmake_minimum_required( VERSION 3.0 FATAL_ERROR )
set( CMAKE_VERBOSE_MAKEFILE ON )

project( TestApp )

get_filename_component( CINDER_PATH "${CMAKE_CURRENT_LIST_DIR}/../../../cinder_master" ABSOLUTE )
get_filename_component( APP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../" ABSOLUTE )

include( "${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake" )

FILE(GLOB APP_SOURCES ${APP_PATH}/src/*.cpp ${APP_PATH}/src/**/*.cpp)

add_definitions(-DCICMS_CTREE)

ci_make_app(
	SOURCES     ${APP_SOURCES}
	CINDER_PATH ${CINDER_PATH}
	RESOURCES ${APP_PATH}/resources/config.json
	BLOCKS		ciCMS Cinder-Syphon
)

Any suggestions for either block- or app-side changes are more than welcome!

(Note that Syphon is mac-only technology, so other platforms are of no concern here.)


#2

I could solve it from the app side only. Would be better from the cmake file of the block, though. Check out the cmake branch and the samples.


#3

I love it! Thanks. And yea if anybody knows a block-side fix so apps don’t require a custom command in their cmake file that would still be very welcome, but for now this’ll do.