On 08/07/2011 09:33 PM, Hans Johnson wrote: > Hello, > > I'm trying to use the cmake feature for testing if compiler flags are valid, > but I am running into trouble with these two complier flags. I can not > figure out how to proper escape the "+" or the "%" that I believe are > causing the failures. > > cat CMakeLists.txt > ============================================ > project(TestCompilerFlagTest) > > include(CheckCCompilerFlag) > include(CheckCXXCompilerFlag) > > set(flag -Wno-c++0x-static-nonintegral-init) > check_cxx_compiler_flag(${flag} CXX_HAS_WARNING${flag}) > set(flag -features=no%anachronisms ) > check_cxx_compiler_flag(${flag} CXX_HAS_WARNING${flag}) > ============================================ > > I'd appreciate any help in resolving this. > > A more robust version of /opt/cmake-2.8.4-Darwin-universal/CMake > 2.8-4.app/Contents/share/cmake-2.8/Modules/CheckCXXCompilerFlag.cmake > for use in ITK (and Slicer/SimpleITK/BRAINS) would also be acceptable. > > Thanks in advance. > > Hans
The result variable's name, i.e. CHECK_CXX_COMPILER_FLAG()'s second argument, undergoes a regex evaluation in CHECK_CXX_SOURCE_COMPILES(), so it mustn't contain regex-sensitive characters like "+". The "=" and "%" in the other test seem to pass CHECK_CXX_COMPILER_FLAG(), but bail out on another occasion. In general, IMO, using any special characters except for "_" in identifiers means asking for trouble. Thus, restrict yourself to "[A-Za-z][A-Za-z0-9_]*" - or "[A-Za-z_][A-Za-z0-9_]*" with regard to internal variables - and your issue will probably go away. Regards, Michael _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake