[CMake] Good sample code for finding and using os x frameworks?

Mike Jackson imikejackson at gmail.com
Thu Apr 5 17:44:20 EDT 2007


Here is a code snippet from a CMakeLists.txt file that i use to  
compile some Qt projects. Qt needs the Carbon framework, Quicktime  
Framework and ApplicationServices.

IF(APPLE)
#SET(GUI_TYPE MACOSX_BUNDLE)
INCLUDE_DIRECTORIES ( /Developer/Headers/FlatCarbon )
FIND_LIBRARY(CARBON_LIBRARY Carbon)
FIND_LIBRARY(QUICKTIME_LIBRARY QuickTime )
FIND_LIBRARY(APP_SERVICES_LIBRARY ApplicationServices )
MARK_AS_ADVANCED (CARBON_LIBRARY)
MARK_AS_ADVANCED (QUICKTIME_LIBRARY)
MARK_AS_ADVANCED (APP_SERVICES_LIBRARY)
SET(EXTRA_LIBS ${CARBON_LIBRARY} ${QUICKTIME_LIBRARY} $ 
{APP_SERVICES_LIBRARY} ${EXTRA_LIBS})
ENDIF (APPLE)

... Then later on in the file:

ADD_EXECUTABLE( ${MHDVIEWER_EXE_NAME} ${GUI_TYPE} ${PROJECT_SRCS} )

TARGET_LINK_LIBRARIES( ${MHDVIEWER_EXE_NAME} ${EXTRA_LIBS} )

As far as the syntax for the #includes..Apple seems to have this style:

#include <Carbon/Carbon.h>

Hope that helps
-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On Apr 5, 2007, at 5:22 PM, Andrew Wagner wrote:

> Hello-
>
> I'm writing some software that I'm trying to keep as portable as  
> possible, but alas will need to use some apple-specific code to  
> query mouse position.   Are there any good examples for the current  
> best way of doing this?  i.e. should my source have #include  
> <framework/header.h> or just #include<header.h>?  Are there modules  
> for finding the standard os x frameworks, or should I hard code the  
> paths in my CMakeLists.txt?  I hunted around a lot for this, but  
> all I could find were discussions on the mailing list that did not  
> seem to imply any sort of consensus yet, and were discussing future  
> development.  I'm still new to cmake, so please forgive me if I'm  
> not even asking the right question.
>
> For the time being, I don't care about creating frameworks; just  
> using existing ones supplied by apple.
>
> Thanks,
> Drew
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list