[CMake] Figuring out dependencies for a library in order to build
E. Wing
ewmailing at gmail.com
Tue Jul 19 17:20:29 EDT 2005
> TRY_COMPILE(
> MY_RESULT
> ${CMAKE_BINARY_DIR}
> ${PROJECT_SOURCE_DIR}/test_sdlsound.c
> COMPILE_DEFINITIONS "-I/Library/Frameworks/SDL.framework/Headers"
> "-I/Library/Frameworks/SDL_sound.framework/Headers" "-framework
> SDL.framework" "-framework SDL_sound"
> CMAKE_FLAGS -DINCLUDE_DIRECTORIES:STRING=...
> -DLINK_DIRECTORIES:STRING=...
> -DLINK_LIBRARIES:STRING=...
> OUTPUT_VARIABLE MY_OUTPUT
> )
>
>
> To help in debugging things if you run cmake --debug-trycompile it will leave
> the temporary files in CMakeTmp. Also CMakeError.log and CMakeOutput.log are
> good places to look at what is going on.
>
Okay, I'm almost there, but I'm having trouble massaging my strings so
CMake does what I need.
I'm still stuck on the INCLUDE_DIRECTORIES part, so I'll ignore the
LINK stuff for now.
If I try this:
TRY_COMPILE(
MY_RESULT
${CMAKE_BINARY_DIR}
${PROJECT_SOURCE_DIR}/test_sdlsound.c
CMAKE_FLAGS
-DINCLUDE_DIRECTORIES:STRING=${SDL_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}
OUTPUT_VARIABLE MY_OUTPUT
)
(Or if I use a semicolon instead of a space between the
${SDL_INCLUDE_DIR} and ${SDL_SOUND_INCLUDE_DIR}),
when CMake runs the TRY_COMPILE, I only see the first variable with a
-I listed in the gcc compile line. The second variable is dropped.
If I try doing:
TRY_COMPILE(
MY_RESULT
${CMAKE_BINARY_DIR}
${PROJECT_SOURCE_DIR}/test_sdlsound.c
CMAKE_FLAGS
-DINCLUDE_DIRECTORIES:STRING="${SDL_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}"
OUTPUT_VARIABLE MY_OUTPUT
)
The quotes seem to crash CMake with the following error:
/Volumes/DataPartition1_Tiger/Tiger/SOFTWARE/CMAKE/CVS_UNTOUCHED/CMake/Source/cmGlobalGenerator.cxx:915:
failed assertion `in_remote[0] != '\"''
Abort trap
If I try doing something with a temporary variable like:
SET(TEMP_INCLUDE_STRING "${SDL_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}")
and specify STRING=${TEMP_INCLUDE_STRING}
CMake lists the entire string, but only the first variable gets a -I
attached and the following entry is listed as is (which is meaningless
to the compiler).
Finally, if I try something like this:
TRY_COMPILE(
MY_RESULT
${CMAKE_BINARY_DIR}
${PROJECT_SOURCE_DIR}/test_sdlsound.c
CMAKE_FLAGS
-DINCLUDE_DIRECTORIES:STRING=${SDL_INCLUDE_DIR}
-DINCLUDE_DIRECTORIES: STRING=${SDL_SOUND_INCLUDE_DIR}
OUTPUT_VARIABLE MY_OUTPUT
)
The second entry gets listed with the -I, but the first entry seems to
be missing (so I think it got reset).
So what is the correct way of listing multiple pieces? (I assume this
solution will be the same for the LINK_DIRECTORIES and
LINK_LIBRARIES.)
Thanks,
Eric
More information about the CMake
mailing list