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

William A. Hoffman billlist at nycap.rr.com
Wed Jul 20 09:28:35 EDT 2005


OK, at this point I think a better approach would be to configure or FILE(WRITE 
a CMakeLists.txt file that is used by the try compile.   

Something like this:

FILE(WRITE ${PROJECT_BINARY_DIR}/CMakeTmp/CMakeLists.txt 
"PROJECT(test) 
ADD_EXECUTABLE(test test.cxx)
TARGET_LINK_LIBRARIES(test $SDL_LIBRARY "

TRY_COMPILE(RESULT_VAR ${PROJECT_BINARY_DIR}/CMakeTmp ${PROJECT_BINARY_DIR}/CMakeTmp
              test <targetname> <CMAKE_FLAGS <Flags>>
              <OUTPUT_VARIABLE var>)

-Bill
At 05:22 AM 7/20/2005, E. Wing wrote:
>> > Try this:
>> >
>> >   -DINCLUDE_DIRECTORIES:STRING=${SDL_INCLUDE_DIR}\;${SDL_SOUND_INCLUDE_DIR}
>
>Okay, that seemed to work for my initial case, but I moved my testing
>to Windows and I hit another stumbling block which is related to this.
>So now I am on my link flags. My line looks like this:
>-DLINK_LIBRARIES:STRING=${SDL_SOUND_LIBRARY}\;${SDL_LIBRARY}
>
>The problem is that the ${SDL_LIBRARY} flag may be comprised of
>multiple variables depending on which compiler and which platform I'm
>on. For example, on OS X, it is set like:
>SET(SDL_LIBRARY  "-framework SDL -framework Cocoa")
>
>Under Msys on Windows, it is set like
>FIND_LIBRARY(SDL_LIBRARY ...)
>SET(SDL_LIBRARY ${SDLMAIN_LIBRARY} ${SDL_LIBRARY})
>SET(SDL_LIBRARY ${MINGW32_LIBRARY} ${SDL_LIBRARY})
>(where it comes out to something like
>"mingw32;E:/Libs/libSDLmain.a;E:/Libs/libSDL.dll)
>
>Under Visual Studio, it is similar to Msys, but without the mingw32
>and they link to .lib stubs.
>
>${SDL_LIBRARY} tries to hide all this since both the number of flags
>and the names of the flags will be different everywhere.
>
>So when I run my ${SDL_LIBRARY} variable through the LINK_LIBRARIES
>option, I loose everything except the first entry like I did before.
>How do I massage this data so it gets passed correctly?
>
>Thanks,
>Eric
>_______________________________________________
>CMake mailing list
>CMake at cmake.org
>http://www.cmake.org/mailman/listinfo/cmake 



More information about the CMake mailing list