MantisBT - CMake
View Issue Details
0012871CMakeCMakepublic2012-01-10 09:532012-07-09 06:52
Sam Morris 
Brad King 
normalmajoralways
closedduplicate 
CMake 2.8.7 
 
0012871: add_definitions adds flags to RC_DEFINES
The attached project tries to create an executable from a C++ file and a Windows resource script:

CMakeLists.txt contains:

    project(restest)
    add_definitions(-msse)
    add_executable(a a.cpp a_res.rc)

The build fails because -msse ends up in RC_DEFINES, which is passed to windres to compile the resource script.
$ make VERBOSE=1
/usr/bin/cmake -H/home/sam/src/cmake/rc -B/home/sam/src/cmake/rc/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/sam/src/cmake/rc/build/CMakeFiles /home/sam/src/cmake/rc/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/sam/src/cmake/rc/build'
make -f CMakeFiles/a.dir/build.make CMakeFiles/a.dir/depend
make[2]: Entering directory `/home/sam/src/cmake/rc/build'
cd /home/sam/src/cmake/rc/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/sam/src/cmake/rc /home/sam/src/cmake/rc /home/sam/src/cmake/rc/build /home/sam/src/cmake/rc/build /home/sam/src/cmake/rc/build/CMakeFiles/a.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/sam/src/cmake/rc/build'
make -f CMakeFiles/a.dir/build.make CMakeFiles/a.dir/build
make[2]: Entering directory `/home/sam/src/cmake/rc/build'
/usr/bin/cmake -E cmake_progress_report /home/sam/src/cmake/rc/build/CMakeFiles 2
[ 50%] Building RC object CMakeFiles/a.dir/a_res.res
/usr/bin/i686-w64-mingw32-windres -O coff -msse /home/sam/src/cmake/rc/a_res.rc CMakeFiles/a.dir/a_res.res
/usr/bin/i686-w64-mingw32-windres: invalid option -- 'm'
Usage: /usr/bin/i686-w64-mingw32-windres [option(s)] [input-file] [output-file]
 The options are:
  -i --input=<file> Name input file
  -o --output=<file> Name output file
  -J --input-format=<format> Specify input format
  -O --output-format=<format> Specify output format
  -F --target=<target> Specify COFF target
     --preprocessor=<program> Program to use to preprocess rc file
     --preprocessor-arg=<arg> Additional preprocessor argument
  -I --include-dir=<dir> Include directory when preprocessing rc file
  -D --define <sym>[=<val>] Define SYM when preprocessing rc file
  -U --undefine <sym> Undefine SYM when preprocessing rc file
  -v --verbose Verbose - tells you what it's doing
  -c --codepage=<codepage> Specify default codepage
  -l --language=<val> Set language when reading rc file
     --use-temp-file Use a temporary file instead of popen to read
                               the preprocessor output
     --no-use-temp-file Use popen (default)
  -r Ignored for compatibility with rc
  @<file> Read options from <file>
  -h --help Print this help message
  -V --version Print version information
FORMAT is one of rc, res, or coff, and is deduced from the file name
extension if not specified. A single file name is an input file.
No input-file is stdin, default rc. No output-file is stdout, default rc.
/usr/bin/i686-w64-mingw32-windres: supported targets: pe-i386 pei-i386 elf32-i386 elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
make[2]: *** [CMakeFiles/a.dir/a_res.res] Error 1
make[2]: Leaving directory `/home/sam/src/cmake/rc/build'
make[1]: *** [CMakeFiles/a.dir/all] Error 2
make[1]: Leaving directory `/home/sam/src/cmake/rc/build'
make: *** [all] Error 2
No tags attached.
duplicate of 0012444closed Bill Hoffman Starting with CMake 2.8.4 it passes invalid msse flag when compiling with MinGW 
gz rc.tar.gz (139,331) 2012-01-10 09:53
https://public.kitware.com/Bug/file/4182/rc.tar.gz
Issue History
2012-01-10 09:53Sam MorrisNew Issue
2012-01-10 09:53Sam MorrisFile Added: rc.tar.gz
2012-01-10 10:10Michael WildNote Added: 0028234
2012-01-10 10:14Sam MorrisNote Added: 0028235
2012-01-10 13:54Brad KingRelationship addedduplicate of 0012444
2012-01-10 13:54Brad KingStatusnew => resolved
2012-01-10 13:54Brad KingResolutionopen => duplicate
2012-01-10 13:54Brad KingAssigned To => Brad King
2012-07-09 06:52David ColeNote Added: 0029949
2012-07-09 06:52David ColeStatusresolved => closed

Notes
(0028234)
Michael Wild   
2012-01-10 10:10   
add_definitions() should only be used to add preprocessor defines (-D or /D flag), not compiler flags. For this, use the variables CMAKE_<lang>_FLAGS and CMAKE_<lang>_FLAGS_<config> or the COMPILE_FLAGS and COMPILE_FLAGS_<config> properties.

IMHO if you encounter problems it would be preferable if you first contacted the mailing list to confirm the bug before filing a report. This would help keeping the user errors out of the bug tracker...
(0028235)
Sam Morris   
2012-01-10 10:14   
Thanks for that. I will pass that advice on to the maintainers of the project I'm trying to build. FYI, this is probably a duplicate of http://public.kitware.com/Bug/view.php?id=12444. [^]
(0029949)
David Cole   
2012-07-09 06:52   
Closing resolved issues that have not been updated in more than 4 months.