[CMake] Problem with Static Pattern Rules
Carminati Federico
Federico.Carminati at cern.ch
Wed Jul 9 04:23:15 EDT 2008
Dear Alex,
Thanks a lot for the answer. Now I hit another problem. I have to
add a command of the kind
Foreach(_checkFile ${CXXSRCS})
String(REGEX REPLACE "([^;]*).cxx" "${CMAKE_CURRENT_BINARY_DIR}/
check/\\1.viol" _violFile "${_checkFile}")
Set(_command "${CMAKE_CXX_COMPILER} -E ${CMAKE_CXX_FLAGS} -I. $*
> tmp.i")
Add_Custom_Command(
OUTPUT ${_violFile}
COMMAND ${CMAKE_CXX_COMPILER} ARGS -E ${CMAKE_CXX_FLAGS} -I. $
{_checkFile} > tmp.i
DEPENDS ${_checkFile}
VERBATIM)
Set(VIOLS ${VIOLS} ${_violFile})
EndForeach(_checkFile ${CXXSRCS})
The trouble is that ${CMAKE_CXX_FLAGS} expands to " -m64 .... " with
double quotes and therefore the command fails because is expanded to
g++ -E " -m64 .... "
I do not seem to be able to get around this and help would be
appreciated. best,
Federico Carminati
CERN-PH
1211 Geneva 23
Switzerland
Tel: +41 22 76 74959
Fax: +41 22 76 79480
Mobile: +41 76 487 4843
On 8 Jul 2008, at 21:53, Alexander Neundorf wrote:
> On Tuesday 08 July 2008, Carminati Federico wrote:
>> Hello,
>> it is possible to add a custom command to cmake with a static
>> pattern rule? My problem is the following, I have a coding convention
>> checker that for each c++ source file creates a "violation" file. The
>> rule I had in my makefile was
>>
>> $(SRCS:.cxx=.viol) : %.viol : %.cxx
>> bla bla
>>
>> How can I do this in cmake? The only way that seems to work is to
>> create a single rule for each file with foreach.
>
> Yes, that's how to do it.
> You can wrap this in a macro, so you get something like:
>
> add_violation_rules(... files....)
>
> Alex
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list