Note that you must not specify a build type (Debug or Release) since it apparently conflicts with the manually set compiler flags. Set(CMAKE_EXE_LINKER_FLAGS "-s") # Strip binary This is an example that shows how to do it: cmake_minimum_required(VERSION 2.6) So before forcing compiler options, you need to check that the compiler is really GCC. However, keep in mind that a CMakeLists.txt file should ideally work with many compilers. Last, if you are a GCC wizard and you want full control of the options passed to the compiler, you can also set them manually. And if you find uncomfortable to have to edit the CMakeLists.txt file to switch between Release and Debug mode, you can also specify the option in the CMake command line, like this: mkdir build & cd build usr/bin/c++ -O3 -DNDEBUG CMakeFiles/hello.dir/ CMakeFiles/hello.dir/ usr/bin/c++ -O3 -DNDEBUG -o CMakeFiles/hello.dir/ -c /tmp/cmaketest/foo.cpp usr/bin/c++ -O3 -DNDEBUG -o CMakeFiles/hello.dir/ -c /tmp/cmaketest/main.cpp With the Release build type, the options passed to the compiler are these: Of course, change “Release” with “Debug” for debug builds. To fix this you simply need to specify a build type in the CMakeLists.txt file, in this way: set(CMAKE_BUILD_TYPE Release)Īt the end of your CMakeLists.txt file. The build type is a feature most IDE have, it allows you to compile your program in “debug” mode, for easily single-stepping through it with a debugger, or in “release” mode, with speed optimization enabled. That’s because no build type has been specified to CMake. Now, if you’ve read my previous blog post on GCC’s compiler flags, you might probably not like what you see, since no optimization flag has been passed to GCC and as a result, your program won’t run as fast as it should. usr/bin/c++ CMakeFiles/hello.dir/ CMakeFiles/hello.dir/ -o hello usr/bin/c++ -o CMakeFiles/hello.dir/ -c /tmp/cmaketest/foo.cpp Building CXX object CMakeFiles/hello.dir/ usr/bin/c++ -o CMakeFiles/hello.dir/ -c /tmp/cmaketest/main.cpp Here is the relevant part of the printout: But if the goal is to see the compiler flags used, it is always possible to override this behaviour with the VERBOSE=1 option. By default CMake hides the options passed to the compiler, and displays a higher level status indicator with the build completion percentage together with the name of the file currently being built (a much more elegant solution than autoconf). The interesting thing here is the VERBOSE=1 option. To do so, it is possible to use the commands: mkdir build & cd build But let’s see exactly what CMake does to compile these files. The first CMakeLists.txt looked like this: cmake_minimum_required(VERSION 2.6)Īs already explained, it successfully creates an executable called “hello” using the main.cpp and foo.cpp source files. Now it’s time to explore the CMake syntax further. Very disappointed in the place.It’s not the first time I talk about CMake in this blog, for the introduction read here. When she saw me return she tried to cover by saying she didn't know who or why someone had cleared our table but she would get us new drinks. Whole cloves in the baklava that tasted of nothing but cloves and cinnamon, soupy banana pudding, nasty "cheesecake" yuck!) our table had been cleared and our waitress was setting it up for new customers. When we came back from getting some deserts (they weren't good either. I have never thrown uneaten crab legs away but tonight I did. they were like putting a spoon of salt in your mouth and chewing on it. The Crab Imperial tasted like cheap mustard and pickles. We finally were seated at another table because yes, that first table was taken. She made us stand there until she SLOWLY walked back to hostess stand to find out. I have eaten at this resturant several times and never had a bad meal BUT this time it was HORRIBLE!!!!! First the hostess took us to a table she wasn't sure if people were sitting at our not.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |