help with cmake macro
Erik van Pienbroek
erik at vanpienbroek.nl
Sat Jun 25 15:47:22 UTC 2011
Farkas Levente schreef op do 23-06-2011 om 00:47 [+0200]:
> hi,
> i try to package opencv for mingw which use cmake. when i try to build
> it i need to add a few params, but i can't do it, because:
> %mingw_cmake "-DENABLE_OPENMP=1"
> but during the build it runs:
> /usr/bin/cmake -DCMAKE_VERBOSE_MAKEFILE=ON
> -DCMAKE_INSTALL_PREFIX:PATH=/usr/i686-w64-mingw32/sys-root/mingw
> -DCMAKE_INSTALL_LIBDIR:PATH=/usr/i686-w64-mingw32/sys-root/mingw/lib
> -DINCLUDE_INSTALL_DIR:PATH=/usr/i686-w64-mingw32/sys-root/mingw/include
> -DLIB_INSTALL_DIR:PATH=/usr/i686-w64-mingw32/sys-root/mingw/lib
> -DSYSCONF_INSTALL_DIR:PATH=/usr/i686-w64-mingw32/sys-root/mingw/etc
> -DSHARE_INSTALL_PREFIX:PATH=/usr/i686-w64-mingw32/sys-root/mingw/share
> -DCMAKE_SKIP_RPATH:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=ON
> -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw32.cmake ..
> -DENABLE_OPENMP=1
>
> as you can see the path is NOT the last param which cause problems:-)
> actually i don't understand it since mingw32_cmake defined as:
>
> %mingw32_cmake() %{mingw32_env} ; \
> __mingw32_topdir=.; if ! test -f CMakeLists.txt; then
> __mingw32_topdir=..; fi; \\\
> %__cmake \\\
> -DCMAKE_VERBOSE_MAKEFILE=ON \\\
> -DCMAKE_INSTALL_PREFIX:PATH=%{mingw32_prefix} \\\
> -DCMAKE_INSTALL_LIBDIR:PATH=%{mingw32_libdir} \\\
> -DINCLUDE_INSTALL_DIR:PATH=%{mingw32_includedir} \\\
> -DLIB_INSTALL_DIR:PATH=%{mingw32_libdir} \\\
> -DSYSCONF_INSTALL_DIR:PATH=%{mingw32_sysconfdir} \\\
> -DSHARE_INSTALL_PREFIX:PATH=%{mingw32_datadir} \\\
> %{?_cmake_skip_rpath} \\\
> -DBUILD_SHARED_LIBS:BOOL=ON \\\
> -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw32.cmake \\\
> $* $__mingw32_topdir
>
> where the __mingw32_topdir is the last param so when it's called why not
> the last param?
>
> any help would be useful.
> thanks.
>
The $* mentioned in the mingw32_cmake macro is a typo. I've just fixed
that in the repo. However, this doesn't solve the real problem.
The issue is that the list of arguments given to the mingw_cmake macro
need to be passed on to the mingw32_cmake and mingw64_cmake macros.
Appararently RPM doesn't like this kind of argument pass-through as can
be seen in this simple example:
$ rpm --eval '
%define macro1() start - %* - end
%define macro2() %{macro1}
%macro2 test
'
Given the mingw-w64 context, you could interpret macro1 as mingw32_cmake
and macro2 as mingw_cmake (it's basically a simplified version of what
happens inside these macros).
This example returns this result:
start - - end
(while you would expect 'start - test - end')
I also would be interested in having a method to get the expected
behaviour.
It can be worked-around using something like this:
$ rpm --eval '
%define macro1 start - %* - end
%define macro2() %{macro1}
%macro2 test
'
This returns 'start - test - end', but has the side-effect that it
breaks calling %macro1 as can be seen in the next example:
$ rpm --eval '
%define macro1 start - %* - end
%define macro2() %{macro1}
%macro1 test
'
which returns:
start - %* - end test
Perhaps anybody on this mailing list knows how to properly implemented
such RPM macros ?
Kind regards,
Erik van Pienbroek
More information about the mingw
mailing list