Skip to content

Latest commit

 

History

History

chp2-pre-slam

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

chp2-pre-slam

Author : csl

E-Mail : 3079625093@qq.com

[TOC]

1. Project Structure

total 17 directories, 57 files

the file system of this project named 'preslam':

2. Main Apis

1. CPP

  • void hello_slam()
/**
 * @brief a no-return function to print "hello, slam!"
 */

2. CMake

  • # Sets the minimum required version of cmake
    cmake_minimum_required(VERSION 3.10)
  • # Set the name of the project
    project(preslam VERSION 0.0.1)
  • # Add include directories to the build
    include_directories(${CMAKE_SOURCE_DIR}/include)
  • # Add a library to the project using the 'helloslam.cpp'
    add_library(${LIB_NAME} SHARED ${CMAKE_SOURCE_DIR}/src/helloslam.cpp)
  • # Add an executable to the project using the 'main.cpp'
    add_executable(${CMAKE_PROJECT_NAME} ${CMAKE_SOURCE_DIR}/main.cpp)
  • # link the lib to the executable
    target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE  ${LIB_NAME})

3. Source Code

1. CPP

#pragma once

#include <iostream>

namespace ns_chp2 {
/**
 * @brief a no-return function to print "hello, slam!"
 */
void hello_slam();
}  // namespace ns_chp2
#include "helloslam.h"

namespace ns_chp2 {
void hello_slam() {
  // print "Hello, slam!"
  std::cout << "Hello, slam!" << std::endl;
  return;
}
}  // namespace ns_chp2
#include "helloslam.h"

int main(int argc, char const *argv[]) {
  // call 'hello_slam'
  ns_chp2::hello_slam();
  return 0;
}

2. CMake

# Sets the minimum required version of cmake
cmake_minimum_required(VERSION 3.10)

# Set the name of the project
project(preslam VERSION 0.0.1)

# Add include directories to the build
include_directories(${CMAKE_SOURCE_DIR}/include)

# Set a environment variable to the lib name
set(LIB_NAME helloslam)

# set the lib output directory
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)

# set the bin output directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)

# Add a library to the project using the 'helloslam.cpp'
add_library(${LIB_NAME} SHARED ${CMAKE_SOURCE_DIR}/src/helloslam.cpp)

# Add an executable to the project using the 'main.cpp'
add_executable(${CMAKE_PROJECT_NAME} ${CMAKE_SOURCE_DIR}/main.cpp)

# link the lib to the executable
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE  ${LIB_NAME})