{"id":333,"date":"2019-02-25T08:00:00","date_gmt":"2019-02-25T07:00:00","guid":{"rendered":"http:\/\/www.miscdebris.net\/blog\/?p=333"},"modified":"2019-02-19T13:41:11","modified_gmt":"2019-02-19T12:41:11","slug":"adding-doxygen-support-to-cmakelists-txt","status":"publish","type":"post","link":"http:\/\/www.miscdebris.net\/blog\/2019\/02\/25\/adding-doxygen-support-to-cmakelists-txt\/","title":{"rendered":"Adding doxygen support to CMakeLists.txt"},"content":{"rendered":"\n<p>There might be a lot of discussions which build system is the best &#8211; I once decided to invest into understanding <a href=\"https:\/\/cmake.org\">cmake<\/a> and never looked back. It&#8217;s not perfect, but it&#8217;s really easy to set up a build especially a cross-platform one.<\/p>\n\n\n\n<p>There is actually no discussion that one should document his\/her source code thoroughly &#8211; you should just do it. Over a decade ago I chose to use <a href=\"http:\/\/www.doxygen.nl\">doxygen<\/a> and I also didn&#8217;t regret it. Also cross-platform and does its job.<\/p>\n\n\n\n<p>It&#8217;s actually quite easy to marry both tools since cmake provides doxygen support and here I just present shortly the steps needed to activate doxygen.<\/p>\n\n\n\n<p>First install cmake and doxygen. On Linux this packages will be provided by your distribution, on Mac OS X I would just use <a href=\"https:\/\/brew.sh\/index_de\">homebrew<\/a> (&#8220;brew install cmake doxygen&#8221;) and on Windows I actually like <a href=\"https:\/\/chocolatey.org\">chocolatey<\/a> quite a lot (&#8220;choco install doxygen.install&#8221; and &#8220;choco install  cmake&#8221;). After installation (and maybe a restart or at least rerunning the CLI) you should make sure that cmake and doxygen are installed (&#8220;cmake &#8211;version&#8221; and &#8220;doxygen &#8211;version&#8221;).<\/p>\n\n\n\n<p>Then add the following lines to you CMakeLists.txt (I added the code after the find_packages() part).<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># look for Doxygen package\nfind_package(Doxygen)\n\nif(DOXYGEN_FOUND)\n  # exclude sqlite code\n  set(DOXYGEN_EXCLUDE_PATTERNS\n        *\/sqlite3\/*\n  )\n\n  # doxygen settings can be set here, prefixed with \"DOXYGEN_\"\n  set(DOXYGEN_SOURCE_BROWSER YES)\n  set(DOXYGEN_EXTRACT_PRIVATE YES)\n  set(DOXYGEN_OUTPUT_DIRECTORY \"${PROJECT_BINARY_DIR}\/api-docs\")\n\n  # this target will only be built if specifically asked to.\n  # run \"make api-docs\" to create the doxygen documentation\n  doxygen_add_docs(\n    api-docs\n    ${PROJECT_SOURCE_DIR}\n    COMMENT \"Generate API-documents for NoteSearch.\"\n  )\nendif(DOXYGEN_FOUND)<\/pre>\n\n\n\n<p>This will create a custom target, which is not automatically run with the compilation. Which makes sense for me, since I don&#8217;t need the documentation updated all the time. If you want to create the documentation just run &#8220;make api-docs&#8221; (or similar). If you use Visual C++ there will be a project &#8220;api-docs&#8221; which you can build on demand.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There might be a lot of discussions which build system is the best &#8211; I once decided to invest into understanding cmake and never looked back. It&#8217;s not perfect, but it&#8217;s really easy to set up a build especially a cross-platform one. There is actually no discussion that one should document his\/her source code thoroughly &hellip; <a href=\"http:\/\/www.miscdebris.net\/blog\/2019\/02\/25\/adding-doxygen-support-to-cmakelists-txt\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Adding doxygen support to CMakeLists.txt<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[30,9,10,24],"tags":[],"class_list":["post-333","post","type-post","status-publish","format-standard","hentry","category-development","category-linux","category-macosx","category-windows"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6pnj-5n","_links":{"self":[{"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/posts\/333"}],"collection":[{"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/comments?post=333"}],"version-history":[{"count":3,"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/posts\/333\/revisions"}],"predecessor-version":[{"id":336,"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/posts\/333\/revisions\/336"}],"wp:attachment":[{"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/media?parent=333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/categories?post=333"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.miscdebris.net\/blog\/wp-json\/wp\/v2\/tags?post=333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}