[CMake] IF(... MATCHES WIN32) weird behavior
Filipe Sousa
filipe at ipb.pt
Tue May 31 13:58:18 EDT 2005
On Tuesday 31 May 2005 18:33, Brad King wrote:
> Filipe Sousa wrote:
> > SET(arg "WIN32")
> > IF("${arg}" MATCHES "WIN32")
> > MESSAGE(STATUS ":)")
> > ELSE("${arg}" MATCHES "WIN32")
> > MESSAGE(STATUS ":(")
> > ENDIF("${arg}" MATCHES "WIN32")
> >
> > C:\_builds\testes>cmake -G"NMake Makefiles" c:\_projects\testes
> > -- :(
> > -- Configuring done
> > -- Generating done
> > -- Build files have been written to: C:/_builds/testes
>
> This is due to an ambiguity in the interface to the IF command left from
> early CMake versions. Read the documentation for the IF command
> carefully, and keep in mind that "WIN32" is defined as a variable on
> Windows. Basically the left "WIN32" is getting replaced by "1" before
> comparison. On non-windows systems or when you use WIN3 the variable is
> not defined.
>
> -Brad
Of course, I completely forgot that WIN32 is defined on windows :)
I was trying to create a macro for Qt when the problem arose:
MACRO(QT_ADD_EXECUTABLE target)
SET(sources)
SET(exetype)
FOREACH(arg ${ARGN})
IF("${arg}" MATCHES "WIN32")
SET(exetype WIN32)
ELSE("${arg}" MATCHES "WIN32")
SET(sources ${sources} ${arg})
ENDIF("${arg}" MATCHES "WIN32")
ENDFOREACH(arg)
QT_GET_MOCABLE_FILES(moc_list ${sources})
IF(moc_list)
QT_MOC_FILES(generated_files ${moc_list})
SET(sources ${generated_files} ${sources})
ENDIF(moc_list)
# Add compiler flags needed by Qt
STRING(REGEX REPLACE ";" " " defs "${qt_definitions}")
SET_SOURCE_FILES_PROPERTIES(${sources} PROPERTIES COMPILE_FLAGS
"-I${QT_INCLUDE_DIR} ${defs}")
# Create the executable
ADD_EXECUTABLE(${target} ${exetype} ${sources})
ENDMACRO(QT_ADD_EXECUTABLE)
Is there another way to split "WIN32" from ARGN?
--
Filipe Sousa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/cmake/attachments/20050531/5be69939/attachment.pgp
More information about the CMake
mailing list