{"id":13732427,"url":"https://github.com/sakra/cotire","last_synced_at":"2025-10-26T08:31:33.712Z","repository":{"id":2694769,"uuid":"3687959","full_name":"sakra/cotire","owner":"sakra","description":"CMake module to speed up builds.","archived":false,"fork":false,"pushed_at":"2019-12-23T15:00:32.000Z","size":563,"stargazers_count":1301,"open_issues_count":70,"forks_count":143,"subscribers_count":64,"default_branch":"master","last_synced_at":"2024-12-18T23:13:04.414Z","etag":null,"topics":["cmake"],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sakra.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-11T16:36:51.000Z","updated_at":"2024-12-16T02:37:40.000Z","dependencies_parsed_at":"2022-07-09T19:00:51.622Z","dependency_job_id":null,"html_url":"https://github.com/sakra/cotire","commit_stats":null,"previous_names":[],"tags_count":57,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakra%2Fcotire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakra%2Fcotire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakra%2Fcotire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakra%2Fcotire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sakra","download_url":"https://codeload.github.com/sakra/cotire/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238298397,"owners_count":19448925,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmake"],"created_at":"2024-08-03T02:01:56.091Z","updated_at":"2025-10-26T08:31:33.408Z","avatar_url":"https://github.com/sakra.png","language":"CMake","readme":"cotire\n======\n\nCotire (compile time reducer) is a CMake module that speeds up the build process of CMake based\nbuild systems by fully automating techniques as [precompiled header][pch] usage and\n[single compilation unit][scu] builds for C and C++.\n\nThe functionality provided by cotire has been superseded by features added to [CMake 3.16][cmkr].\nSupport for [pre-compiling][cpch] and [unity builds][cscu] is now built into CMake. Thus, there\nwill not be any further updates or support for this project.\n\nfeatures\n--------\n\n* Non-intrusive. Requires no source code modification and only minimal changes to CMake list files.\n* Automatically generates a [single compilation unit][scu] (aka unity source file) for a CMake target.\n* Automatically generates a [prefix header][pfh] by tracking includes used by a CMake target.\n* Automatically precompiles prefix header and applies resulting [precompiled header][pch] to a CMake target.\n* Alternatively, allows for using manually maintained unity source and prefix header files.\n* Supports C/C++ compilers Clang, GCC, Intel and Visual Studio C++.\n* Supports mixed language CMake targets.\n* Supports console (Makefile generator) and IDE (Visual Studio and Xcode) based builds.\n* Compatible with CMake single build type and CMake multi-configuration builds.\n* Compatible with most CMake generators (including [Ninja][ninja]).\n* Supports multi-core unity builds for some generators (make -j, [jom][jom], Visual Studio, Ninja).\n* Leverages native precompiled header generation features of IDEs (Visual Studio and Xcode).\n* Compatible with CMake's [cross-compiling][ccrc] support.\n* Compatible with compiler wrappers like [ccache][ccch].\n* Tested with Windows, Linux and OS X.\n* MIT licensed.\n\nrequirements\n------------\n\n* [CMake 2.8.12][cmk] or newer. The executable `cmake` should be on the system path.\n* [Visual Studio C++][vslstd], [MinGW][mingw] or [Cygwin][cgwn] under Windows.\n* [Clang][clang] under Windows, Linux or OS X.\n* [GCC][gcc] under Linux or OS X.\n* [Intel C++ compiler][intel] under Windows, Linux or OS X.\n* [Xcode][xcdt] application or Xcode Command Line Tools under OS X.\n\ninstallation\n------------\n\nCopy the file `CMake/cotire.cmake` to the module directory of your CMake project. In the\ntop-level `CMakeList.txt` file, add the module directory to the CMake module search path:\n\n    set (CMAKE_MODULE_PATH \"${CMAKE_SOURCE_DIR}/CMake\")\n\nusage\n-----\n\nTo use cotire in your CMake project, add the following include directive to the beginning of the\ntop-level `CMakeList.txt`:\n\n    include(cotire)\n\nTo speed the build process of a CMake library or executable target, just apply the `cotire`\nfunction to the target:\n\n    add_executable(MyExecutable ${MyExecutableSources})\n    target_link_libraries(MyExecutable ${MyExecutableLibraries})\n    cotire(MyExecutable)\n\nCotire looks at the properties of the target provided by CMake (e.g., target type, source files,\ncompile flags, preprocessor defines, include directories, ...) and sets up custom commands that\nwill generate a unity source file, a prefix header and a precompiled header at build time\nspecially tailored to the target.\n\nFor the generation of the prefix header, cotire will automatically choose headers used by the\ntarget that are outside of the project directory and thus are likely to change infrequently.\nThe precompiled prefix header is then applied to the target to speed up the compilation process.\n\nTo use an existing manually maintained prefix header instead of the automatically generated one,\nset the `COTIRE_CXX_PREFIX_HEADER_INIT` property before invoking cotire:\n\n    set_target_properties(MyExecutable PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT \"stdafx.h\")\n    cotire(MyExecutable)\n\nAs a side effect, cotire generates a new target named `MyExecutable_unity`, which lets you perform\na unity build for the original target. The unity target inherits all build settings from the\noriginal target, including linked library dependencies.\n\nFor Makefile based generators you can then invoke a unity build that produces the same output as\nthe original target, but does so much faster by entering:\n\n    $ make MyExecutable_unity\n\nSee the advanced usage section of the [cotire manual][manual] for information on how to\nconfigure the cotire process (e.g., how to make the unity build use all available processor\ncores).\n\nThe directory `Patches` contains patch files to enable cotire for some popular open sources\npackages that use CMake as a build system.\n\nspeedup\n-------\n\nDepending on factors like hardware, compiler, the number of files in the target and the complexity\nof the C/C++ code, the build process of targets that use a cotire generated precompiled header\nwill be sped up from 10 to 40 percent. Using precompiled headers however is not without\n[issues][PCHH] and may not work for some programs.\n\nA unity build may be up to 90 percent faster than the one file at a time build of the original\ntarget. Single compilation unit builds however are very unlikely to work without source code\nmodifications, because they [break][EoUB] the use of some C and C++ language features.\n\nGenerally, modern C++ code which makes heavy use of header-only libraries will profit the most from\ncotiring.\n\nThis [blog post][shrp] discusses speedup results obtained for real-world projects.\n\nknown issues\n------------\n\n* CMake configure time will increase for cotired targets.\n* The size of the CMake build folder will increase, because precompiled headers are large binaries.\n* It is not possible to share precompiled headers generated by cotire between CMake targets.\n  Multiple targets can share a generated prefix header, though (see the [cotire manual][manual]).\n* Cotire is not compatible with [Xoreax IncrediBuild][XGE].\n\n[ccch]:https://ccache.samba.org/\n[ccrc]:https://cmake.org/Wiki/CMake_Cross_Compiling\n[cgwn]:https://www.cygwin.com/\n[clang]:https://clang.llvm.org/\n[cmk]:https://cmake.org/download/\n[gcc]:https://gcc.gnu.org/\n[manual]:https://github.com/sakra/cotire/blob/master/MANUAL.md\n[mingw]:http://www.mingw.org/\n[ninja]:https://ninja-build.org/\n[pch]:https://en.wikipedia.org/wiki/Precompiled_header\n[pfh]:https://en.wikipedia.org/wiki/Prefix_header\n[scu]:https://en.wikipedia.org/wiki/Single_Compilation_Unit\n[vslstd]:https://www.visualstudio.com/\n[xcdt]:https://developer.apple.com/xcode/\n[PCHH]:https://gcc.gnu.org/wiki/PCHHaters\n[EoUB]:http://altdevblog.com/2011/08/14/the-evils-of-unity-builds/\n[jom]:https://wiki.qt.io/Jom\n[intel]:https://software.intel.com/en-us/c-compilers\n[XGE]:https://www.incredibuild.com/\n[shrp]:https://unriskinsight.blogspot.co.at/2014/09/sharpen-your-tools.html\n[cmkr]:https://cmake.org/cmake/help/latest/release/3.16.html\n[cpch]:https://cmake.org/cmake/help/latest/command/target_precompile_headers.html\n[cscu]:https://cmake.org/cmake/help/v3.16/prop_tgt/UNITY_BUILD.html\n","funding_links":[],"categories":["Utility Scripts","Tools"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakra%2Fcotire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsakra%2Fcotire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakra%2Fcotire/lists"}