In a GCC compiled project,
- How do I run CMake for each target type (debug/release)?
- How do I specify debug and release C/C++ flags using CMake?
- How do I express that the main executable will be compiled with
g++and one nested library withgcc?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
With CMake, it’s generally recommended to do an “out of source” build. Create your
CMakeLists.txtin the root of your project. Then from the root of your project:And for
Debug(again from the root of your project):Release/Debugwill add the appropriate flags for your compiler. There are alsoRelWithDebInfoandMinSizeRelbuild configurations.You can modify/add to the flags by specifying a toolchain file in which you can add
CMAKE_<LANG>_FLAGS_<CONFIG>_INITvariables, e.g.:See CMAKE_BUILD_TYPE for more details.
As for your third question, I’m not sure what you are asking exactly. CMake should automatically detect and use the compiler appropriate for your different source files.