[CMake] Merging a project from autoconf and GNUMakefiles

Torri, Stephen CIV NSWCDD, W15 stephen.torri at navy.mil
Tue Nov 16 09:35:23 EST 2010


I am trying to merge a project that was using autoconf and GNUMakefiles. When you use automake you can build static libraries in sub directories and then link them together into one shared library in the end that was install. This is not possible with Visual Studio. In GNU Make for the project I can see that there are GNMakefiles in the subdirectories that build the object files where they are linked together in the top level GNUMakefile.
 
In projects I have done where I have had source files in subdirectories I could include all of them in a variable in the single CMakeLists.txt file in the top directory. This project has 1079 C++ and C files in a variety of subdirectories. The only way I can see to make a single shared library with CMake is to include all the source files into a single variable in the single CMakeLists.txt file like I do in my own projects.  So to do this same technique with this project seems unreasonable to ask these developers to adopt.
 
So I am wondering if I can set a single variable used across a variety of CMakeLists.txt files? So that way in subdirectoryA I can add files to a variable called SOURCES that I append files in from subdirectoryB. Therefore in the top level CMakeLists.txt file I can declare:
 
add_library ( target ${SOURCES} )
target_link_libraries ( target ${DEPENDENCY_LIBRARIES} )
 
In a similar way I can include those headers I want to install in all the subdirectories.
 
Stephen


More information about the CMake mailing list