really-simple-ssl
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home3/c2planpf/public_html/wp-includes/functions.php on line 6114wordpress-seo
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home3/c2planpf/public_html/wp-includes/functions.php on line 6114CMake is the meta build system widely used for C and C++ projects and it generates build scripts for target platform. CMake is platform independent and generates Makefile on the Linux.<\/p>\n\n\n\n
When the cmake <\/strong>command is launched it parses an instruction file called CMakeLists.txt. The name of the file is case sensitive and should be CMakeLists.txt<\/em><\/strong> for cmake to be able to parse it.<\/p>\n\n\n\n Lets create a simple CMakeLists.txt file which builds C++ program with two source files.<\/p>\n\n\n\n In general very first instruction used in CMakeList.txt file is specifying the minimum cmake version required for our project. When cmake is run if the version is not matched it will throw fatal error.<\/p>\n\n\n\n Next instruction is declaring the name of the project and programming language C or C++ etc…<\/p>\n\n\n\n In the above instruction CXX specifies C++ and simple C can be used for C language. CMake supports C, C++, CUDA, Fortran etc. By default C, C++ languages are supported if there is no LANGUAGE instruction is specified.<\/p>\n\n\n\n Next instruction is create a build target, in this case it is an executable which is generated by compiling and linking two C++ files.<\/p>\n\n\n\n <\/p>\n\n\n\n Now we assume that source file and CMakeLists.txt file are in the same directory. To build using cmake create build<\/strong><\/em> directory and goto that directory using the below commands. This is one more feature\/advantage of CMake which builds out side of the source directory. The advantage with this kind of build system is it will not mess up the source directory with build files.<\/p>\n\n\n\n The example C++ code we are using for this blog is given below.<\/p>\n\n\n\n <\/p>\n\n\n\n Above commands show the build process using cmake, when we run the cmake with build options it generates executable “hello_cmake” as specified in add_executable instruction. The list of files generated by cmake on Linux platform is as blow<\/p>\n\n\n\n <\/p>\n\n\n\n <\/p>\n","protected":false},"excerpt":{"rendered":" CMake is the meta build system widely used for C and C++ projects and it generates build scripts for target platform. CMake is platform independent and generates Makefile on the Linux. When the cmake command is launched it parses an instruction file called CMakeLists.txt. The name of the file is case sensitive and should be […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[97,95,96],"class_list":["post-987","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-add_executable","tag-cmake","tag-cmakelists-txt"],"yoast_head":"\ncmake_minimum_required( VERSION 3.5 )<\/code><\/pre>\n\n\n\n
project (cmake_c2p LANGUAGES CXX)<\/code><\/pre>\n\n\n\n
add_executable (hello_cmake hello_1.cpp hello_2.cpp)\n<\/code><\/pre>\n\n\n\n
\/\/Hello_1.hpp file content\nint largest(int num1, int num2);\n\n\/\/hello_1.cpp file content\n#include <iostream>\n#include \"hello_1.hpp\"\n\nusing namespace std;\nint main() {\n cout << \"The largest number is: \" << largest(34,65) << endl;\n}\n\n\n\/\/hello_2.cpp file content\n\n#include \"hello_1.hpp\"\n\nint largest(int num1, int num2) {\n return num1 > num2 ? num1:num2;\n}\n\n<\/code><\/pre>\n\n\n\n
mkdir build\ncd build\n\ndemo@c2plabs:~\/CMAKE_BLOG\/build$ cmake --build .\n[ 33%] Linking CXX executable hello_cmake\n[100%] Built target hello_cmake\n<\/code><\/pre>\n\n\n\n