[Cmake] Help with first project
Andy Cedilnik
andy.cedilnik at kitware.com
Mon, 23 Feb 2004 09:06:15 -0500
Hi Matt,
Replace:
SET(Engine_source ${Engine_source} Tag.cpp)
with:
SET(Engine_source ${Engine_source} ${Engine_SOURCE_DIR}/Tag/Tag.cpp)
and replace:
SUBDIRS(Tag SOE)
with
INCLUDE(${Engine_SOURCE_DIR}/Tag/CMakeLists.txt)
INCLUDE(${Engine_SOURCE_DIR}/SOE/CMakeLists.txt)
Andy
On Sun, 2004-02-22 at 12:44, Matt Junkemail wrote:
> Hi,
>
> I'm new at using CMake (and I really like what I see!)
> Here is a question I haven't been able to solve.
>
> I have a project that I've been working on for a while
> in Visual C++. I
> would like to work on the same project within Linux
> using gcc and CMake.
>
> I have several files within the project's root
> directory and several sub-directories that contain
> source files as well.
>
> The project is named "Engine" and resides in a
> directory called Engine, which contains Engine.cpp and
> Engine.h files. Within this directory, the two
> sub-directories are called "Tag" and "SOE", both
> containing several matching .h and .cpp files.
>
> I have in the Engine directory a CMakeLists.txt file
> that contains the
> following:
>
> PROJECT(Engine)
>
> SUBDIRS(Tag SOE)
> INCLUDE_DIRECTORIES(Tag SOE)
> SET(Engine_source Engine.cpp)
>
> ADD_EXECUTABLE(Engine ${Engine_source})
>
> The Tag and SOE directories also contain
> CMakeLists.txt files. They add to the Engine_source
> variable:
>
> SET(Engine_source ${Engine_source} Tag.cpp)
>
> and:
>
> SET(Engine_source ${Engine_source} SOE.cpp)
>
> That's the only command in the file.
>
> CMake generates a make file, but uponing making it, I
> receive errors that within Engine.o, I have an
> undefined reference to Tag.
>
> Within the Tag and SOE directories, there are no .o
> files. So these files are not being compiled.
>
> I have also tried using the AUX_SOURCE_DIRECTORY
> command
> within the root CMakeLists.txt file.
>
> So basically I need to compile a "main" file in the
> main directory that uses objects from classes in
> separate source files (.cpp and .h) that reside in
> sub-directories. I don't want to compile and link the
> sub-directory files as libraries.
>
> Can somebody help with the scripts?