[CMake] need two compilation to achieve success

eial at cs.bgu.ac.il eial at cs.bgu.ac.il
Wed Jun 3 15:36:13 EDT 2009


On Wed 03 Jun 22:25 2009 Michael Jackson wrote:
> 
> 
> On Jun 3, 2009, at 2:53 PM, eial at cs.bgu.ac.il wrote:
> 
> >
> > TARGET_LINK_LIBRARIES(AgathaHud libAgathaUtils libAgathaEngine  
> > libAgathaThreads)
> > the error output is: /usr/lib/gcc/x86_64-pc-linux-gnu/ 
> > 4.3.3/../../../../x86_64-pc-linux-gnu/bin/ld:
> > cannot find -llibAgathaUtils
> >
> > like I've said before, the libs are generated into the bin/libs  
> > folder and the actual program binary
> > is created at bin
> 
> Subtle..
> 
>   You need something like:
> 
> link_directories (${PROJECT_BINARY_DIR}/bin/lib )
> 
> Assuming you only have one call to "project()"
> 
> If you are dumping libraries into bin/libs then I would set the  
> following variables near the top of the top most cmakelists.txt file,  
> just after the first call to "project"
> 
> # ---------- Setup output Directories -------------------------
> SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY
>    ${PROJECT_BINARY_DIR}/bin/libs
>    CACHE PATH
>    "Single Directory for all Libraries"
>    )
> 
> # --------- Setup the Executable output Directory -------------
> SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY
>    ${PROJECT_BINARY_DIR}/bin
>    CACHE PATH
>    "Single Directory for all Executables."
>    )
> 
> # --------- Setup the Executable output Directory -------------
> SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
>    ${PROJECT_BINARY_DIR}/bin/libs
>    CACHE PATH
>    "Single Directory for all static libraries."
>    )
> 
> then you can use those variables in your other sub projects if needed:
> 
> link_libraries(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
> 
> HTH.
> 
> _________________________________________________________
> Mike Jackson                  mike.jackson at bluequartz.net
> BlueQuartz Software                    www.bluequartz.net
> Principal Software Engineer                  Dayton, Ohio
> 
> 

thanks for the tip though but my current problem is in regards to the linking of external libs, I've used to add them to the TARGET_LINK_LIBRARIES but it was suggested here not to use it in that way.

btw, trying your suggestion generates this warnings:
WARNING: Target "AgathaEngine" requests linking to directory "/home/dagg/workspace/AgathaHud/bin/libs". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "AgathaHud" requests linking to directory "/home/dagg/workspace/AgathaHud/bin/libs". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "AgathaHud" requests linking to directory "/home/dagg/workspace/AgathaHud/bin/libs". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "AgathaThreads" requests linking to directory "/home/dagg/workspace/AgathaHud/bin/libs". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "AgathaUtils" requests linking to directory "/home/dagg/workspace/AgathaHud/bin/libs". Targets may link only to libraries. CMake i






More information about the CMake mailing list