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

Dekeyser, Kris Kris.Dekeyser at lms.be
Wed Sep 29 08:07:53 EDT 2004


Joye,

1. Grabbing an environment variable is pretty simple: $ENV{<var>). So you
should replace "${COINDIR}/include" with "$ENV{COINDIR}/include", etc. One
of those things you'll find in the manual ;-)

2. (1) I'm not a QT user myself and do not know how the QT_WRAP_UI command
works, but it looks like you cannot specify the output files. But the
solution should not be difficult. Either you add a custom command that
copies the output files of QT_WRAP_UI to the proper file names (timing is
critical here) or (even easier) you create the file names you want by hand
and just put a #include "qt_wrap_ui_generated_file" in it. The generation of
the personalised files could even be done automatically with a
CONFIGURE_FILE command of FILE(WRITE ...) [find all your .ui files, strip
the extension and loop over the files. for each iteration generate the
proper files based on the .ui base name]. If you let CMake generate the
files, put them in your build dir - not the source dir - and make sure you
add an INCLUDE_DIRECTORIES for
${MyProject_BINARY_DIR}/.../generated_from_qt_ui.

(2) I don't know. You could try your project executable target instead of
the library and if that does not work, just create a static lib containing
the QT_UI files and link that to your executable. The final result will be
the same and grouping related source code in a library does make sense.

3. The full path should work in any case. If you do not want to specify
that, you'll need to specify the relative path starting from the directory
where your CMakeLists.txt file lives. I don't think only the file names will
work. INCLUDE_DIRECTORIES makes only the compiler look in certain
directories (-I option), but will not make CMake or the IDE look for the
file in those directories.

- Kris

> -----Original Message-----
> From: Henry Joye [mailto:henryjoye at yahoo.com]
> Sent: Wednesday, September 29, 2004 11:59
> To: Dekeyser, Kris
> Cc: cmake at www.cmake.org
> Subject: RE: Problems about generating CMakeLists files from existing
> VC++ 6 project
> 
> 
> 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
+-+-+- Email Confidentiality Footer +-+-+- 
Privileged/Confidential Information may be contained in this message. If you
are not the addressee indicated in this message (or responsible for delivery
of the message to such person), you may not print, retain, copy nor
disseminate this message or any part of it to anyone and you should notify
the sender by reply email and destroy this message. Neglecting this clause
could be a breach of confidence. Please advise immediately if you or your
employer does not consent to Internet email for messages of this kind.
Opinions, conclusions and other information in this message that are not
related to the official business of my firm shall be understood as neither
given nor endorsed by it.



More information about the CMake mailing list