Re: [CMake] Compile project as C++ if MSVC
On 12/23/2011 5:43 PM, Pau Garcia i Quiles wrote: Hi Bill, Thank you. I tried that but it's failing: since no project in the whole project tree is defined as C++ (i. e. everything is project(blah C)), the generation step fails with: CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly. Missing variable is: CMAKE_CXX_FLAGS_DEBUG I've opened issue #12639 for this and attached a minimal case, and a workaround: http://public.kitware.com/Bug/view.php?id=12639 I am thinking if you want to compile with C++, you need to enable the c++ language. You can call enable_language(CXX) inside the if. -Bill -- 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
Re: [CMake] Compile project as C++ if MSVC
On Sat, Dec 24, 2011 at 4:11 PM, Bill Hoffman bill.hoff...@kitware.com wrote: Thank you. I tried that but it's failing: since no project in the whole project tree is defined as C++ (i. e. everything is project(blah C)), the generation step fails with: CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly. Missing variable is: CMAKE_CXX_FLAGS_DEBUG I've opened issue #12639 for this and attached a minimal case, and a workaround: http://public.kitware.com/Bug/view.php?id=12639 I am thinking if you want to compile with C++, you need to enable the c++ language. You can call enable_language(CXX) inside the if. You are right. That solves the issue, thank you. -- Pau Garcia i Quiles http://www.elpauer.org (Due to my workload, I may need 10 days to answer) -- 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
Re: [CMake] Compile project as C++ if MSVC
On 23 December 2011 01:28, Pau Garcia i Quiles pgqui...@elpauer.org wrote: Visual C++ 2010 does not support C99 yet and it seems it will be a long time before MSVC supports it. AFAIK, Microsoft does not plan to support C99. Visual C++ will support as much C99 as imported in to most recent C++11 as Microsoft aims to fully support C++11 and future revisions. For now, the usual work-around is to build the project as C++. If a certain feature from C99 is not supported by Visual C++, how it is supposed to be workaround? Best regards, -- Mateusz Loskot, http://mateusz.loskot.net -- 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
Re: [CMake] Compile project as C++ if MSVC
2011/12/23 Mateusz Łoskot mate...@loskot.net: For now, the usual work-around is to build the project as C++. If a certain feature from C99 is not supported by Visual C++, how it is supposed to be workaround? Many C99 features were already supported by standard C++ and/or Visual C++-specific features: mixing declarations and code, snprintf, inline functions, more data types, etc -- Pau Garcia i Quiles http://www.elpauer.org (Due to my workload, I may need 10 days to answer) -- 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
Re: [CMake] Compile project as C++ if MSVC
2011/12/23 Pau Garcia i Quiles pgqui...@elpauer.org: 2011/12/23 Mateusz Łoskot mate...@loskot.net: For now, the usual work-around is to build the project as C++. If a certain feature from C99 is not supported by Visual C++, how it is supposed to be workaround? Many C99 features were already supported by standard C++ and/or Visual C++-specific features: mixing declarations and code, snprintf, inline functions, more data types, etc No. All the features you listed above are C++ standard features, including snprintf which is C++11 feature introduced as part of C99 compatibility. There are *no* C99 features available in Visual C++, other than those defined by C++11. However, there are Microsoft-specific features in Visual C++ which only look feel like C99 but they are not claimed or documented as they supposed to be considered as C99. Thus, _snprintf (not snprintf, in pre-Visual Studio 11) is Microsoft-specific feature, *not* C99. In Visual Studio 11 it is snprintf, which is C++11 feature. Regarding C language, there is *no* support of plain/core C99, other than that from C++11 and future revisions. It has been clearly stated by Microsoft many times. It is just people seem to be confused or just don't want to understand it (and then complain). [1] http://connect.microsoft.com/VisualStudio/feedback/details/531634/support-iso-c99-standard Best regards, -- Mateusz Loskot, http://mateusz.loskot.net -- 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
Re: [CMake] Compile project as C++ if MSVC
2011/12/23 Mateusz Łoskot mate...@loskot.net: Thus, _snprintf (not snprintf, in pre-Visual Studio 11) is Microsoft-specific feature I missed to add link related to this: http://msdn.microsoft.com/en-us/library/45aft37a.aspx Best regards, -- Mateusz Loskot, http://mateusz.loskot.net -- 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
Re: [CMake] Compile project as C++ if MSVC
2011/12/23 Mateusz Łoskot mate...@loskot.net: For now, the usual work-around is to build the project as C++. If a certain feature from C99 is not supported by Visual C++, how it is supposed to be workaround? Many C99 features were already supported by standard C++ and/or Visual C++-specific features: mixing declarations and code, snprintf, inline functions, more data types, etc No. All the features you listed above are C++ standard features, including snprintf which is C++11 feature introduced as part of C99 compatibility. That's exactly why the workaround is to compile the C project as C++ to get the C99 features that are both in C99 and in C++. -- Pau Garcia i Quiles http://www.elpauer.org (Due to my workload, I may need 10 days to answer) -- 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
Re: [CMake] Compile project as C++ if MSVC
2011/12/23 Pau Garcia i Quiles pgqui...@elpauer.org: 2011/12/23 Mateusz Łoskot mate...@loskot.net: For now, the usual work-around is to build the project as C++. If a certain feature from C99 is not supported by Visual C++, how it is supposed to be workaround? Many C99 features were already supported by standard C++ and/or Visual C++-specific features: mixing declarations and code, snprintf, inline functions, more data types, etc No. All the features you listed above are C++ standard features, including snprintf which is C++11 feature introduced as part of C99 compatibility. That's exactly why the workaround is to compile the C project as C++ to get the C99 features that are both in C99 and in C++. Gotcha. Visual C++ compiles as C++ by default, unless you specify /TC option. Best regards, -- Mateusz Loskot, http://mateusz.loskot.net -- 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
Re: [CMake] Compile project as C++ if MSVC
Back to the original question, just to be clear. The right way to do this is with the set_source_files_properties command: set_source_files_properties(SRC PROPERTIES LANGUAGE CXX) -Bill -- 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
Re: [CMake] Compile project as C++ if MSVC
On 23 December 2011 15:07, Bill Hoffman bill.hoff...@kitware.com wrote: Back to the original question, just to be clear. The right way to do this is with the set_source_files_properties command: set_source_files_properties(SRC PROPERTIES LANGUAGE CXX) Thanks Bill. It is always good to learn new things about favourite build toolset :) Best regards, -- Mateusz Loskot, http://mateusz.loskot.net -- 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
Re: [CMake] Compile project as C++ if MSVC
2011/12/23 Mateusz Łoskot mate...@loskot.net: On 23 December 2011 15:07, Bill Hoffman bill.hoff...@kitware.com wrote: Back to the original question, just to be clear. The right way to do this is with the set_source_files_properties command: set_source_files_properties(SRC PROPERTIES LANGUAGE CXX) This works well; when I implemented it I ended up wanting to compile as C and C++ the same code, so I used cmake copy_if_different functionality to copy all the .c files and directory structure to the build directory, and rename to .cpp during the copy Thanks Bill. It is always good to learn new things about favourite build toolset :) Best regards, -- Mateusz Loskot, http://mateusz.loskot.net -- 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 -- 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
Re: [CMake] Compile project as C++ if MSVC
Hi Bill, Thank you. I tried that but it's failing: since no project in the whole project tree is defined as C++ (i. e. everything is project(blah C)), the generation step fails with: CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly. Missing variable is: CMAKE_CXX_FLAGS_DEBUG I've opened issue #12639 for this and attached a minimal case, and a workaround: http://public.kitware.com/Bug/view.php?id=12639 On Fri, Dec 23, 2011 at 4:07 PM, Bill Hoffman bill.hoff...@kitware.com wrote: Back to the original question, just to be clear. The right way to do this is with the set_source_files_properties command: set_source_files_properties(SRC PROPERTIES LANGUAGE CXX) -- Pau Garcia i Quiles http://www.elpauer.org (Due to my workload, I may need 10 days to answer) -- 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
[CMake] Compile project as C++ if MSVC
Hi, Visual C++ 2010 does not support C99 yet and it seems it will be a long time before MSVC supports it. For now, the usual work-around is to build the project as C++. I'd like to build as C if using mingw, and as C++ if using MSVC. How can I do that? project() seems not to be valid here (I can't do if(MSVC) before project()) and I cannot find a target property to say compile as language CXX Thank you -- Pau Garcia i Quiles http://www.elpauer.org (Due to my workload, I may need 10 days to answer) -- 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
Re: [CMake] Compile project as C++ if MSVC
2011/12/23 Pau Garcia i Quiles pgqui...@elpauer.org: Hi, Visual C++ 2010 does not support C99 yet and it seems it will be a long time before MSVC supports it. For now, the usual work-around is to build the project as C++. I'd like to build as C if using mingw, and as C++ if using MSVC. How can I do that? project() seems not to be valid here (I can't do if(MSVC) before project()) and I cannot find a target property to say compile as language CXX There is a LANGUAGE property but it is for source files not target (which is logical because a target may contain mixed language sources) so set_source_files_properties(SRC PROPERTIES LANGUAGE C) see cmake --help-property LANGUAGE cmake --help-command set_source_files_properties you may be interested by the SOURCE target property as well which makes its possible to retrieve all SOURCE file belonging to a target. -- Erk Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org -- 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
Re: [CMake] Compile project as C++ if MSVC
On 12/23/2011 07:23 AM, Eric Noulard wrote: 2011/12/23 Pau Garcia i Quiles pgqui...@elpauer.org: Hi, Visual C++ 2010 does not support C99 yet and it seems it will be a long time before MSVC supports it. For now, the usual work-around is to build the project as C++. I'd like to build as C if using mingw, and as C++ if using MSVC. How can I do that? project() seems not to be valid here (I can't do if(MSVC) before project()) and I cannot find a target property to say compile as language CXX There is a LANGUAGE property but it is for source files not target (which is logical because a target may contain mixed language sources) so set_source_files_properties(SRC PROPERTIES LANGUAGE C) see cmake --help-property LANGUAGE cmake --help-command set_source_files_properties you may be interested by the SOURCE target property as well which makes its possible to retrieve all SOURCE file belonging to a target. You could also fiddle around with the CMAKE_LANG_SOURCE_FILE_EXTENSION variables. E.g: if(MSVC) list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSION ${CMAKE_C_SOURCE_FILE_EXTENSION}) set(CMAKE_C_SOURCE_FILE_EXTENSION) endif() 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