[CMake] One library with multiple sub-directories

Bradley Lowekamp blowekamp at mail.nih.gov
Tue Nov 2 14:23:13 EST 2004


Hello,
	I am trying to generate a single library from multiple source 
sub-directories where in the subdirectories files may have the same 
name. Currently I have been making sure that each file had different 
names, but I can't be doing this any more. The way I have it currently 
set up is basically as follows:

directory structure:
	/-
	-/foo
		default.cpp
	-/bar
		default.cpp

top level cmake:
	SUBDIRS( foo)
	SUBDIRS(bar)
	SET (MY_LIB_SRC ${FOO_SRC} ${BAR_SRC})
	ADD_LIBRARIES(my ${MY_LIB_SRC}

foo (simular for bar) directory cmake:
	SET(LOCAL_FOO_SRC default.cpp )

	SET(FOO_SRC "" CACHE INTERNAL "source files for foo")
	FOREACH(file ${LOCAL_FOO_SRC})
     		SET(FOO_SRC "${FOO_SRC};${CMAKE_CURRENT_SOURCE_DIR}/${file}" 
CACHE INTERNAL "source files for foo")
	ENDFOREACH(file)

So by doing this all the *.o files get created in the "top level" 
directory. This would be very problematic for multiple files with the 
same name. A while a go I tried getting the *.o files to be places in 
the foo and bar directories respectfully, but was unable to get the 
linker to link them correctly. I hope that I have explained what I need 
to do, any questions just ask. I would very much appreciate a prompt 
response.

Thanks,
========================================================
Bradley Lowekamp
Management Systems Designers Contractor for
Office of High Performance Computing and Communications
National Library of Medicine
'blowekamp at mail.nih.gov



More information about the CMake mailing list