Skip to content

Latest commit

Β 

History

History
193 lines (178 loc) Β· 5.76 KB

File metadata and controls

193 lines (178 loc) Β· 5.76 KB

First Steps with Cppm

To start a new package with Cppm, use cppm init

$ cppm init -h  
Usage:
   cppm init [--verbose]

Option:
   --bin [-b] {name}               :initialize new c++ binary project
   --help [-h]                     :show cppm commands and options
   --lib [-l] {name}               :initialize new c++ library project

New Binary Project

$ cppm init --bin hello_world

Generated project

$ cd hello_world
$ tree .  
.
|-- build  # Build directory
|   |-- Debug   # Debug mode target directory 
|   `-- Release # Release mode target directory
|-- cmake    # cmake module path
|   |-- Modules  # cmake Find*.cmake path
|   `-- cppm_tool.cmake # cppm_tool load tool
|-- cppm.toml
|-- include   # public header
|-- src       # private header and sources
|   `-- main.cpp
`-- thirdparty # cppkg config and file path
    `-- ${cppkg_name}/${cppkg_version}/cppkg.toml  # cppkg config file

Cppm project config file

# cppm.toml
[package]
   name = "hello_world"
   version = "0.0.1"
   description = ""

[[bin]]
   name = "hello_world"
   source = ["src/.*"]

Generated defualt cpp file

// src/main.cpp
#include <iostream>
int main(int argc, char* argv[]) {
    std::cout<<"hello world"<<std::endl;
    return 0; 
} 

Compile "hello_world" project with cppm build, this command generate CMakeLists.txt

$ cppm build
[cppm] Generate CMakeLists.txt
From https://github.com/injae/cppm_tools
   1c79dca..00fb374  0.0.9      -> origin/0.0.9
-- [cppm] cppm_tools-0.0.9 download to /home-path/.cppm/src/cppm_tools/0.0.9
-- The C compiler identification is Clang 9.0.0
-- The CXX compiler identification is Clang 9.0.0
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- [cppm] Target: hello_world [Type:debug, Cppm:0.0.9, CMake:3.16.2]
-- [cppm] System: x86_64-Darwin-19.3.0
-- [cppm] Compiler: Clang-9.0.0
-- [cppm] Generator: Unix Makefiles
-- [cppm] Build Cache: ccache
-- [cppm] cppm_root: /path/to/.cppm
-- [cppm] c++ version: 17
-- [cppm] Compiler Option: -std=c++17 -Wall -fPIC -O0 -g
-- Configuring done
-- Generating done
-- Build files have been written to: /path/to/hello_world/build
Scanning dependencies of target hello_world
[ 50%] Building CXX object CMakeFiles/hello_world.dir/src/main.cpp.o
[100%] Linking CXX executable hello_world
[100%] Built target hello_world

And the run it.

$ cd build/Debug
$ ./hello_world
hello world

Easy run command cppm run, default binary name ${[package.name]}

$ cppm run
hello world

Generated CMakeLists.txt

cmake_minimum_required(VERSION 3.12)

include(cmake/cppm_tool.cmake)
cppm_project()
project(hello_world VERSION 0.0.1 LANGUAGES C CXX)
cppm_setting()

cppm_cxx_standard(17)
cppm_compiler_option(DEFAULT)

cppm_target_define(hello_world BINARY 
SOURCES 
        src/main.cpp
)

cppm_target_dependencies(hello_world)

cppm_target_install(hello_world)

Changed project Directory

$ tree .
.
β”œβ”€β”€ CMakeLists.txt
β”œβ”€β”€ build
β”‚Β Β  β”œβ”€β”€ CMakeCache.txt
β”‚Β Β  β”œβ”€β”€ CMakeFiles
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ 3.17.1
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CMakeCCompiler.cmake
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CMakeCXXCompiler.cmake
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CMakeDetermineCompilerABI_C.bin
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CMakeDetermineCompilerABI_CXX.bin
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CMakeSystem.cmake
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CompilerIdC
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CMakeCCompilerId.c
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ a.out
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  └── tmp
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── CompilerIdCXX
β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ CMakeCXXCompilerId.cpp
β”‚Β Β  β”‚Β Β  β”‚Β Β      β”œβ”€β”€ a.out
β”‚Β Β  β”‚Β Β  β”‚Β Β      └── tmp
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CMakeDirectoryInformation.cmake
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CMakeOutput.log
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CMakeTmp
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Makefile.cmake
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Makefile2
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ TargetDirectories.txt
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ cmake.check_cache
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ progress.marks
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ hello_world.dir
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CXX.includecache
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ DependInfo.cmake
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ build.make
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ cmake_clean.cmake
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ depend.internal
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ depend.make
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ flags.make
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ link.txt
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ progress.make
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── src
β”‚Β Β  β”‚Β Β  β”‚Β Β      └── main.cpp.o
β”‚Β Β  β”‚Β Β  └── hello_world_info.dir
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ DependInfo.cmake
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ build.make
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ cmake_clean.cmake
β”‚Β Β  β”‚Β Β      └── progress.make
β”‚Β Β  β”œβ”€β”€ Debug
β”‚Β Β  β”‚Β Β  └── hello_world  # Binary or Library export Directory
β”‚Β Β  β”œβ”€β”€ Makefile
β”‚Β Β  β”œβ”€β”€ cmake_install.cmake
β”‚Β Β  └── compile_commands.json
β”œβ”€β”€ cmake
β”‚Β Β  β”œβ”€β”€ Modules
β”‚Β Β  └── cppm_tool.cmake
β”œβ”€β”€ cppm.toml
β”œβ”€β”€ include
β”œβ”€β”€ src
β”‚Β Β  └── main.cpp
└── thirdparty