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 projectNew Binary Project
$ cppm init --bin hello_worldGenerated 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 fileCppm 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_worldAnd the run it.
$ cd build/Debug
$ ./hello_world
hello worldEasy run command cppm run, default binary name ${[package.name]}
$ cppm run
hello worldGenerated 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