[CMake] Add subdir and library in CmakeList.txt

Jonick, Kathy-P57450 Kathleen.Jonick at gdc4s.com
Mon Sep 26 11:39:37 EDT 2005


Hi Bill,

Thanks for the help.  I am using cmake version 2.0.6.  I downloaded the
2.2.1 version, but I don't think the ADD_SUBDIRECTORIES option is what I
need.

I am setting up SNMP to build via cmake as a demo for our development
team.  In the net-snmp/agent subdirectory, I want to build libraries in
two subdirectories (helpers and mibgroup), then build a library in the
agent directory.  I have a CMakeList.txt in helpers and mibgroup, that
both build fine.  Below is the file for agent.  The problem again is
that the source files I am listing here in the agent file, it is trying
to find in the helpers subdirectory.  I get the following error:

# cmake .
-- Check for working C compiler: gcc -- works
-- Check for working CXX compiler: c++ -- works
CMake Error: can not find file
/mpc_demo/snmp_cmake/net-snmp/agent/helpers/snmp_agent.c

Tried .c .C .c++ .cc .cpp .cxx .m .M .mm .h .h++ .hm .hpp .hxx .in .txx
CMake Error: can not find file
/mpc_demo/snmp_cmake/net-snmp/agent/helpers/snmp_vars.c
.........

Net-snmp/agent/helpers/CMakeList.txt:
SUBDIRS( helpers mibgroup )
SET(SOURCES snmp_agent.c
        snmp_vars.c
        agent_read_config.c
        agent_registry.c
        agent_index.c
        agent_trap.c
        kernel.c
        agent_handler.c
        mibgroup/snmpv3/usmConf.c
        mibgroup/agentx/master.c
        mibgroup/agentx/subagent.c
        mibgroup/mibII/vacm_conf.c
        mibgroup/utilities/execute.c
        mibgroup/agentx/protocol.c
        mibgroup/agentx/client.c
        mibgroup/agentx/master_admin.c
        mibgroup/agentx/agentx_config.c )

INCLUDE_DIRECTORIES(../include . ../agent ../agent/mibgroup ../snmplib)

ADD_LIBRARY(netsnmpagents SHARED ${SOURCES})


Thanks!

Kathy

-----Original Message-----
From: William A. Hoffman [mailto:billlist at nycap.rr.com] 
Sent: Friday, September 23, 2005 5:30 PM
To: Jonick, Kathy-P57450; cmake at cmake.org
Subject: RE: [CMake] Add subdir and library in CmakeList.txt

In cmake 2.2.1 you can use the ADD_SUBDIRECTORY command that will add
the sub directory immediately.   I would have to see more of your
cmakelist
files to understand the problem you are having here.  If File1.c is in
the current directory, then SUBDIRS should not affect it at all.  

-Bill
 

At 06:16 PM 9/23/2005, Jonick, Kathy-P57450 wrote:
>File1.c is location in the current directory.  But it is looking in the

>directory listed in the SUBDIRS command.  I wanted it to build those 
>directories, then create the library in the current directory.
>
>Thanks!
>
>Kathy
>
>-----Original Message-----
>From: William A. Hoffman [mailto:billlist at nycap.rr.com]
>Sent: Friday, September 23, 2005 12:09 PM
>To: Jonick, Kathy-P57450; cmake at cmake.org
>Subject: Re: [CMake] Add subdir and library in CmakeList.txt
>
>
>>
>>Is it possible to include a SUBDIR list as well as a library in one
>CMakeList.txt file? 
>>
>>I want to be able to build a library in the current directory, as well
>as call the CMakeList.txt file in 2 subdirectories.  My CMakeList.txt 
>file looks like:
>>SUBDIRS(dir1 dir2)
>>
>>SET(SOURCES <file list> )
>>
>>ADD_LIBRARY(libname SHARED ${SOURCES})
>>
>>But when I run cmake, I get messages looking for the files listed in
>the subdirectories, rather than the current directory: 
>>CMake Error: can not find file
>>/home/cmake_demo/current_dir/dir1/file1.c
>>
>>Tried .c .C .c++ .cc .cpp .cxx .m .M .mm .h .h++ .hm .hpp .hxx .in 
>>.txx
>>
>>Is this possible?  If not, how do I build the library in current dir?
>How do I say I also want to build subdirectories?  I tried using the 
>PREORDER flag in the SUBDIRS statement since I want to build those 
>first, that that didn't seem to help at all.
>
>This is certainly possible.   Where is file1.c added?  Could the error
>be in one of the sub dirs?
>
>-Bill
>
>_______________________________________________
>CMake mailing list
>CMake at cmake.org
>http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list