[CMake] How to use Cmake for WIN32 and WINCE project both?

Brad King brad.king at kitware.com
Fri Nov 18 10:47:12 EST 2005


chenjin263 at 263.net wrote:
> Is there any chance to get a set of CMakeLists.txt,
> which can generator Nmake/Make makefiles for targets on WIN32 and WINCE
> either. That means I can do this:
> 
>>cmake -DWIN32 -G "NMake Makefiles" ../MySrc
> 	for makefiles building exe running on WIN32, and
>>cmake -DWINCE -G "NMake Makefiles" ../MySrc
> 	for makefiles building exe running on PDA(WINCE).

In the CMakeLists.txt file add an OPTION command that will be available 
on windows:

IF(WIN32)
   OPTION(MYPROJ_BUILD_FOR_WINCE "Enable to build WinCE support." OFF)
ENDIF(WIN32)
# ... code common to all builds ...
IF(MYPROJ_BUILD_FOR_WINCE)
   # ... code specific to WinCE
ELSE(MYPROJ_BUILD_FOR_WINCE)
   # ... code for non-WinCE builds
ENDIF(MYPROJ_BUILD_FOR_WINCE)

Then the option can be set in the CMakeSetup configuration dialog or on 
the cmake command line:

cmake -DMYPROJ_BUILD_FOR_WINCE:BOOL=ON -G "NMake Makefiles" ../MySrc

> It is prefered that discremination can be posponted when nmake runs. I
> means: I can use cmds "nmake TARGET=WIN32  or nmake TARGET=WINCE" to do
> the same job.

CMake is not designed to generate Makefiles with make-time options like 
this.

-Brad


More information about the CMake mailing list