Re: [AD] CMake on Mac OS X |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Wednesday 10 September 2008 06:18:27 am Milan Mimica wrote:
> Peter Wang wrote:
> > We used to do the following but Trent changed it for some reason.
> > I'd try that, or else follow the find_path/find_library examples in
> > (e.g.) FindFreetype.cmake.
>
> I remember he changed it because it wasn't detecting vorbis. I've had
> problems with find_library and find_path myself too.
Does OSX have/use pkg-config? CMake 2.4 comes with pkg_check_modules which
handilly gives needed -I and -L paths, and gives a list of the needed libs.
The various Find<Package> includes tend to ignore pkg-config. Use it like:
include(FindPkgConfig)
include(UsePkgConfig)
...
pkg_check_modules(FFmpeg libavcodec libavformat)
if(NOT FFmpeg_FOUND)
check_include_file(ffmpeg/avcodec.h HAVE_FFMPEG_AVCODEC_H)
check_include_file(ffmpeg/avformat.h HAVE_FFMPEG_AVFORMAT_H)
if(NOT HAVE_FFMPEG_AVCODEC_H AND NOT HAVE_FFMPEG_AVFORMAT_H)
message(FATAL_ERROR "FFmpeg not found!")
endif()
set(FFmpeg_LIBRARIES avformat avcodec)
else()
include_directories(${FFmpeg_INCLUDE_DIRS})
link_directories(${FFmpeg_LIBRARY_DIRS})
endif()
...
target_link_libraries(mytarget ${FFmpeg_LIBRARIES})
Of course, the NOT path can be expanded to do more rigorous checking. Just
make sure it sets the proper include/link_directories, put the libs in
foo_LIBRARIES, and use foo_LIBRARIES for the list of libraries for the
target(s).