[CMake] Re: [cmake 2.5 CVS] CMAKE_${LANG}_FLAGS is initialized with space
I've managed to debug and correct this 'bug'. The bug report is at: http://www.cmake.org/Bug/view.php?id=6167 I really think that compiler flags should be treated like a list of flags instead of a string because this way, IMHO, it's easier to deal with space in flag parameters etc, to add a flag to the compiler (using LIST(APPEND...) instead of SET(FLAG ${FLAG} -other_flag), which is ugly and to remove a flag using LIST(REMOVE_ITEM...). Regards, rod ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Re: [cmake 2.5 CVS] CMAKE_${LANG}_FLAGS is initialized with space
Rodolfo Lima wrote: David Cole escreveu: What about: MESSAGE(X${CMAKE_CXX_FLAGS}X) Same thing. There is nothing in CMAKE_CXX_FLAGS -- it's just the behavior of MESSAGE when you pass it a list instead of a single string... I think there is... another proof: if(${CMAKE_CXX_FLAGS} STREQUAL ) MESSAGE(equal!) else(${CMAKE_CXX_FLAGS} STREQUAL ) MESSAGE(not equal!) endif(${CMAKE_CXX_FLAGS} STREQUAL ) What is in your CMakeCache.txt file? Also, does this happen with a very simple one line cmakelist.txt file? add_library(foo.cxx) (of course you will have to create an empty foo.cxx) -Bill ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
[CMake] Re: [cmake 2.5 CVS] CMAKE_${LANG}_FLAGS is initialized with space
Bill Hoffman escreveu: What is in your CMakeCache.txt file? Also, does this happen with a very simple one line cmakelist.txt file? add_library(foo.cxx) (of course you will have to create an empty foo.cxx) I always test with a clean CMakeCache.txt (i.e., without it), and don't even add a library (or executable). Just a simple one-liner, like: message(X ${CMAKE_CPP_FLAGS} X) The CMakeCache.txt created contains //Flags used by the compiler during all build types. CMAKE_CXX_FLAGS:STRING=' ' and //Flags for C compiler. CMAKE_C_FLAGS:STRING=' ' The same happens with cmake-2.4.7 Regards, rod ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
[CMake] Re: [cmake 2.5 CVS] CMAKE_${LANG}_FLAGS is initialized with space
Bill Hoffman escreveu: Can you give an example that shows the unwanted semicolons? For sure. Here's the setup: test.c: int main() {} CMakeLists.txt: list(APPEND CMAKE_C_FLAGS -Wall) add_executable(test test.c) when we run make, we have: gcc: no input files /bin/sh: -Wall: not found make[2]: ** [CMakeFiles/test.dir/test.o] Erro 127 make[1]: ** [CMakeFiles/test.dir/all] Erro 2 make: ** [all] Erro 2 If we do 'make VERBOSE=1' (thanks on this one...): /usr/bin/cmake -H/home/rodolfo/src/tst -B/home/rodolfo/src/tst --check-build-system CMakeFiles/Makefile.cmake 0 /usr/bin/cmake -E cmake_progress_start /home/rodolfo/src/tst/CMakeFiles 1 make -f CMakeFiles/Makefile2 all make[1]: Entrando no diretório `/home/rodolfo/src/tst' make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/depend make[2]: Entrando no diretório `/home/rodolfo/src/tst' make[2]: Nada a ser feito para `CMakeFiles/test.dir/depend'. make[2]: Saindo do diretório `/home/rodolfo/src/tst' make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build make[2]: Entrando no diretório `/home/rodolfo/src/tst' /usr/bin/cmake -E cmake_progress_report /home/rodolfo/src/tst/CMakeFiles 1 [100%] Building C object CMakeFiles/test.dir/test.o /usr/local/bin/gcc ;-Wall -o CMakeFiles/test.dir/test.o -c /home/rodolfo/src/tst/test.c gcc: no input files /bin/sh: -Wall: not found make[2]: ** [CMakeFiles/test.dir/test.o] Erro 127 make[2]: Saindo do diretório `/home/rodolfo/src/tst' make[1]: ** [CMakeFiles/test.dir/all] Erro 2 make[1]: Saindo do diretório `/home/rodolfo/src/tst' make: ** [all] Erro 2 See... the compiler arguments gets a ';-Wall', which confuses the shell interpreter. A way to circumvent this would be deleting all leading space from CMAKE_C_FLAGS before calling add_executable, but I smell a bug somewhere. Regards, rod ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Re: [cmake 2.5 CVS] CMAKE_${LANG}_FLAGS is initialized with space
Rodolfo Schulz de Lima wrote: Bill Hoffman escreveu: Can you give an example that shows the unwanted semicolons? For sure. Here's the setup: test.c: int main() {} CMakeLists.txt: list(APPEND CMAKE_C_FLAGS -Wall) add_executable(test test.c) OK, list append is having the problem. I will try and figure out why it has the space. For now, you could try this: set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wall) -Bill ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Re: [cmake 2.5 CVS] CMAKE_${LANG}_FLAGS is initialized with space
Bill Hoffman wrote: CMakeLists.txt: list(APPEND CMAKE_C_FLAGS -Wall) add_executable(test test.c) OK, list append is having the problem. I will try and figure out why it has the space. For now, you could try this: set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wall) OK, Dave Cole, just pointed out that list is the wrong thing to use here. The CMAKE_C_FLAGS variable is supposed to be a string and not a list. If you used list(APPEND more than once it would always fail. So, although odd that it has a space in it, it is benign. You should treat the variable as a string and not a list. -Bill ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Re: [cmake 2.5 CVS] CMAKE_${LANG}_FLAGS is initialized with space
On Dec 14, 2007 2:34 PM, Bill Hoffman [EMAIL PROTECTED] wrote: So, although odd that it has a space in it, it is benign. It's malignant from the standpoint of IF. CMAKE_C_FLAGS is being initialized to a nonempty string. That means if(CMAKE_C_FLAGS) will succeed. Should file a bug or fix it. Cheers, Brandon Van Every ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Re: [cmake 2.5 CVS] CMAKE_${LANG}_FLAGS is initialized with space
On Dec 14, 2007 7:43 AM, Rodolfo Lima [EMAIL PROTECTED] wrote: I think there is... another proof: if(${CMAKE_CXX_FLAGS} STREQUAL ) MESSAGE(equal!) else(${CMAKE_CXX_FLAGS} STREQUAL ) MESSAGE(not equal!) endif(${CMAKE_CXX_FLAGS} STREQUAL ) This returns equal! in my system... If CMAKE_CXX_FLAGS is actually null, then your script should terminate with an error. Correct syntax is either plain CMAKE_CXX_FLAGS or ${CMAKE_CXX_FLAGS}. What you've written would work only if the variable evaluates to a single variable name, or a single string constant. A cmake -P script has no cache. On my Windows Vista machine, your code gives me: C:\devel\mozcmake -P flags.cmake CMake Error: Error in cmake code at C:/devel/moz/flags.cmake:1: if had incorrect arguments: ${CMAKE_CXX_FLAGS} STREQUAL (Unknown arguments s pecified). Called from: [1] C:/devel/moz/flags.cmake Cheers, Brandon Van Every ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Re: [cmake 2.5 CVS] CMAKE_${LANG}_FLAGS is initialized with space
Brandon Van Every wrote: On Dec 14, 2007 2:34 PM, Bill Hoffman [EMAIL PROTECTED] wrote: So, although odd that it has a space in it, it is benign. It's malignant from the standpoint of IF. CMAKE_C_FLAGS is being initialized to a nonempty string. That means if(CMAKE_C_FLAGS) will succeed. Should file a bug or fix it. Sure, or better yet create a patch and file it... :) Since this is in CMAke 2.4 and CVS, it is a bug that folks have been living with for a lng time, and this is the first report of an issue. -Bill ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
[CMake] Re: [cmake 2.5 CVS] CMAKE_${LANG}_FLAGS is initialized with space
Brandon Van Every escreveu: On Dec 14, 2007 7:43 AM, Rodolfo Lima [EMAIL PROTECTED] wrote: If CMAKE_CXX_FLAGS is actually null, then your script should terminate with an error. Correct syntax is either plain CMAKE_CXX_FLAGS or ${CMAKE_CXX_FLAGS}. What you've written would work only if the variable evaluates to a single variable name, or a single string constant. Sorry, my mistake, I'd normally surround it with quotation marks. A cmake -P script has no cache. On my Windows Vista machine, your code gives me: C:\devel\mozcmake -P flags.cmake CMake Error: Error in cmake code at C:/devel/moz/flags.cmake:1: if had incorrect arguments: ${CMAKE_CXX_FLAGS} STREQUAL (Unknown arguments s pecified). Called from: [1] C:/devel/moz/flags.cmake It seems to be a unix problem... I'll dig cmake's source code when I get home, hopefully to find the culprit. Regards, rod ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Re: [cmake 2.5 CVS] CMAKE_${LANG}_FLAGS is initialized with space
On Dec 14, 2007 3:01 PM, Rodolfo Schulz de Lima [EMAIL PROTECTED] wrote: Bill Hoffman escreveu: OK, Dave Cole, just pointed out that list is the wrong thing to use here. The CMAKE_C_FLAGS variable is supposed to be a string and not a list. If you used list(APPEND more than once it would always fail. So, although odd that it has a space in it, it is benign. You should treat the variable as a string and not a list. I really thought it was a list of flags. What if a flag has an argument with a space? For instance, -I/home/rodolfo lima Congrats, you've discovered that certain aspects of CMake aren't actually list oriented. This is the kind of reason we need Chapter Oriented documentation, to explain these nuances of lists, strings, quotes, and escapes. For compatibility reasons, I don't think overhauling the string-oriented variables to make them list-oriented is feasible. And in one's own code, one has to choose whether to embrace a string-oriented or list-oriented flag handling style. More grist for the chapter. Cheers, Brandon Van Every ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
[CMake] Re: [cmake 2.5 CVS] CMAKE_${LANG}_FLAGS is initialized with space
Bill Hoffman escreveu: Do you have environment variables CFLAGS and CXXFLAGS set to have just a space? Also, what OS/compiler are you using? No, those variables are empty. Here's my configuration [EMAIL PROTECTED] ~ $ cmake --version cmake version 2.5-20071212 [EMAIL PROTECTED] ~ $ echo X${CXXFLAGS}X X${CFLAGS}X XX XX [EMAIL PROTECTED] ~ $ uname -a Linux home 2.6.23-gentoo-r1 #1 SMP Wed Nov 7 21:06:37 BRDT 2007 i686 Intel(R) Pentium(R) 4 CPU 3.20GHz GenuineIntel GNU/Linux [EMAIL PROTECTED] ~ $ gcc --version gcc (GCC) 4.2.2 (Gentoo 4.2.2 p1.0) Thanks for the quick response. Regards, rod ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake