[CMake] Figuring out dependencies for a library in order to build

William A. Hoffman billlist at nycap.rr.com
Mon Jul 18 16:43:29 EDT 2005


At 04:03 PM 7/18/2005, E. Wing wrote:

>So for right now, getting this stuff built has been an exercise left
>to the user. Until recently, I think most of the people using SDL
>sound built it themselves and didn't worry about others needing to
>compile their stuff. The ones who did might statically link in all the
>other library dependencies directly into SDL_sound and then
>dynamically link against it (to remain LGPL compliant). But I'm
>starting to see SDL_sound in distros. And for my own projects, I keep
>forgetting how I compiled it (and it's different for each platform
>depending on which source code I can actually get compiled). So I
>would like to solve this problem.
>
>So could you elaborate on how I would use the TRY_COMPILEs? My first
>problem is that the TRY_COMPILE needs to specify the include paths for
>SDL.h and SDL_sound.h. So I need to essentially run a FIND_INCLUDE
>first and pass it to TRY_COMPILE. In addition, I need to also
>essentially do a FIND_LIBRARY on SDL and SDL_sound (for -lSDL or
>-framework SDL_sound, etc) so I can get far enough in the link process
>so it can complain about the 3rd party symbols and not the SDL
>symbols. I'm not sure how to pass any of this to the TRY_COMPILE. I
>looked at the COMPILE_DEFINITIONS, but the documentation said it was
>only for -D flags. I tried using it anyway...my -I flags, but the
>-framework/-l flags were disregarded because they were used too early
>in the compile process.
>
>I'm also unsure what to expect in the OUTPUT_VARIABLE and how I can
>interpret the output in a general enough way to deal with cross
>platform issues. Do you have any suggestions here?


OK, well if they hate autoconf, then the correct thing to do is to get the SDL
to use CMake, and create Find/Use package files for SDL.  Then you just need
to do a FIND_PACKAGE(SDL)  and it should work.   

For the TRY_COMPILE stuff you use the RESULT_VAR and not the OUTPUT_VARIABLE.
If it compiles then it should be OK.   It would seem that there is some missing
documentation for TRY_COMPILE.   In addition to COMPILE_DEFINITIONS, 
INCLUDE_DIRECTORIES, LINK_DIRECTORIES, and LINK_LIBRARIES are also used by
trycompile commands.

-Bill





More information about the CMake mailing list