[Cmake] generating executables
Mónica Hernández Giménez
mhg at posta . unizar . es
Wed, 27 Aug 2003 12:58:35 +0200
Hi:
I have a problem with the generation of my executables using cmake.
I have a project called myexample with folders include, src and applications.
The CMakeLists.txt from the main folder is:
# Name of project
PROJECT (MYEXAMPLE)
SUBDIRS(src applications)
***************************************************************************************
***************************************************************************************
The CMakeLists.txt from the src folder is:
# Include directories (*.h)
INCLUDE_DIRECTORIES (${MYEXAMPLE_SOURCE_DIR}/include)
# Source directories (*.cc)
FILE(GLOB MYEXAMPLE_SOURCE_LIST ${MYEXAMPLE_SOURCE_DIR}/src/*.cc)
# Building myexample library
SET(LIBRARY_OUTPUT_PATH ${MYEXAMPLE_BINARY_DIR}/lib)
ADD_LIBRARY(myexample ${MYEXAMPLE_SOURCE_LIST})
*******************************************************************************************
*******************************************************************************************
The CMakeLists.txt from the applications folder is:
# Include directories (*.h)
INCLUDE_DIRECTORIES(${MYEXAMPLE_SOURCE_DIR}/include)
# Source directories (*.cc)
FILE(GLOB MYEXAMPLE_SOURCE_LIST ${MYEXAMPLE_SOURCE_DIR}/applications/*.cc)
#Link to myexample library
LINK_DIRECTORIES (${MYEXAMPLE_BINARY_DIR}/lib)
LINK_LIBRARIES(libmyexample)
# Building myexample library
SET(LIBRARY_OUTPUT_PATH ${MYEXAMPLE_BINARY_DIR}/lib)
SET(EXECUTABLE_OUTPUT_PATH ${MYEXAMPLE_BINARY_DIR}/bin)
ADD_EXECUTABLE(demo demo.cc)
ADD_LIBRARY(myexample ${MYEXAMPLE_SOURCE_LIST})
***********************************************************************************
***********************************************************************************
If I try to compile it, when building the executables I get this error:
Building executable /extra/local/usrsrc/monica/examples/MyExample/bin/demo...
/usr/bin/ld: cannot find -llibmyexample
collect2: ld returned 1 exit status
gmake[3]: *** [/extra/local/usrsrc/monica/examples/MyExample/bin/demo] Error 1
What's happening?????
Another thing:
If I have several *.cc in my applications folder and I want to build all of
them, is there an alternative way instead of doing ADD_EXECUTABLE *.cc by
*.cc to do the whole thing?
Thanks a lot!!!
------------------------------------------------------------------------------------------------------------------
Mónica Hernández Giménez
Departamento de Ingeniería Electrónica y Comunicaciones
Lab. 3.05
Centro Politécnico Superior. Universidad de Zaragoza
Phone. (+34) 976 76 27 05
Fax: (+34) 976 76 21 11
e-mail: mhg at unizar . es
------------------------------------------------------------------------------------------------------------------