[CMake] RE: Problems about generating CMakeLists files from existing VC++ 6 project

Henry Joye henryjoye at yahoo.com
Wed Sep 29 05:59:08 EDT 2004


Thanks a lot for your  reply.

Your emails help me a lot to create my CMakeLists.txt
files. I still have some unclear problems and need
your help. I followed your idea in the last email and
want to create only one CMakeLists.txt file in the
root folder in my project.

1. 
How to add an include folder to the CMakeLists.txt
(not Qt, ITK)? For example, I have the Coin3D include
folder and binary folder “d:\Coin3D\include,
d:\Coin3D\Bin”. I have set an environment variable in
Windows advanced variable settings of “COINDIR” to
“d:\Coin3D”. I donot want to set absolute path in
CMakeLists.txt to Coin3D, but the relative path, so
that I just need to change “COINDIR” in Windows
settings, but not CMakeLists.txt file itself when
changed to another computer. It is like this:
 
I want 
INCLUDE_DIRECTORIES(
${COINDIR}/include
)

but not 
INCLUDE_DIRECTORIES(
D:/Coin3D/include
)
My problem is whether I can use Windows environment
variable “COINDIR” in the “INCLUDE_DIRECTORIES”. If
not , how to define this?

2. 
How to process Qt related files in subfolders which
are needed to warp to .h and .cpp files?
In my case, I have Qt .ui files and derived classes
from these .ui files in some folders, e.g. in
/volEditor, I have files:
(1) ui files and the files created by “uic” command
QColorTablePageBase.ui  --> uic creates files:
QColorTablePageBase.qt.h, QColorTablePageBase.qt.cpp
QSliceViewerPageBase.ui --> uic creates files:
QSliceViewerPageBase.qt.h, QSliceViewerPageBase.qt.cpp

(2)Derived classes from QColorTablePageBase class and 
QSliceViewerPageBase class:
QColorTablePage.qt.h , QColorTablePage.qt.cpp -->
Derived class from QColorTablePageBase,
QSliceViewerPage.qt.h, QSliceViewerPage.qt.cpp
-->Derived class from QSliceViewerPageBase

(3) Other files using these classes:
EditorPage.h, EditorPage.cpp

I have several problems for this folder to create
CMakeLists.txt in root folder:
(1) The use of QT_WRAP_UI:
QT_WRAP_UI: Create QT user interfaces Wrappers.
  QT_WRAP_UI(resultingLibraryName HeadersDestName
             SourcesDestName SourceLists ...)

This CMake command does not give users to specify the
created file names of this WARP. For example, I want
“QColorTablePageBase.ui”  to create files:
QColorTablePageBase.qt.h, QColorTablePageBase.qt.cpp,
because I use “QColorTablePageBase.qt.h” in my derived
classes. Is it possible to do like this?
Another question for this QT_WARP_UI command is
“resultingLibraryName”, I donot create any libraries
in my project. What should I put for this variable?
May I put “MyProjectName” for this variable?

(2)The use of QT_WRAP_CPP:
QT_WRAP_CPP: Create QT Wrappers.
  QT_WRAP_CPP(resultingLibraryName DestName
              SourceLists ...)
The question for this command is same as QT_WRAP_UI:
is it possible for me to specif the created moc file
names? I donot create any libraries in my project.
What should I put for this variable? May I put
“MyProjectName” for this variable?

3.
Questions about specifying source files in
CMakeLists.txt in the root folder:

My root folder is “RootDir”, and has several
subfolders: main basics volEditor volFunc util. I use
followsing line in CMakeLists.txt in root folder:

INCLUDE_DIRECTORIES(main basics volEditor volFunc
util)

When I specify source files from subfolders in
CMakeLists.txt in rootfolder, do I need to include the
complete path or just type the file name? It is like
this:

SET(volEditor_SRC
${MyProject_SOURCE_DIR}/volEditor/mycfile1.cpp
${MyProject_SOURCE_DIR}/volEditor/mycfile2.cpp)

Or

SET(volEditor_SRC myfile1.cpp myfile2.cpp)

Which one is correct?

This is a little long email. Thank you very much to
read it and reply it for me.

Best regards,

Joye

--- "Dekeyser, Kris" <Kris.Dekeyser at lms.be> wrote:

> No it's not the same, but since you group source
> code in different folders
> you already implictly indicate that some form of
> 'subsystems' exist. Why not
> create static libraries from each folder (except
> from your main executable).
> The concept would work if each folder's files are
> indeed strongly related
> and dependencies between the folders can be listed
> in a hierachical scheme
> (no recursive dependencies!).
> 
> I've read your other mail to the mailing list in the
> mean time. Looks like
> your setup is pretty simple. You could opt for a
> single CMakeLists.txt in
> your RootDir:
> 
> --- CMakeLists.txt ---
> PROJECT(MyProject)
> 
> INCLUDE_DIRECTORIES(main basics volEditor volFunc
> util)
> INCLUDE_DIRECTORIES(<all paths to your 3rd party
> library headers>)
> 
> ADD_DEFINITIONS(<whatever you need ...>)
> 
> ADD_EXECUTABLE(MyProgram <list of all source files>)
> 
> TARGET_LINK_LIBRARIES(MyProgram <list of full paths
> to all 3rd party
> libraries>)
> -----------------------
> 
> Basically, I think that should do the trick. Just
> create a build dir and run
> cmakesetup enter the RootDir and BuildDir and hit
> "configure" and "OK". You
> should see a VS6 workspace in your build dir.
> 
> Of course a lot can be fine tuned and added.
> 



		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com


More information about the CMake mailing list