[Insight-users] Windows Cmake Script

Neil Panjwani paniwani at gmail.com
Mon Jun 6 10:40:49 EDT 2011


The -D flag worked perfectly. Thanks. Here's my script (.bat) for future
developers:

@echo off
REM %1: project name

REM check if user entered an argument
if [%1]==[] goto error1
if exist %1 goto error2

REM Make CMake file
mkdir %1\src
echo PROJECT(%1) > %1\src\CMakeLists.txt
echo FIND_PACKAGE(ITK) >> %1\src\CMakeLists.txt
echo IF(ITK_FOUND) >> %1\src\CMakeLists.txt
echo INCLUDE(${ITK_USE_FILE}) >> %1\src\CMakeLists.txt
echo ELSE(ITK_FOUND) >> %1\src\CMakeLists.txt
echo MESSAGE(FATAL_ERROR >> %1\src\CMakeLists.txt
echo "ITK not found. Please set ITK_DIR.") >> %1\src\CMakeLists.txt
echo ENDIF(ITK_FOUND) >> %1\src\CMakeLists.txt
echo. >> %1\src\CMakeLists.txt
echo ADD_EXECUTABLE(%1 %1.cxx )   >> %1\src\CMakeLists.txt
echo. >> %1\src\CMakeLists.txt
echo TARGET_LINK_LIBRARIES(%1 ${ITK_LIBRARIES}) >> %1\src\CMakeLists.txt
echo INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) >> %1\src\CMakeLists.txt
echo INCLUDE_DIRECTORIES(C:/GitProjects/common) >> %1\src\CMakeLists.txt

REM Make soure code
echo #include ^<itkImage.h^> >> %1\src\%1.cxx
echo #include ^<iostream^> >> %1\src\%1.cxx
echo. >> %1\src\%1.cxx
echo int main(int argc, char * argv[]) >> %1\src\%1.cxx
echo { >> %1\src\%1.cxx
echo system("pause"); >> %1\src\%1.cxx
echo return 0; >> %1\src\%1.cxx
echo } >> %1\src\%1.cxx

mkdir %1\build
cd %1\build
cmake -G "Visual Studio 8 2005 Win64" -D
ITK_DIR:PATH=C:/InsightToolkit-3.20.0/build64 ../src
%1.sln
exit

goto end

:error1
echo Error: Please enter project name as argument.
echo.
goto end

:error2
echo Error: Project already exists. Enter a new project name.
echo.

:end


On Mon, Jun 6, 2011 at 10:04 AM, Cory Quammen <cquammen at cs.unc.edu> wrote:

> Neil,
>
> To set a specific ITK_DIR in a project that uses ITK, the command line
> option is
>
> -D ITK_DIR:STRING=/path/to/ITK/flavor/build
>
> If I recall correctly, it should appear before the -G option.
>
> Hope that helps,
>
> Cory
>
> On Mon, Jun 6, 2011 at 9:52 AM, Neil Panjwani <paniwani at gmail.com> wrote:
> > That works great for building ITK, but for specific projects I need to
> set
> > the specific ITK_DIR because I have several flavors of ITK. How do I
> specify
> > that directory as a parameter to cmake via command line?
> >
> > On Sun, Jun 5, 2011 at 7:28 PM, Luis Ibanez <luis.ibanez at kitware.com>
> wrote:
> >>
> >> Hi Neil,
> >>
> >> from the command line,
> >> go to the binary directory
> >> where you want to build ITK
> >>
> >> and type
> >>
> >>   cmake   -G"Visual Studio 9 2008 Win64"
> >>      path_to_itk_source_tree
> >>
> >>
> >> ---
> >>
> >> There are other options, but this is probably
> >> the simplest one.
> >>
> >>
> >>    Luis
> >>
> >>
> >> ------------------------------------------------
> >> On Mon, May 30, 2011 at 11:25 PM, Neil Panjwani <paniwani at gmail.com>
> >> wrote:
> >> > Does someone have a script (batch, python, etc) to run Cmake via the
> >> > command
> >> > line in Windows to build ITK projects?
> >> > The only settings I need to change are source and bin directories,
> >> > ITK_DIR,
> >> > and the compiler (32 vs 64-bit). Thanks.
> >> > _____________________________________
> >> > Powered by www.kitware.com
> >> >
> >> > Visit other Kitware open-source projects at
> >> > http://www.kitware.com/opensource/opensource.html
> >> >
> >> > Kitware offers ITK Training Courses, for more information visit:
> >> > http://www.kitware.com/products/protraining.html
> >> >
> >> > Please keep messages on-topic and check the ITK FAQ at:
> >> > http://www.itk.org/Wiki/ITK_FAQ
> >> >
> >> > Follow this link to subscribe/unsubscribe:
> >> > http://www.itk.org/mailman/listinfo/insight-users
> >> >
> >> >
> >
> >
> > _____________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Kitware offers ITK Training Courses, for more information visit:
> > http://www.kitware.com/products/protraining.html
> >
> > Please keep messages on-topic and check the ITK FAQ at:
> > http://www.itk.org/Wiki/ITK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.itk.org/mailman/listinfo/insight-users
> >
> >
>
>
>
> --
> Cory Quammen
> Computer Integrated Systems for Microscopy and Manipulation (CISMM)
> Department of Computer Science
> University of North Carolina at Chapel Hill
> http://www.cs.unc.edu/~cquammen
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110606/a7d8c470/attachment.htm>


More information about the Insight-users mailing list