[Insight-users] Re: Minimum framework for an itk project
Luis Ibanez
luis.ibanez@kitware.com
Sat, 08 Mar 2003 09:49:53 -0500
Hi Zein,
Recycling VisualStudio workspaces from previous
projects is certainly not a good practice.
Your CMakeLists.txt looks just fine.
It is totally normal for CMake to generate a
certain extra number of files and directories.
This may look like a lot of overhead when it is
seen in the frame of such a simple project example.
But when you start doing real projects it is clearer
how this additional overhead helps to maintain things
in order.
1) BUILD_ALL : in real projects you may not be
just creating a single executable. It is likely
to endup doing two or three libraries and several
executables. Visual Studio creates a .dsp per
library and a .dsp per executable. If you want
to rebuild everything, you have to go project
by project rebuilding...
The BUILD_ALL project is provided by CMake for your
convenience. It is the target for the sum of all
the other projects in your workspace.
This projects allow you to select rebuild at the
top level and then go to have lunch or read a paper
with the confidence that VC++ will rebuild all the
projects.
2) CMAke creates several files and sub-directories in
your binary directory. Most of them are related with
dependencies and local configuration options.
You don't have to deal with them at all. They are
there to ensure that things are rebuild in the right
order. Again, the need of such a complex structure
makes more sense in real size projects.
3) What you have to open with VisualStudio is the
*.dsw file. Never open the .dsp files. The .dsw
is the workspace file that groups all the .dsp
files together. It contains global definitions
to be shared among the .dsp files.
When you open the .dsw file, you will find all
the projects inside.
So, to summarize:
Once you run CMake succesfully, you go directly to the
.dsw file and open it with VisualStudio. Do not change
any thing in the project from inside VC++. If you do,
such changes will be lost the next time you run CMake
in your project.
If you need to add more source files to your project,
simply modify your CMakeLists.txt file, adding more .cxx
files after main.cxx, like
ADD_EXECUTABLE(ColorViewer main.cxx s1.cxx s2.cxx s3.cxx)
Please let us know if you have further questions.
Thanks
Luis
------------------------------------------------------
salah wrote:
> Hi Luis,
>
> I had never succeeded to build my own ITK project from scratch. Yes, it is the truth!! I tried several times, got unexpected results and gave up.
> I always take an example, remove its source files, add my files by "Add files to Project" in VC++, and then do some renamings!!!!!!
>
> Please help me doing that myself. What is the simplest way??
>
> I copied the cmakelist.txt file from the sampleproject directory to my directory, which has only the file main.cxx, updated it like this
>
> PROJECT(ColorViewer)
>
> FIND_PACKAGE(ITK)
> IF(ITK_FOUND)
> INCLUDE(${ITK_USE_FILE})
> ENDIF(ITK_FOUND)
>
> ADD_EXECUTABLE(ColorViewer main.cxx)
>
> TARGET_LINK_LIBRARIES(ColorViewer ITKCommon)
>
> I ran cmake, pointing both the source and built directories to be my directory.
> after Configure then OK, my directory ended up with these many files (please see picture below).
>
> <<filelist.jpg>>
> I may guess what the file ColorViewer.dsp could be. BUT, but I could not understand what the other files are! what have I to do with them, ALL_BUILD...... CMake....... ??????
>
>
>
>>>>>>>Shortly speaking>>>>>
>>>>>>
> I need only a minimum framwork of a project that uses itk, fltk, and vtk. I can add my source files later using VC++ "Add Source file to Project".
> Can I build such a framework without CMake?? If I had to use CMake, what is the right contents of the directory to start with, the contents of the CMakeList.txt file, and the right configurations to be done in CMake so that I end up with a (preferebly clean) workspace that recognises itk, fltk, and vtk????
>
>
>>>>>>>>>>>> I am so sorry for this long email and hope you could have the time to help me.
>>>>>>>>>>>
>
> Many thanks for any help or guide.
>
> Zein
>
> ->8<------------->8<------------->8<------------->8<------------->8<------------->8<-
> Zein I. Salah
> University of Tübingen, WSI-GRIS, Sand 14, 72076 Tübingen
> Email: salah@gris.uni-tuebingen.de
> Tel.: (07071) 29 75465 (GRIS), Fax: (07071) 29 54 66
>
>
>
> ------------------------------------------------------------------------
>