Author : csl
E-Mail : 3079625093@qq.com
[TOC]
total 17 directories, 57 filesthe file system of this project named 'preslam':
- .vscode contains the configure files for VSCode
- bin the binary output directory
- build the cmake binary directory for build
- include the include directory contains cpp head files
- lib the lib output directory
- src directory constains cpp source files
- .gitignore the gitignore file
- CMakeLists.txt the cmake file
- main.cpp the main source file
- readme.md the readme file
- void hello_slam()
/**
* @brief a no-return function to print "hello, slam!"
*/
-
# 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})
#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;
}
# 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})