Skip to content

cnruby/w3h1_cmake

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello, install:multi!

How to install executable on local with "Ninja Multi-Config"



@Gitter :gitter.im/cnruby
Code ID: basic_140
Code Name: Hello, install:multi!
Code Status: CircleCI

Youtube Video

Demo Video

TABLE of CONTENTS

About The Project basic_140

About The Project

Requirements

CMake Code of Project

  • CMake's "Ninja Multi-Config" Code
  • CMake's "install" Code
  • install executable commands on Project
  • install executable commands on OS

13 if(NOT CMAKE_CONFIGURATION_TYPES)
14   set(
15     CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo"
16     CACHE STRING "specifies available build types" FORCE )
17 endif()
18 if(NOT CMAKE_CROSS_CONFIGS)
19   set(                                # -DCMAKE_CROSS_CONFIGS="all"
20     CMAKE_CROSS_CONFIGS "all"
21     #CMAKE_CROSS_CONFIGS "Debug;Release;RelWithDebInfo"
22     CACHE STRING "create available config files" FORCE )
23   endif()

CMake's "Ninja Multi-Config" Code of Project

4 install(
5   TARGETS ${TARGET_NAME}
6   CONFIGURATIONS Debug
7   RUNTIME
8     DESTINATION ${RUNTIME_INSTALL_DIRECTORY}/Debug/bin
9 )
10 install(
11   TARGETS ${TARGET_NAME}
12   CONFIGURATIONS Release
13   RUNTIME
14     DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
15 )

CMake's "install" Code of Project

1 # to install executable to Project for Developer
2 cmake -G"Ninja Multi-Config" -H. -B_build
3 cmake -DCMAKE_BUILD_TYPE=Debug --build _build
4 
5 ninja -C _build main_140:Debug
6 ./_bin/Debug/main_140
7 
8 ninja -C _build install:Debug
9 ./_install/Debug/bin/main_140

install executable commands on Project

1 # to install executable from source to OS for User
2 cmake -G"Ninja Multi-Config" -H. -B_build
3 cmake -DCMAKE_DEFAULT_BUILD_TYPE=Release _build
4 
5 cmake --build _build --target main_140:Release
6 ./_bin/Release/main_140
7 
8 sudo cmake --build _build --target install:Release
9 cmake --install _build help
10 sudo cmake --install _build --config Release
11 main_140
12 #sudo ninja -C _build install:Release

install executable commands on OS

A Demonstration of Building Project

About The Project basic_140

Final Summary

感谢大家观看!

@Gitter: gitter.im/cnruby

@Github: github.com/cnruby

@Twitter: twitter.com/cnruby

@Blogspot: cnruby.blogspot.com

References

Requirements

Get The Code with Shell Commands

git clone https://github.com/cnruby/w3h1_cmake.git basic_140
cd basic_140
git checkout basic_140
code .

The Structure of Folder

.
├── cmake
│  ├── CMakeLists.txt
│  ├── config.h.in
│  ├── multi_config.cmake
│  └── targets.cmake
├── CMakeLists.txt
├── config
│  └── config.hxx
└── src
   ├── CMakeLists.txt
   ├── install.cmake
   └── main.cxx

Explain C++ and CMake Code