[Cmake] newbie question - subfolder linking.

Andy Cedilnik andy.cedilnik at kitware.com
Thu Mar 27 11:42:09 EST 2003


Hi Denny,

All CMake variables (except cached ones) are local to subtree.

So, what you really want is this:

#CMake file for the adapter library.
PROJECT(AdapterLibrary)
#group in some logical manner, either functional or alphabetical.
SET(SRCS
)

IF(WIN32)
  INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/win32/CMakeLists.txt)
  FOREACH(src ${WIN_SRCS})
    SET(SRCS ${SRCS} "${CMAKE_CURRENT_SOURCE_DIR}/win32/${src}")
  ENDFOREACH(src)
ENDIF(WIN32)

ADD_LIBRARY(Adapter ${SRCS})



//win32 directory.
#CMake file for the win32 adapter library.

#group in some logical manner, either functional or alphabetical.
SET(WIN_SRCS
	LocalAdapter.cpp
)

				Andy


On Thu, 2003-03-27 at 10:53, denny at teufelkind.net wrote:
> Hi ALl,
> Sorry for the brain dead question, but I can't seem to find the answer to
> it in the examples and I can't seem to figure it out on my own.  I'm
> generating a vc++ 6 project from the following code:
> 
> //top level dir:
> #CMake file for the adapter library.
> 
> PROJECT(AdapterLibrary)
> 
> #group in some logical manner, either functional or alphabetical.
> SET(SRCS
> )
> 
> IF(WIN32)
> 	SUBDIRS(win32)
> ENDIF(WIN32)
> 
> ADD_LIBRARY(Adapter ${SRCS})
> 
> 
> 
> //win32 directory.
> #CMake file for the win32 adapter library.
> 
> #group in some logical manner, either functional or alphabetical.
> SET(SRCS
> 	${SRCS}
> 	LocalAdapter.cpp
> )
> 
> 
> Shouldn't SRCS be appended in win32 and then added to the 'Adapter' lib up
> in the top level directory?  CMake runs from the command line just fine,
> but LocalAdapter.cpp doesn't show up in my vc++ library project.  I am
> making several other libraries just fine with *only* a top level
> directory, this is the first sub dir i've tried.





More information about the CMake mailing list