# build_tools **Repository Path**: fibjs/build_tools ## Basic Information - **Project Name**: build_tools - **Description**: fibjs's build_tools based on .cmake - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: dev - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-06-19 - **Last Updated**: 2025-06-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # build_tools fibjs's build_tools based on .cmake # Getting Started To use build_tools for fibjs, you need install: - CMake >= 3.0 - C/Cpp Compiler - Windows: clang/VC++ - Linux: clang - MacOS: clang To explain how to use built_tools, we try to compile [examples/hello](./examples/hello/build.cmake). All `` in codes refers to this project's root path. ### Workflow on CMake ccripts We recommend CMake script-mode as build workflow, that is, instead of bash/sh/cmd/powershell, just use CMake script to drive your build. ```CMake include(/cmake-scripts/get_env.cmake) set(WORK_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/output") set(BIN_ROOT "${WORK_ROOT}/bin") set(OUT_ROOT "${WORK_ROOT}/out") set(DIST_DIRNAME "${CMAKE_HOST_SYSTEM_NAME}_${BUILD_ARCH}_${BUILD_TYPE}") if("${CLEAN_BUILD}" STREQUAL "true") rimraf(${BIN_ROOT}/${DIST_DIRNAME}) rimraf(${OUT_ROOT}/${DIST_DIRNAME}) else() set(OUT_PATH "${OUT_ROOT}/${DIST_DIRNAME}") build("${CMAKE_CURRENT_SOURCE_DIR}" "${OUT_PATH}/hello") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test") build("${CMAKE_CURRENT_SOURCE_DIR}/test" "${OUT_PATH}/hello_test") endif() endif() ``` As of this script, `build` funciton is defined in `/cmake-scripts/get_env.cmake`. ```CMake build(src_dirname, outputpath) ``` It tried to find `/CMakeLists.txt` and run do cmake build against it. That is, you can customize by writing your own CMakeList.txt ### Create CMakeLists.txt Add one CMakeLists.txt on your project. like [examples/hello/CMakeLists.txt](./examples/hello/CMakeLists.txt). To build one **static** Library, include `cmake/Library.cmake` ```CMake cmake_minimum_required(VERSION 3.10) include(/cmake/Library.cmake) ``` Or put one CMakeLists.txt on project_root's test directory, like [examples/hello/test/CMakeLists.txt](./examples/hello/test/CMakeLists.txt). To build one **test** executation, include `cmake/LibraryTest.cmake` ```CMake cmake_minimum_required(VERSION 3.10) include(/cmake/LibraryTest.cmake) ``` ### Run CMake ```bash cmake -DBUILD_ARCH=x64\ -DBUILD_TYPE=release\ -DCLEAN_BUILD=""\ -DBUILD_JOBS=4\ -DBUILD_WITH_MSVC=1\ -P build.cmake ``` see more configuration on - [examples/hello/build](./examples/hello/build) for bash - [examples/hello/build.cmd](./examples/hello/build.cmd) for windows cmd ## Copyright [MIT](./LICENSE) License