{"id":20987256,"url":"https://github.com/haxpor/cmake_example","last_synced_at":"2026-03-19T18:20:47.418Z","repository":{"id":54014051,"uuid":"194408479","full_name":"haxpor/cmake_example","owner":"haxpor","description":"Example project using CMake as build system. Included executable linking with shared library with some other configurable features of CMake.","archived":false,"fork":false,"pushed_at":"2019-06-30T11:40:10.000Z","size":26,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-20T07:42:04.443Z","etag":null,"topics":["cmake","cross-compile","example"],"latest_commit_sha":null,"homepage":null,"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/haxpor.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2019-06-29T13:25:48.000Z","updated_at":"2022-08-06T16:50:15.000Z","dependencies_parsed_at":"2022-08-13T06:01:03.064Z","dependency_job_id":null,"html_url":"https://github.com/haxpor/cmake_example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haxpor%2Fcmake_example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haxpor%2Fcmake_example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haxpor%2Fcmake_example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haxpor%2Fcmake_example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haxpor","download_url":"https://codeload.github.com/haxpor/cmake_example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243394326,"owners_count":20283945,"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","cross-compile","example"],"created_at":"2024-11-19T06:16:26.442Z","updated_at":"2026-02-04T23:37:00.822Z","avatar_url":"https://github.com/haxpor.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cmake_example\nExample project using CMake as build system. Included executable linking with shared library with some other configurable features of CMake.\n\nIt follows along with [cmake-tutorial](https://cmake.org/cmake-tutorial/) on official website of\nCMake itself but with modified and improvements.\n\n# Usage\n\n* Create a build directory i.e. `build` or any desired name\n* `cd` into such directory, then `cmake ..`\n* Now you can inspect `CMakeLists.txt`, `MathFunctions/CMakeLists.txt` and its effect towards the result of the build operation\n\n## Cross Compile\n\nCross compile is based on [mingw64](https://mingw-w64.org/doku.php).\nIts toolchain file is `mingwtoolchain.cmake` which support building for both 32 and 64 bit Windows executable.\n\nThe following is options available when using it\n\n* `BUILD_64` - whether or not to build 64-bit Windows executable. **Default** is **OFF**.\n\nExample of executing commands\n\nThis will build for 64-bit Windows executable (provided that you created a new directory outside of source tree)\n\n```\ncmake -DCMAKE_TOOLCHAIN_FILE=../mingwtoolchain.cmake -DBUILD_64=ON ..\n```\n\nThis will build for 32-bit Windows executable\n\n```\ncmake -DCMAKE_TOOLCHAIN_FILE=../mingwtoolchain.cmake -DBUILD_64=OFF ..\n```\n\nor\n\n```\ncmake -DCMAKE_TOOLCHAIN_FILE=../mingwtoolchain.cmake  ..\n```\n\n## Unit test\n\nExecute `make test` to run unit test.\n\n# Technical Note\n\n* Prevent in-source build thus you can not proceed building at project root directory, only way is to create another directory then call `cmake` from there.\n* Use `set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -DUSE_MYMATH\")` to support CMake's option which is configurable by users `USE_MYMATH`. It doesn't use `#cmakedefine` by choice, but you can still use it.\n* remember to add `enable_testing()` after adding test cases, otherwise there will be no `test` target for `Makefile`.\n\n# License\nThis project licensed under [MIT](https://github.com/haxpor/cmake_example/blob/master/LICENSE), Wasin Thonkaew\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaxpor%2Fcmake_example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaxpor%2Fcmake_example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaxpor%2Fcmake_example/lists"}