CMake generates Visual Studio 2008 solution for Win32 and x64

I am using CMake 2.8 under Windows XP and want to generate a Visual Studio 2008 solution file that contains the Release and Debug configurations for Win32 and x64.

Can this be done by setting the CMake configuration variable in the file CMakeLists.txt?

+3
source share
3 answers

CMakeLists does not specify a generator (makefile, Xcode, Visual Studio) for the project. The generator is indicated when the user runs CMake on your source.

+2
source

You must create a solution file under the console using CMake.exe.

CMake -G "Visual Studio 9 2008" (, CMakeLists.txt)// X86.

CMake -G "Visual Studio 9 2008 Win64" (, CMakeLists.txt)// X64.

+2

. script. , script .

.

builder . -64bit -Debug

, , - 64- .

script, cmake.

SET VISUAL_STUDIO_9_HOME =

SET CMAKE_HOME =

@echo off

rem ===== Usage
rem builder c:\workspace\project1 -32bit -Release
rem builder . -64bit -Debug

rem Global configuration variables. Should be update based on your system
SET VISUAL_STUDIO_9_HOME=c:\Program Files\Microsoft Visual Studio 9.0
SET CMAKE_HOME=c:\Documents and Settings\stumk\My Documents\toolkit\cmake

rem First parameter is project folder path
SET PROJECT_DIR=%1

rem Add executables into path
rem Only add them once
if NOT DEFINED SETENV  SET SETENV=0
if %SETENV% EQU 0 SET PATH=%CMAKE_HOME%\bin;%VISUAL_STUDIO_9_HOME%\Common7\Tools;%PATH%
SET SETENV=1

rem Go to project director
cd %PROJECT_DIR%

rem Create build folder, don't mess the source code with visual studio project files
md build

rem Go to build folder
cd build\
   rem Set visual studio environment variables
   call vsvars32.bat 

   rem Second parameter defines 32 bit or 64 bit compilation
   if "%2"=="-32bit" (
       cmake.exe .. -G "Visual Studio 9 2008"
   )
   if "%2"=="-64bit" (
       cmake.exe .. -G "Visual Studio 9 2008 Win64"
   )

   rem Third parameter defines debug or release compilation
   if "%3"=="-Debug" (
           cmake.exe --build . --target ALL_BUILD --config Debug
   )
   if "%3"=="-Release" (
           cmake.exe --build . --target ALL_BUILD --config Release
   )

   rem Go to source code directory and finalize script
   cd ..

@echo on
+2
source

All Articles