If I am understanding you correct, you would like a CMake file in
each of the subdirectories that lists the source files in that
subdirectory that should be included in the build? Try the following:
In your top level CMakeLists.txt file----------
SET (PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET (PROJECT_SOURCE_FILES
${PROJECT_SOURCE_DIR }/TopLevel.cpp
)
INCLUDE ( ${PROJECT_SOURCE_DIR }/SubDir1/Sources.cmake)
--- In a File called "Sources.cmake" in a subdirectory called
SubDir1--------
SET (PROJECT_SOURCE_FILES ${PROJECT_SOURCE_FILES}
SubDir1_Source1.cpp
SubDir1_Source1.cpp
)
Depending on the style of your "#includes" you may need something like:
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR }/SubDir1 )
ADD_EXECUTABLE (MyExe ${PROJECT_SOURCE_FILES} )
All this is untested but I do something similar to pull in sources
from a main project into a secondary project because creating a
convenience library was not working.
Those projects can be found here:
http://titanium.imts.us/viewvc/Task_4/PVPhaseField/ (Secondary
Project - Look in the "Resources/UseMXADataModel.cmake", which is
included from the top level CMakeLists.txt file [line 39] )
http://titanium.imts.us/viewvc/Task_7/MXADataModel/ (Main Project -
Source files are pulled from here)
--
Mike Jackson Senior Research Engineer
Innovative Management & Technology Services
On Oct 8, 2007, at 9:42 AM, Tim wrote:
My project is a shared library. I just moved the
project over to CMake from autotools. The sources for
the target is divided up into several
subdirectories(which also contain sources in
subdirectories). I need to be able to build all the
sources recursively and have them all linked into the
same target. I can't seem to find a single clue
anywhere of how to accomplish it. Even looking at
existing projects and examples the only instances
where I see subdirectories being used with CMake is
when they are different targets.
So far the only way I can get the project to build is
to put a list of all source files in the
CMakeLists.txt of the top-level source directory which
to me seems like an ugly hack. Not to mention if I try
to use CMake to generate an Xcode project file it puts
all the sources into one flat folder which looks very,
especially since some files have the same name but are
in different directories.
I am also looking for a way to execute a script in my
project directory with an argument(The argument being
the install root of the project).
___________________________________________________________
All new Yahoo! Mail "The new Interface is stunning in its
simplicity and ease of use." - PC Magazine
http://uk.docs.yahoo.com/nowyoucan.html
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake