cross compiling - CMake: Setting correct compiler options for one platform only -


i use cmake generate build files (makefile or project files) across windows, osx , linux, c , c++ compilers native platforms. on windows gnerate vs 2010 project, , in release configuration following error occures:

command line error d8016: '/zi' , '/ob2' command-line options incompatible

clearly, cmake generates optimization , debug information options not compatible. default cmake configuration, not setup special flags.

i fix altering /zi /z7 in project options in visual studio, makes annoying setup continous integration system - need add script modify project file.

can force cmake gnerate /z7 (c7 compatible debug info) instead of /zi?

in addition, how can make generate in release configuration , not in debug?

i don't think cmake applies /zi release flags default - it's being applied elsewhere in cmakelists.txt or 1 of cmake files included it.

nonetheless, can switch flag doing like:

if(msvc)   string(regex replace "/z[ii7]" ""          cmake_cxx_flags_release          "${cmake_cxx_flags_release}")   set(cmake_cxx_flags_release "${cmake_cxx_flags_release} /z7") endif() 

the first line strips /zi, /zi , /z7 flags if exist in release flags. note use of " round "${cmake_cxx_flags_release}". it's important cmake variable remains single string. if quotes removed, variable becomes semi-colon separated list (i.e. each space replaced semi-colon) , unsuitable passing compiler.

you can give conflicting flags here if want. if removed string(regex replace ...) command , left set command, ${cmake_cxx_flags_release} contain ... /zi ... /z7 ...", long /z7 last debug info flag, "wins" , 1 gets applied.

however, tiny amount of effort clean variable first, feel it's worth stripping conflicting flags.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -