[CMake] Still problems with add_custom_command
Hi, in my CMake project I have the need for a custom command that should be processed in case a file is touched...that is the file the custom command depends on. I already use the add_custom_command and add_custom_target CMake instructions in my project, but always for CMakeLists.txt files in subfolders where a static library will be build. I think I have a real simple requirement, but I don't get it work up to now. In my main project I have a subfolder with an own CMakeLists.txt file, this subfolder is added to the main project by instruction add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/subfolder" ). Within the CMakeLists.txt in the subfolder I want to call a custom command, so I added the following lines: message( "My Tool started by custom command / target" ) add_custom_command( OUTPUT Out.txt COMMAND tool.exe ${ToolConfig} DEPENDS ${ToolConfig} ) add_custom_target( TOOL_CFG_OUT DEPENDS Out.txt ) In my main project I added the custom target as dependency in the way: add_dependencies( ${PROJECT_NAME} TOOL_CFG_OUT ) If I start the CMake process generating the Makefile I see the output of my message "My Tool started by custom command / target", but the custom command is never called. I would like to have a build configuration that every time the dependend file which is declared in the variable ${ToolConfig} is touched, the command tool.exe is started. What am I doing wrong? Do you have a sample for me how to start a custom command every time a file is touched. I don't get it work. Thanks in advance, Martin... -- 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] How to use add_custom_command correctly
On 29.09.11 01:46, Michael Hertling wrote: On 09/28/2011 01:45 PM, Martin Kupke wrote: Now it seems to be solved, the generator is called and the generated sources / headers are then compiled and linked into a library. My changes are in the D:/project/Discovery/Generated/Driver/CMakeLists.txt just adding a add_custom_target( MyGeneratedSources ALL DEPENDS ${all_generated_srcs} ${all_generated_hdrs} ) Additionally I added in the root CMakeLists.txt add_dependencies( ${MY_PROJECT} MyGeneratedSources ) This works fine. Just two additional remarks: - For ADD_CUSTOM_COMMAND(OUTPUT ...), it's documented explicitly that relative paths after the OUTPUT clause will be interpreted with respect to the current binary directory, so you may leave out the leading ${CMAKE_CURRENT_BINARY_DIRECTORY} and specify relative paths here. However, for the DEPENDS clause, there is no such documentation. That wasn't my problem, because I didn't work with relative paths. But still good to know from where the relative path has to be seen, thanks for the info! - A custom command's OUTPUTs must be mentioned as other targets' prerequisites, i.e. as source files in ADD_EXECUTABLE/LIBRARY() or after the DEPENDS clause of ADD_CUSTOM_TARGET() in the same CMakeLists.txt file. Otherwise, the rule for the then unused OUTPUT is dropped, and it will never be generated. Thus, for generated sources/headers, there should be no need for an additional custom target as a custom command's anchor. This info with the ADD_CUSTOM_TARGET is the most important thing. Thanks for your answers. Regards, Martin Regards, Michael On 28.09.11 13:34, Rolf Eike Beer wrote: On 27.09.11 18:24, Michael Wild wrote: On 09/27/2011 05:59 PM, Martin Kupke wrote: Hi, in my project there is a subfolder which SHALL contain sources to generate a library. The problem is that at startup of the project there are no source files existing, because they will be generated by a code generator. This means within the build process the code generator needs to be called first, then generates the output files in the subfolder and then a library shall be generated from that source files (this are standard .c and .h files). If I start the code generator by hand to generate the source files and remove the custom command, then the compilation is successful, but I want the code generator to be started every time the configuration file for the code generator has changed. In my sample below * the driver.c would be one of the files which the code generator would generate * the variable CodeGen is the executable tool (the code generator himself) * the variable CodeGenParam contains the parameters which are passed to be able to generate without any user interaction * the variable CodeGenConfig is the input file for the code generator This subfolder contains its own CMakeLists.txt with the following settings: # snip # project(CANstack C) add_custom_command( OUTPUT driver.c COMMAND ${CodeGen} ${CodeGenParam} DEPENDS ${CodeGenConfig} ) ) file(GLOB CANstack_srcs "*.c") file(GLOB CANstack_hdrs "*.h") set(lib_name "CANstack") add_library(${lib_name} STATIC ${CANstack_srcs} ${CANstack_hdrs}) # snap # I don't get it work that the custom command is called and the source files from the code generator are produced. A few issues here: - Never generate output in the source tree, only in the binary tree. - Always use absolute paths with add_custom_command(). I use the absolute paths - Always list *all* outputs after the OUTPUT argument, otherwise CMake won't know that they are generated sources. I added the list of *all* files which shall be generated - Never use file(GLOB ...). It is evil. And breaks in your case. Just don't. I don't use the file(GLOB ...) anymore in this CMakeLists.txt Michael In case the generated output files already exist and the dependency file ${CodeGenConfig} has been touched, then the output will be generated. Typically there is from beginning of the project no source file existing, because the generator needs to be run first. If the output files are not existing, then I get an error message from CMake: # snip # CMake Error at Generated/CarIF_Appl/CANstack/CMakeLists.txt:31 (add_library): Cannot find source file: D:/project/Discovery/Generated/Driver/uart.c Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx # snap # How do I have to instruct CMake to run the code generator first, so that the library can be build of that sources? Can you paste the relevant snippet from your new CMakeLists.txt? You can try this first and see if it helps: add_custom_command
Re: [CMake] How to use add_custom_command correctly
Now it seems to be solved, the generator is called and the generated sources / headers are then compiled and linked into a library. My changes are in the D:/project/Discovery/Generated/Driver/CMakeLists.txt just adding a add_custom_target( MyGeneratedSources ALL DEPENDS ${all_generated_srcs} ${all_generated_hdrs} ) Additionally I added in the root CMakeLists.txt add_dependencies( ${MY_PROJECT} MyGeneratedSources ) This works fine. On 28.09.11 13:34, Rolf Eike Beer wrote: On 27.09.11 18:24, Michael Wild wrote: On 09/27/2011 05:59 PM, Martin Kupke wrote: Hi, in my project there is a subfolder which SHALL contain sources to generate a library. The problem is that at startup of the project there are no source files existing, because they will be generated by a code generator. This means within the build process the code generator needs to be called first, then generates the output files in the subfolder and then a library shall be generated from that source files (this are standard .c and .h files). If I start the code generator by hand to generate the source files and remove the custom command, then the compilation is successful, but I want the code generator to be started every time the configuration file for the code generator has changed. In my sample below * the driver.c would be one of the files which the code generator would generate * the variable CodeGen is the executable tool (the code generator himself) * the variable CodeGenParam contains the parameters which are passed to be able to generate without any user interaction * the variable CodeGenConfig is the input file for the code generator This subfolder contains its own CMakeLists.txt with the following settings: # snip # project(CANstack C) add_custom_command( OUTPUT driver.c COMMAND ${CodeGen} ${CodeGenParam} DEPENDS ${CodeGenConfig} ) ) file(GLOB CANstack_srcs "*.c") file(GLOB CANstack_hdrs "*.h") set(lib_name "CANstack") add_library(${lib_name} STATIC ${CANstack_srcs} ${CANstack_hdrs}) # snap # I don't get it work that the custom command is called and the source files from the code generator are produced. A few issues here: - Never generate output in the source tree, only in the binary tree. - Always use absolute paths with add_custom_command(). I use the absolute paths - Always list *all* outputs after the OUTPUT argument, otherwise CMake won't know that they are generated sources. I added the list of *all* files which shall be generated - Never use file(GLOB ...). It is evil. And breaks in your case. Just don't. I don't use the file(GLOB ...) anymore in this CMakeLists.txt Michael In case the generated output files already exist and the dependency file ${CodeGenConfig} has been touched, then the output will be generated. Typically there is from beginning of the project no source file existing, because the generator needs to be run first. If the output files are not existing, then I get an error message from CMake: # snip # CMake Error at Generated/CarIF_Appl/CANstack/CMakeLists.txt:31 (add_library): Cannot find source file: D:/project/Discovery/Generated/Driver/uart.c Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx # snap # How do I have to instruct CMake to run the code generator first, so that the library can be build of that sources? Can you paste the relevant snippet from your new CMakeLists.txt? You can try this first and see if it helps: add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/driver.c COMMAND ${CodeGen} {CodeGenParam} DEPENDS ${CodeGenConfig} ) add_executable(myexe ${CMAKE_CURRENT_BINARY_DIR}/driver.c) Of course you must tell the CodeGen where to put the result, preferably by passing "${CMAKE_CURRENT_BINARY_DIR}/driver.c" as argument (with the quotes, to make paths with spaces work right). If the generator can't handle this you can try to set WORKING_DIRECTORY to ${CMAKE_CURRENT_BINARY_DIR}, passing all other file arguments with absolute paths then. Eike -- 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] multiple source directories
I have a same problem (even relative paths should not be used, as I understood from documentation) and I fixed my problem by setting a variable in the /root/CMakeLists.txt e.g. set( MY_PROJECT_PROG1 ${CMAKE_CURRENT_SOURCE_DIR}/prog1 ) set( MY_PROJECT_PROG2 ${CMAKE_CURRENT_SOURCE_DIR}/prog2 ) The subprojects / subfolders always inherit the settings / variables, so you can work with ${MY_PROJECT_PROG1} in your /root/prog1/CMakeLists.txt. Martin On 28.09.11 12:51, pellegrini wrote: Hi all, I have a project with the following structure: root/ CMakeLists.txt prog1/ CMakeLists.txt Src/ file1.f90 prog2/ CMakeLists.txt Src/ file2.f90 where prog1, prog2 are individual projects. I would like to add file1.90 to the build process of prog2. To do so, in the CMakeLists.txt file of prog2 project, I put: set(SOURCES ../../prog1/Src/file1.f90 Src/file2.f90) and further add_executable(prog2 ${SOURCES}) when compiling with CMake I get the following error: ## CMake Error at CMakeLists.txt:35 (add_executable): Cannot find source file: ../../prog1/Src/file1.f90 Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx ### It seems that CMake cna not deal with relative path when declaring the sources for a project. I tried using the option CMAKE_USE_RELATIVE_PATHS but it might not be defined for that purpose as it did not solve the problem. Would you have any idea how to solve that problem ? thanks a lot Eric -- *martin kupke* can diagnostics engineer | senior software developer *m*:+49.151.5511.3632| *e*:martin.ku...@novero.com <mailto:martin.ku...@novero.com> skype:martin.kupke_novero | w:www.novero.com <http://www.novero.com> novero GmbH meesmannstr.103 | 44807 Bochum | germany novero gmbh | parsevalstr. 7 a | 40468 düsseldorf | germany | amtsgericht düsseldorf | hrb 58283 | umsatzsteueridentifikationsnummer: de 814973142 | geschäftsführender gesellschafter: razvan olosu -- 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] How to use add_custom_command correctly
On 27.09.11 18:24, Michael Wild wrote: On 09/27/2011 05:59 PM, Martin Kupke wrote: Hi, in my project there is a subfolder which SHALL contain sources to generate a library. The problem is that at startup of the project there are no source files existing, because they will be generated by a code generator. This means within the build process the code generator needs to be called first, then generates the output files in the subfolder and then a library shall be generated from that source files (this are standard .c and .h files). If I start the code generator by hand to generate the source files and remove the custom command, then the compilation is successful, but I want the code generator to be started every time the configuration file for the code generator has changed. In my sample below * the driver.c would be one of the files which the code generator would generate * the variable CodeGen is the executable tool (the code generator himself) * the variable CodeGenParam contains the parameters which are passed to be able to generate without any user interaction * the variable CodeGenConfig is the input file for the code generator This subfolder contains its own CMakeLists.txt with the following settings: # snip # project(CANstack C) add_custom_command( OUTPUT driver.c COMMAND ${CodeGen} ${CodeGenParam} DEPENDS ${CodeGenConfig} ) ) file(GLOB CANstack_srcs "*.c") file(GLOB CANstack_hdrs "*.h") set(lib_name "CANstack") add_library(${lib_name} STATIC ${CANstack_srcs} ${CANstack_hdrs}) # snap # I don't get it work that the custom command is called and the source files from the code generator are produced. A few issues here: - Never generate output in the source tree, only in the binary tree. - Always use absolute paths with add_custom_command(). I use the absolute paths - Always list *all* outputs after the OUTPUT argument, otherwise CMake won't know that they are generated sources. I added the list of *all* files which shall be generated - Never use file(GLOB ...). It is evil. And breaks in your case. Just don't. I don't use the file(GLOB ...) anymore in this CMakeLists.txt Michael In case the generated output files already exist and the dependency file ${CodeGenConfig} has been touched, then the output will be generated. Typically there is from beginning of the project no source file existing, because the generator needs to be run first. If the output files are not existing, then I get an error message from CMake: # snip # CMake Error at Generated/CarIF_Appl/CANstack/CMakeLists.txt:31 (add_library): Cannot find source file: D:/project/Discovery/Generated/Driver/uart.c Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx # snap # How do I have to instruct CMake to run the code generator first, so that the library can be build of that sources? Br, Martin -- 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] How to use add_custom_command correctly
Hi, in my project there is a subfolder which SHALL contain sources to generate a library. The problem is that at startup of the project there are no source files existing, because they will be generated by a code generator. This means within the build process the code generator needs to be called first, then generates the output files in the subfolder and then a library shall be generated from that source files (this are standard .c and .h files). If I start the code generator by hand to generate the source files and remove the custom command, then the compilation is successful, but I want the code generator to be started every time the configuration file for the code generator has changed. In my sample below * the driver.c would be one of the files which the code generator would generate * the variable CodeGen is the executable tool (the code generator himself) * the variable CodeGenParam contains the parameters which are passed to be able to generate without any user interaction * the variable CodeGenConfig is the input file for the code generator This subfolder contains its own CMakeLists.txt with the following settings: # snip # project(CANstack C) add_custom_command( OUTPUT driver.c COMMAND ${CodeGen} ${CodeGenParam} DEPENDS ${CodeGenConfig} ) ) file(GLOB CANstack_srcs "*.c") file(GLOB CANstack_hdrs "*.h") set(lib_name "CANstack") add_library(${lib_name} STATIC ${CANstack_srcs} ${CANstack_hdrs}) # snap # I don't get it work that the custom command is called and the source files from the code generator are produced. -- 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] How to set own linker?
After setting the variable CMAKE_C_LINK_EXECUTABLE to my own linker in my Platform/Generic-dcc file it was used. Formerly I set the variable in my toolchain file and that doesn't work. If setting the CMAKE_C_LINK_EXECUTABLE variable you need to set the complete string as in the CMake\share\cmake-2.8\Modules\CMakeCInformation.cmake. This means I copied the line where the standard C compiler was declared also as the linker and set the string in my Platform/Generic-dcc variable CMAKE_C_LINK_EXECUTABLE and that works. Now my cross linker is used, the compiled objects are passed as parameter and my linker flags are set. Your hint with the two lines is useful in any case: SET_TARGET_PROPERTIES(foo_target PROPERTIES LINKER_LANGUAGE C) SET_TARGET_PROPERTIES(foo_target PROPERTIES LINK_FLAGS "-abcdfg") Many thanks for that! On 23.09.11 14:37, Florian Reinhard wrote: here some points that should help you find a solution (just as a hint where or what to search) ENABLE_LANGUAGE(ASM_OCU) PROJECT (foo) SET(CMAKE_EXE_LINKER_FLAGS "-abcdfg" ) <-- does work for me! add_executable(foo_target ${FOO_SRC}) SET_TARGET_PROPERTIES(foo_target PROPERTIES LINKER_LANGUAGE C) SET_TARGET_PROPERTIES(foo_target PROPERTIES LINK_FLAGS "-abcdfg") -- martin kupke can diagnostics engineer | senior software developer m: +49.151.5511.3632 | e: martin.ku...@novero.com skype: martin.kupke_novero | w: www.novero.com meesmannstr.103 | 44807 Bochum | germany novero gmbh | parsevalstr. 7 a | 40468 düsseldorf | germany | amtsgericht düsseldorf | hrb 58283 | umsatzsteueridentifikationsnummer: de 814973142 | geschäftsführender gesellschafter: razvan olosu -- 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] How to set own linker?
In my cross compiling environment I have an own Platform folder which contains a Generic-dcc file, in this file I added the statement: set(CMAKE_C_LINK_EXECUTABLE "${COMPILER_PATH}/dld.exe") and now it seems that the dld.exe is used as linker. My next problem is, that my linker flags are not used. I tried to set CMAKE_EXE_LINKER_FLAGS, but this doesn't work. On 23.09.11 11:08, Martin Kupke wrote: If I am using a cross linker, mine is the dld.exe.. How do I incorporate it into the CMake process? As I could figure out CMake assumes that the compiler itself will do the linking. On 22.09.11 18:09, Martin Kupke wrote: Hi, I created a toolchain file for cross compiling in my Windows XP environment. To provide cross compiling functionality I set the CMAKE_SYSTEM_NAME to Generic. The toolchain file contains the variables: CMAKE_C_COMPILER set to my own wanted compiler, which is dcc.exe CMAKE_ASM_OCU_COMPILER set to my own wanted assembler, which is das.exe For both, assembler and compiler I created configuration files in the Platform folder. Up to this point everything goes fine and as wanted, the assembler source files with the .s extension are compiled with das.exe and the C source files with the extension .c are compiled with the dcc.exe. In the root top level CMakeLists.txt the instruction project( EmbeddedProject C ASM_OCU) ensures that only C compiler and ASM_OCU assembler are called (no CXX). Even in the root top level CMakeLists.txt I set add_executable( ${PROJECT_NAME} ${SourceFiles} ) where SourceFiles is a string containing all source files (assembler and C). I even tried to set the CMAKE_LINKER variable to my own linker, but it isn't used. Where is my fault? Thanks, Martin... -- 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] How to set own linker?
If I am using a cross linker, mine is the dld.exe.. How do I incorporate it into the CMake process? As I could figure out CMake assumes that the compiler itself will do the linking. On 22.09.11 18:09, Martin Kupke wrote: Hi, I created a toolchain file for cross compiling in my Windows XP environment. To provide cross compiling functionality I set the CMAKE_SYSTEM_NAME to Generic. The toolchain file contains the variables: CMAKE_C_COMPILER set to my own wanted compiler, which is dcc.exe CMAKE_ASM_OCU_COMPILER set to my own wanted assembler, which is das.exe For both, assembler and compiler I created configuration files in the Platform folder. Up to this point everything goes fine and as wanted, the assembler source files with the .s extension are compiled with das.exe and the C source files with the extension .c are compiled with the dcc.exe. In the root top level CMakeLists.txt the instruction project( EmbeddedProject C ASM_OCU) ensures that only C compiler and ASM_OCU assembler are called (no CXX). Even in the root top level CMakeLists.txt I set add_executable( ${PROJECT_NAME} ${SourceFiles} ) where SourceFiles is a string containing all source files (assembler and C). I even tried to set the CMAKE_LINKER variable to my own linker, but it isn't used. Where is my fault? Thanks, Martin... -- 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 -- ---- *martin kupke* can diagnostics engineer | senior software developer *m*:+49.151.5511.3632| *e*:martin.ku...@novero.com <mailto:martin.ku...@novero.com> skype:martin.kupke_novero | w:www.novero.com <http://www.novero.com> novero GmbH meesmannstr.103 | 44807 Bochum | germany novero gmbh | parsevalstr. 7 a | 40468 düsseldorf | germany | amtsgericht düsseldorf | hrb 58283 | umsatzsteueridentifikationsnummer: de 814973142 | geschäftsführender gesellschafter: razvan olosu -- 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] How to set own linker?
Hi, I created a toolchain file for cross compiling in my Windows XP environment. To provide cross compiling functionality I set the CMAKE_SYSTEM_NAME to Generic. The toolchain file contains the variables: CMAKE_C_COMPILER set to my own wanted compiler, which is dcc.exe CMAKE_ASM_OCU_COMPILER set to my own wanted assembler, which is das.exe For both, assembler and compiler I created configuration files in the Platform folder. Up to this point everything goes fine and as wanted, the assembler source files with the .s extension are compiled with das.exe and the C source files with the extension .c are compiled with the dcc.exe. In the root top level CMakeLists.txt the instruction project( EmbeddedProject C ASM_OCU) ensures that only C compiler and ASM_OCU assembler are called (no CXX). Even in the root top level CMakeLists.txt I set add_executable( ${PROJECT_NAME} ${SourceFiles} ) where SourceFiles is a string containing all source files (assembler and C). I even tried to set the CMAKE_LINKER variable to my own linker, but it isn't used. Where is my fault? Thanks, Martin... -- 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] SOLVED: Generated successfully NMake Makefile using CMake for Cross Compiling, but compiling with nmake fails
Hi, short info for those of you who run into the same pitfall. I downloaded the free (free of charge) nmake tool version 1.50 from the Microsoft website. The problem is this nmake tool which produces the problems with blanks / spaces in folder- and filenames. Even parameters which contain double quotes (") make problems in the Makefile. We have several installations of MS Visual Studio in different versions (Visual Studio 2003, 2008, 2010) and now I tried the NMake from Visual Studio 2003 which is file version 7.10.3077 and this works fine. Of course this version is NOT free of charge, because it's part of the buyable package from Microsoft. Just the short form: the nmake tool version 1.50 isn't able to use the generated Makefile. Br, Martin... On 20.09.11 11:00, Martin Kupke wrote: Hi, after many helpful hints from other users now I was able to create a NMake Makefile using CMake. I'm working in a Windows XP environment in a cmd.exe command line interface (shell). The CMake tool created the typical Makefile including the subfolders etc. in my output folder, without any errors or warnings. To compile my simple test project (in moment it contains only a single source standard C file), I call nmake.exe in my output path in the console. This is the same as calling nmake.exe with the parameter -f Makefile. The output of the nmake build process is: snip D:\novero\Discovery\impl\target\CarIF_Appl\output\Debug>nmake -f Makefile Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. 'C:\Program' is not recognized as an internal or external command, operable program or batch file. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x1' Stop. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2' Stop. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2' Stop. snap I assume that there is a problem with the filename / foldername, because of the line: 'C:\Program' is not recognized as an internal or external command... A search over the output files from CMake including the generated Makefile itself shows that all references in variables are set with double quote (") e.g. "C:\Program Files\CMake 2.8\bin\cmake.exe". Many thanks for your helpful comments in advance. Br, Martin... ___ 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 -- martin kupke can diagnostics engineer | senior software developer m: +49.151.5511.3632 | e: martin.ku...@novero.com skype: martin.kupke_novero | w: www.novero.com meesmannstr.103 | 44807 Bochum | germany novero gmbh | parsevalstr. 7 a | 40468 düsseldorf | germany | amtsgericht düsseldorf | hrb 58283 | umsatzsteueridentifikationsnummer: de 814973142 | geschäftsführender gesellschafter: razvan olosu ___ 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] Generated successfully NMake Makefile using CMake for Cross Compiling, but compiling with nmake fails
Hi, after many helpful hints from other users now I was able to create a NMake Makefile using CMake. I'm working in a Windows XP environment in a cmd.exe command line interface (shell). The CMake tool created the typical Makefile including the subfolders etc. in my output folder, without any errors or warnings. To compile my simple test project (in moment it contains only a single source standard C file), I call nmake.exe in my output path in the console. This is the same as calling nmake.exe with the parameter -f Makefile. The output of the nmake build process is: snip D:\novero\Discovery\impl\target\CarIF_Appl\output\Debug>nmake -f Makefile Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. 'C:\Program' is not recognized as an internal or external command, operable program or batch file. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x1' Stop. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2' Stop. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2' Stop. snap I assume that there is a problem with the filename / foldername, because of the line: 'C:\Program' is not recognized as an internal or external command... A search over the output files from CMake including the generated Makefile itself shows that all references in variables are set with double quote (") e.g. "C:\Program Files\CMake 2.8\bin\cmake.exe". Many thanks for your helpful comments in advance. Br, Martin... ___ 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] Cross compiling in Win32 environment doesn't work
Hi Alex, sorry for sending mails in HTML format (hopefully the mail client is now configured correctly). You'll find my answers to your comments below. On 20.09.11 05:29, Alexander Neundorf wrote: Hi, can you please adjust your mail client so it doesn't send HTML mails ? On Monday, September 19, 2011 04:57:32 PM Martin Kupke wrote: That's a hint, I changed my toolchain file "toolchain_ppc.cmake" to the following: INCLUDE(CMakeForceCompiler) set(CMAKE_SYSTEM_NAME "Discovery") if(CMAKE_CROSSCOMPILING) message("Cross Compiling") endif(CMAKE_CROSSCOMPILING) # which compilers to use for C and C++ set(CMAKE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_FORCE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_C_FLAGS "-tPPCVLEEN:simple") Then I created a folder with the name Platform containing a file with CMAKE_SYSTEM_NAME which is Discovery -> at this point I had already problems, because CMake doesn't use as described the filename with .cmake extension. The filename in the Platform folder has to have the name from CMAKE_SYSTEM_NAME without the extension .cmake (even the documentation says something different). I checked this by adding the output of a message("SYSTEM_NAME=Discovery"). The filename must be Discovery.cmake in your case. Did you say this didn't work ? This file must be either in the cmake Modules/Platfom/ directory, or in a subdirectory Platform/ of a directory which is in CMAKE_MODULE_PATH. Yes, I created the folder Platform in my CMAKE_MODULE_PATH and within this folder the file Discovery.cmake. This doesn't work! I checked it using the message tag to output a string on the console. After renaming the Discovery.cmake to only basename Discovery without the extension .cmake, the file was included. So, the extension .cmake isn't correct...even it is described in the documentation. The output of the CMake tool, if using the CMAKE_SYSTEM_NAME set to "Discovery": ### snip ### D:\novero\Discovery\impl\target\CarIF_Appl\output>cmake -G "NMake Makefiles" -D CMAKE_TOOLCHAIN_FILE="..\toolchain_ppc.cmake" .. Cross Compiling -- The C compiler identification is unknown -- Check for working C compiler: c:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe System is unknown to cmake, create: Platform/Discovery to use this system, please send your config file to cm...@www.cmake.org so it can be added to cmake -- Check for working C compiler: c:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe --works -- Detecting C compiler ABI info System is unknown to cmake, create: Platform/Discovery to use this system, please send your config file to cm...@www.cmake.org so it can be added to cmake -- Detecting C compiler ABI info - done C compiler: c:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe C flags: -tPPCVLEEN:simple Mein CMakeLists.txt File -- Configuring done -- Generating done -- Build files have been written to: D:/novero/Discovery/impl/target/CarIF_Appl/output ### snap ### It seems to work, even there are some hints that CMake doesn't know the system Discovery. I fixed the problem by using the CMAKE_SYSTEM_NAME set to "Generic". With "Generic" I need a configuration file in the Platform folder named to "Generic-dcc" with the compile flags. The name in the Platform folder again is used without the extension .cmake! "Generic" needs to be added with "-dcc" because of the Base name of the dcc.exe compiler. This now works and creates the Makefile in the output folder as wanted, without any errors / warnings ... The Platform/Discovery file contains the lines: message("SYSTEM_NAME=Discovery") set(CMAKE_FORCE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_C_FLAGS "-tPPCVLEEN:simple") set(CMAKE_FORCE_C_FLAGS "-tPPCVLEEN:simple") set(CMAKE_FORCE_CXX_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_CXX_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_CXX_FLAGS "-tPPCVLEEN:simple") set(CMAKE_MAKE_PROGRAM "D:/novero/Discovery/impl/win32/nmake/nmake.exe") That last line should not be necessary. I thought this would help to point to the nmake tool in the Makefile, in case it is not in the search path of the system. Then I call from the command line the CMake tool with the parameters: D:\novero\Discovery\impl\target\CarIF_Appl\output>cmake -G "NMake Makefiles" -D CMAKE_TOOLCHAIN_FILE="..\toolchain_ppc.cmake" .. The following output will be produced: * snip output * Cro
[CMake] How to setup toolchain correctly for C compiler only (no CXX present for target)
Is there a way to setup the toolchain file in a way to work only with a C compiler? What if no C++ compiler is present (or wanted) for the target HW? E.g. we use standard C compiler for different processors on our embedded solutions. We need to buy the compiler for C and / or C++, but mostly we only develop in C and therewith we don't buy the C++ licence. While configuring my build environment with CMake the first time the CMakeTestCCompiler and even the CMakeTestCXXCompiler used. I wasn't able to suppress the CXX part. Is there any option to do this? ___ 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] Where to declare the CMAKE_C_FLAGS for cross compiling
For cross compiling I need to set the variables "CMAKE_C_FLAGS_INIT" and "CMAKE_CXX_FLAGS_INIT" in the Platform Generic-dcc file. Not sure why I need to configure CXX compiler and flags, even I don't use them...but that's another story. Now the CMake tool passes and finished without any errors, but the created Makefile for "NMake Makefiles" Generator can't compile my source file. ### output of NMake ### D:\novero\Discovery\impl\target\CarIF_Appl\output>nmake Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. 'C:\Program' is not recognized as an internal or external command, operable program or batch file. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x1' Stop. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2' Stop. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2' Stop. ### output of NMake ### I assume that there is a problem with blanks in the path name, because of the output "'C:\Program' is not recognized as an internal or external command,". I guess it would be something like "C:\Program Files\" and the blank / space character confuses the build process. Any ideas to blanks / spaces in files and foldernames? Thanks Martin... On 19.09.11 18:04, Martin Kupke wrote: I'm using a toolchain file with the CMAKE_SYSTEM_NAME "Generic", because I want to cross compile on a Windows XP machine for a PPC (PowerPC) processor. From my point of view it should be in a way as in the documentation for the SDCC. My toolchain file "toolchain_ppc.cmake" is setup: # set(CMAKE_SYSTEM_NAME "Generic") if(CMAKE_CROSSCOMPILING) message("Cross Compiling") endif(CMAKE_CROSSCOMPILING) # which compilers to use for C and C++ set(CMAKE_C_COMPILER "dcc.exe") set(CMAKE_FIND_ROOT_PATH "C:/WindRiver/diab/5.9.0.0/WIN32/bin") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_C_FLAGS "-tPPCVLEEN:simple") # Additionally in the Platform folder I created a Generic-dcc file for system specific options: # MESSAGE("SYSTEM_NAME=Generic") set(CMAKE_C_FLAGS "-tPPCVLEEN:simple") # In the windows console I call the CMake tool in an empty output folder: D:\novero\Discovery\impl\target\CarIF_Appl\output>cmake -G "NMake Makefiles" -D CMAKE_TOOLCHAIN_FILE="..\toolchain_ppc.cmake" .. The output of the CMake process shows that the test compilation could not be performed and the reason for that is, that my CMAKE_C_FLAGS are not passed to the configured compiler dcc.exe. # Cross Compiling -- The C compiler identification is unknown -- The CXX compiler identification is unknown SYSTEM_NAME=Generic -- Check for working C compiler: c:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe -- Check for working C compiler: c:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe --broken CMake Error at C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE): The C compiler "c:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: D:/novero/Discovery/impl/target/CarIF_Appl/output/CMakeFiles/CMakeTmp Run Build Command:nmake /NOLOGO "cmTryCompileExec\fast" nmake -f CMakeFiles\cmTryCompileExec.dir\build.make /nologo -L CMakeFiles\cmTryCompileExec.dir\build "C:\Program Files\CMake 2.8\bin\cmake.exe" -E cmake_progress_report D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\CMakeFiles 1 Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj (LOOK_HERE)->c:\WindRiver\diab\5.9.0.0\WIN32\bin\dcc.exe -o CMakeFiles\cmTryCompileExec.dir\testCCompiler.c.obj -c D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\testCCompiler.c Target Unknown. Use the -t option or set a default target with dctrl -t NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x1' Stop. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2' Stop. CMake will not be able to correctly generate th
[CMake] Where to declare the CMAKE_C_FLAGS for cross compiling
I'm using a toolchain file with the CMAKE_SYSTEM_NAME "Generic", because I want to cross compile on a Windows XP machine for a PPC (PowerPC) processor. From my point of view it should be in a way as in the documentation for the SDCC. My toolchain file "toolchain_ppc.cmake" is setup: # set(CMAKE_SYSTEM_NAME "Generic") if(CMAKE_CROSSCOMPILING) message("Cross Compiling") endif(CMAKE_CROSSCOMPILING) # which compilers to use for C and C++ set(CMAKE_C_COMPILER "dcc.exe") set(CMAKE_FIND_ROOT_PATH "C:/WindRiver/diab/5.9.0.0/WIN32/bin") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_C_FLAGS "-tPPCVLEEN:simple") # Additionally in the Platform folder I created a Generic-dcc file for system specific options: # MESSAGE("SYSTEM_NAME=Generic") set(CMAKE_C_FLAGS "-tPPCVLEEN:simple") # In the windows console I call the CMake tool in an empty output folder: D:\novero\Discovery\impl\target\CarIF_Appl\output>cmake -G "NMake Makefiles" -D CMAKE_TOOLCHAIN_FILE="..\toolchain_ppc.cmake" .. The output of the CMake process shows that the test compilation could not be performed and the reason for that is, that my CMAKE_C_FLAGS are not passed to the configured compiler dcc.exe. # Cross Compiling -- The C compiler identification is unknown -- The CXX compiler identification is unknown SYSTEM_NAME=Generic -- Check for working C compiler: c:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe -- Check for working C compiler: c:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe --broken CMake Error at C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE): The C compiler "c:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: D:/novero/Discovery/impl/target/CarIF_Appl/output/CMakeFiles/CMakeTmp Run Build Command:nmake /NOLOGO "cmTryCompileExec\fast" nmake -f CMakeFiles\cmTryCompileExec.dir\build.make /nologo -L CMakeFiles\cmTryCompileExec.dir\build "C:\Program Files\CMake 2.8\bin\cmake.exe" -E cmake_progress_report D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\CMakeFiles 1 Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj (LOOK_HERE)->c:\WindRiver\diab\5.9.0.0\WIN32\bin\dcc.exe -o CMakeFiles\cmTryCompileExec.dir\testCCompiler.c.obj -c D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\testCCompiler.c Target Unknown. Use the -t option or set a default target with dctrl -t NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x1' Stop. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2' Stop. CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:2 (project) CMake Error: your CXX compiler: "cl" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name. -- Configuring incomplete, errors occurred! # I marked the position in the output with (LOOK_HERE)-> where you can see that the necessary compile flags CMAKE_C_FLAGS "-tPPCVLEEN:simple" have not been passed to the compiler. Where do I have to declare the CMAKE_C_FLAGS? ___ 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] Cross compiling in Win32 environment doesn't work
That's a hint, I changed my toolchain file "toolchain_ppc.cmake" to the following: INCLUDE(CMakeForceCompiler) set(CMAKE_SYSTEM_NAME "Discovery") if(CMAKE_CROSSCOMPILING) message("Cross Compiling") endif(CMAKE_CROSSCOMPILING) # which compilers to use for C and C++ set(CMAKE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_FORCE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_C_FLAGS "-tPPCVLEEN:simple") Then I created a folder with the name Platform containing a file with CMAKE_SYSTEM_NAME which is Discovery -> at this point I had already problems, because CMake doesn't use as described the filename with .cmake extension. The filename in the Platform folder has to have the name from CMAKE_SYSTEM_NAME without the extension .cmake (even the documentation says something different). I checked this by adding the output of a message("SYSTEM_NAME=Discovery"). The Platform/Discovery file contains the lines: message("SYSTEM_NAME=Discovery") set(CMAKE_FORCE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_C_FLAGS "-tPPCVLEEN:simple") set(CMAKE_FORCE_C_FLAGS "-tPPCVLEEN:simple") set(CMAKE_FORCE_CXX_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_CXX_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_CXX_FLAGS "-tPPCVLEEN:simple") set(CMAKE_MAKE_PROGRAM "D:/novero/Discovery/impl/win32/nmake/nmake.exe") Then I call from the command line the CMake tool with the parameters: D:\novero\Discovery\impl\target\CarIF_Appl\output>cmake -G "NMake Makefiles" -D CMAKE_TOOLCHAIN_FILE="..\toolchain_ppc.cmake" .. The following output will be produced: * snip output * Cross Compiling -- The C compiler identification is unknown -- The CXX compiler identification is unknown SYSTEM_NAME=Discovery SYSTEM_NAME=Discovery -- Check for working C compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe System is unknown to cmake, create: Platform/Discovery to use this system, please send your config file to cmake@www .cmake.org so it can be added to cmake -- Check for working C compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe -- broken CMake Error at C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCComp iler.cmake:52 (MESSAGE): The C compiler "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: D:/novero/Discovery/impl/target/CarIF_Appl/output/CMakeFiles/CMak eTmp Run Build Command:nmake /NOLOGO "cmTryCompileExec\fast" nmake -f CMakeFiles\cmTryCompileExec.dir\build.make /nologo -L CMakeFiles\cmTryCompileExec.dir\build "C:\Program Files\CMake 2.8\bin\cmake.exe" -E cmake_progress_report D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\CMakeFil es 1 Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj C:\WindRiver\diab\5.9.0.0\WIN32\bin\dcc.exe -o CMakeFiles\cmTryCompileExec.dir\testCCompiler.c.obj -c D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\testCCom piler.c Target Unknown. Use the -t option or set a default target with dctrl -t NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x1' Stop. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2' Stop. CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:2 (project) -- Configuring incomplete, errors occurred! You have changed variables that require your cache to be deleted. Configure will be re-run and you may have to reset some variables. The following variables have changed: CMAKE_CXX_COMPILER= cl -- Generating done -- Build files have been written to: D:/novero/Discovery/impl/target/CarIF_Appl/ output * snap output * 1.) with the output SYSTEM_NAME=Discovery I can see that the platform file is used 2.) the compilation doesn't complete, because the CMAKE_C_FLAGS are still not used 3.) why do I have to have a CXX
Re: [CMake] Cross compiling in Win32 environment doesn't work
My problem (the error) already occurs in the toolchain file, this means before the CMakeLists.txt is read. So far it is total independent of the entries in the CMakeLists.txt! I have added the line: message ("Mein CMakeLists.txt File") in top of my CMakeLists.txt and would assume that there is an output on the console with the string, but it isn't. The output is stopped while parsing the toolchain file and determining the compiler. On 19.09.11 15:26, Benjamin Ruard wrote: You can use the following commands to know what are compilers used in the CMakeLists.txt: message("C compiler: " ${CMAKE_C_COMPILER}) message("C++ compiler: " ${CMAKE_CXX_COMPILER}) Moreover, you can set them: set(CMAKE_CXX_COMPILER ...) regards Benjamin JEANTY-RUARD Le lundi 19 septembre 2011 à 14:44 +0200, Martin Kupke a écrit : I'm using CMake in version 2.8.5 and just want to cross compile with a decicated Compiler / Linker set on my Windows machine. Of course I've read the FAQ and the Tutorial, afterwards I started trying to use CMake on a DOS (cmd.exe) command line interface with CMakeLists.txt and a toolchain file. After all tests failed to get CMake work in the Win32 environment, I tried it in my private Linux (Debian Squeeze) and the same procedure is successful. In Linux environment it works as described, in Win32 not. My PC has installed Windows XP including SP3. CMake version 2.8.5 is installed. My development path contains a CMakeLists.txt and a toolchain_ppc.cmake file, because I want to compile on my WinXP code for an embedded hardware using a PPC processor. The toolchain_ppc.cmake file contains the following settings: set (CMAKE_GENERATOR "NMake Makefiles") set (CMAKE_SYSTEM_NAME "Generic") set (CMAKE_C_COMPILER "dcc.exe") set (CMAKE_SYSTEM_PROCESSOR "ppc") if(CMAKE_CROSSCOMPILING) message("Cross Compiling") endif(CMAKE_CROSSCOMPILING) set(CMAKE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_C_FLAGS "-tPPCVLEEN:simple") In my build environment I created an empty folder output and in the command line interface (console / cmd.exe) I'm calling the cmake tool: D:\novero\Discovery\impl\target\CarIF_Appl\output>cmake -D CMAKE_TOOLCHAIN_FILE="..\toolchain_ppc.cmake" .. The output of the cmake tool always is: -- Building for: Visual Studio 10 Cross Compiling As you can see my message "Cross Compiling" is shown, this introduces that cmake is using the "CMAKE_CROSSCOMPILING" flag. But why the hell is there always the output "-- Building for: Visual Studio 10"? I don't wan't to use anything from / for Visual Studio 10. The CMakeOutput.log contains the following lines: The target system is: Generic - - ppc The host system is: Windows - 5.1 - x86 Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded. Compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe Build flags: -tPPCVLEEN:simple Id flags: The output was: 0 Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out" Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded. Compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe Build flags: -tPPCVLEEN:simple Id flags: -c The output was: 0 Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.o" Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded. Compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe Build flags: -tPPCVLEEN:simple Id flags: The output was: 0 Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out" Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded. Compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe Build flags: -tPPCVLEEN:simple Id flags: -c The output was: 0 Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.o" Determining if the C compiler works passed with the following output: Change Dir: D:/novero/Discovery/impl/target/CarIF_Appl/output/CMakeFiles/CMakeTmp Run Build Command:C:\PROGRA~1\MICROS~2.0\Common7\IDE\devenv.com CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec Microsoft (R) Visual Studio Version 10.0.30319.1. Copyright (C) Microsoft Corp. All rights reserved. 1>-- Build started: Project: cmTryCompileExec, Configuration: Debug Win32 -- 1> testCCompiler.c 1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(D:\novero\Discovery\impl\target\CarIF_Appl\outp
Re: [CMake] Cross compiling in Win32 environment doesn't work
If adding the parameter -G "NMake Makefiles" to my command line, then the output is different...but still errors: * snip output * Cross Compiling -- The C compiler identification is unknown -- The CXX compiler identification is unknown -- Check for working C compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe -- Check for working C compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe -- broken CMake Error at C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCComp iler.cmake:52 (MESSAGE): The C compiler "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: D:/novero/Discovery/impl/target/CarIF_Appl/output/CMakeFiles/CMak eTmp Run Build Command:nmake /NOLOGO "cmTryCompileExec\fast" nmake -f CMakeFiles\cmTryCompileExec.dir\build.make /nologo -L CMakeFiles\cmTryCompileExec.dir\build "C:\Program Files\CMake 2.8\bin\cmake.exe" -E cmake_progress_report D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\CMakeFil es 1 Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj C:\WindRiver\diab\5.9.0.0\WIN32\bin\dcc.exe -o CMakeFiles\cmTryCompileExec.dir\testCCompiler.c.obj -c D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\testCCom piler.c Target Unknown. Use the -t option or set a default target with dctrl -t NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x1' Stop. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2' Stop. * snap output * As you can see above, now the CMAKE_C_FLAGS are not recognized. set(CMAKE_C_FLAGS "-tPPCVLEEN:simple") On 19.09.11 15:24, Eric Noulard wrote: 2011/9/19 Martin Kupke : I'm using CMake in version 2.8.5 and just want to cross compile with a decicated Compiler / Linker set on my Windows machine. Of course I've read the FAQ and the Tutorial, afterwards I started trying to use CMake on a DOS (cmd.exe) command line interface with CMakeLists.txt and a toolchain file. After all tests failed to get CMake work in the Win32 environment, I tried it in my private Linux (Debian Squeeze) and the same procedure is successful. In Linux environment it works as described, in Win32 not. My PC has installed Windows XP including SP3. CMake version 2.8.5 is installed. My development path contains a CMakeLists.txt and a toolchain_ppc.cmake file, because I want to compile on my WinXP code for an embedded hardware using a PPC processor. The toolchain_ppc.cmake file contains the following settings: set (CMAKE_GENERATOR "NMake Makefiles") I'm not sure whether if CMAKE_GENERATOR can be set in the toolchain file? [...] D:\novero\Discovery\impl\target\CarIF_Appl\output>cmake -D CMAKE_TOOLCHAIN_FILE="..\toolchain_ppc.cmake" .. did you try to add '-G "NMake Makefiles"' to your command line? [...] I just want to use a standard Assembler, C Compiler and Linker. I don't need CXX (C++) in my build environment and even I don't need (want) any Visual Studio in my Cross Compilation. The generator for CMake shall be "NMake Makefiles" so that the generated Makefile can be used with "NMake". Hopefully you can help me out of this. ___ 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 -- martin kupke can diagnostics engineer | senior software developer m: +49.151.5511.3632 | e: martin.ku...@novero.com skype: martin.kupke_novero | w: www.novero.com meesmannstr.103 | 44807 Bochum | germany novero gmbh | parsevalstr. 7 a | 40468 düsseldorf | germany | amtsgericht düsseldorf | hrb 58283 | umsatzsteueridentifikationsnummer: de 814973142 | geschäftsführender gesellschafter: razvan olosu _
[CMake] Cross compiling in Win32 environment doesn't work
I'm using CMake in version 2.8.5 and just want to cross compile with a decicated Compiler / Linker set on my Windows machine. Of course I've read the FAQ and the Tutorial, afterwards I started trying to use CMake on a DOS (cmd.exe) command line interface with CMakeLists.txt and a toolchain file. After all tests failed to get CMake work in the Win32 environment, I tried it in my private Linux (Debian Squeeze) and the same procedure is successful. In Linux environment it works as described, in Win32 not. My PC has installed Windows XP including SP3. CMake version 2.8.5 is installed. My development path contains a CMakeLists.txt and a toolchain_ppc.cmake file, because I want to compile on my WinXP code for an embedded hardware using a PPC processor. The toolchain_ppc.cmake file contains the following settings: set (CMAKE_GENERATOR "NMake Makefiles") set (CMAKE_SYSTEM_NAME "Generic") set (CMAKE_C_COMPILER "dcc.exe") set (CMAKE_SYSTEM_PROCESSOR "ppc") if(CMAKE_CROSSCOMPILING) message("Cross Compiling") endif(CMAKE_CROSSCOMPILING) set(CMAKE_C_COMPILER "C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe") set(CMAKE_C_FLAGS "-tPPCVLEEN:simple") In my build environment I created an empty folder output and in the command line interface (console / cmd.exe) I'm calling the cmake tool: D:\novero\Discovery\impl\target\CarIF_Appl\output>cmake -D CMAKE_TOOLCHAIN_FILE="..\toolchain_ppc.cmake" .. The output of the cmake tool always is: -- Building for: Visual Studio 10 Cross Compiling As you can see my message "Cross Compiling" is shown, this introduces that cmake is using the "CMAKE_CROSSCOMPILING" flag. But why the hell is there always the output "-- Building for: Visual Studio 10"? I don't wan't to use anything from / for Visual Studio 10. The CMakeOutput.log contains the following lines: The target system is: Generic - - ppc The host system is: Windows - 5.1 - x86 Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded. Compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe Build flags: -tPPCVLEEN:simple Id flags: The output was: 0 Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out" Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded. Compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe Build flags: -tPPCVLEEN:simple Id flags: -c The output was: 0 Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.o" Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded. Compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe Build flags: -tPPCVLEEN:simple Id flags: The output was: 0 Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out" Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded. Compiler: C:/WindRiver/diab/5.9.0.0/WIN32/bin/dcc.exe Build flags: -tPPCVLEEN:simple Id flags: -c The output was: 0 Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.o" Determining if the C compiler works passed with the following output: Change Dir: D:/novero/Discovery/impl/target/CarIF_Appl/output/CMakeFiles/CMakeTmp Run Build Command:C:\PROGRA~1\MICROS~2.0\Common7\IDE\devenv.com CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec Microsoft (R) Visual Studio Version 10.0.30319.1. Copyright (C) Microsoft Corp. All rights reserved. 1>-- Build started: Project: cmTryCompileExec, Configuration: Debug Win32 -- 1> testCCompiler.c 1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec) does not match the Linker's OutputFile property value (D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile). 1> cmTryCompileExec.vcxproj -> D:\novero\Discovery\impl\target\CarIF_Appl\output\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec == Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped == Detecting C compiler ABI info compiled with the following output: Change Dir: D:/novero/Discovery/impl/target/CarIF_Appl/output/CMakeFiles/CMakeTmp Run Build Command:C:\PROGRA~1\MICROS~2.0\Common7\IDE\devenv.com CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec Microsoft (R) Visual Studio Version 10.0.30319.1. Copyright (C) Microsoft Corp. All rights reserved. 1>-- Build started: Project: cmTryCompileExec, Configuration: Debug Win32 -- 1> CMakeCCompilerABI.c 1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: