On 01/16/2012 04:23 PM, paspa...@noos.fr wrote: > Thank you michael > > in fact at the beginning I wanted just to do a static local library > > (I am totally new with cmake, before I didn't use that kind of tools with VS > and > recently netbeans) > > finally according to your suggestions I wrote: > > projA > project(proja) > add_library(proja Execute_Msg.cpp)
If you definitely want a static library: ADD_LIBRARY(proja STATIC ...) Without the explicit SHARED/STATIC keyword, the type of the resulting library is determined by the BUILD_SHARED_LIBS variable which can be controlled by the user; this might possibly be undesired. > proj3 > cmake_minimum_required(VERSION 2.8) > project(proj3) > add_subdirectory(projA) > add_executable(proj3 main.cpp) > target_link_libraries(proj3 proja) > > and it works > thanks again > pascal Regards, Michael PS: Please don't drop the ML. > ---- Message d'origine ---- > >De : "Michael Hertling" <mhertl...@online.de> > >À : cmake@cmake.org > >Objet : Re: [CMake] shared library with CMake in kdevelop4 > >Date : 16/01/2012 15:39:29 CET > > > >On 01/16/2012 02:38 PM, paspa...@noos.fr wrote: > > > > > > I am new with kdevelop and cmake so apologize for this pretty naive > > question, I > > > create in kdevelop a proj3 project and want to link a library so I create > > a > > > second project projA within the proj3 directory > > > > > > the projA CMakelist is > > > > > > project(proja) > > > set( lib_SOURCES Execute_Msg.cpp ) > > > add_library(proja ${lib_SOURCES} ) > > > > If you want to get a shared library, you should state this explicitly: > > > > ADD_LIBRARY(proja SHARED ${lib_SOURCES} ) > > > > Also see the BUILD_SHARED_LIBS variable. > > > > > the proj3 CMakelist is > > > > > > cmake_minimum_required(VERSION 2.8) > > > project(proj3) > > > link_directories(/pascal/pKD3/proj3/projA/build) > > > > Never use LINK_DIRECTORIES(), it's unnecessary and dangerous. Instead, > > you need ADD_SUBDIRECTORIES(projA) here to make projA known to proj3. > > > > > add_executable(proj3 main.cpp) > > > target_link_libraries(proj3 libproja) > > > > In TARGET_LINK_LIBRARIES(), refer to targets to link against > > by their *target names*, not by their *file names*, i.e.: > > > > TARGET_LINK_LIBRARIES(proj3 proja) > > > > > there is a libproja file in the /pascal/pKD3/proj3/projA/build directory, > > so I > > > don't understand why I get the message /usr/bin/ld: cannot find > > -llibproja > > > > This is because ld searches a quite restricted set of directories for > > libraries specifed by -l; particularly, it doesn't search the current > > directory. If you specify targets by their target names, CMake uses > > full paths in the linker command lines, so there will be no issue. > > > > > thanks for help > > > > Regards, > > > > Michael -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake