How to construct CMakeLists.txt to use ceres sovler

CMakeLists.txt 파일 κ΅¬μ„±ν•˜κΈ°

Ceres solverλ₯Ό μ„€μΉ˜ν•˜κ³  μ•„λž˜μ™€ 같이 λΉŒλ“œ μ½”λ”© ν›„ λΉŒλ“œν•΄λ³΄μž

1. Code Skeleton

#include <ceres/ceres.h>
#include <glog/logging.h>

using ceres::Problem;

int main(int argc, char** argv)
{
  // The variable to solve for with its initial value. It will be
  // mutated in place by the solver.
  double       x         = 0.5;
  const double initial_x = x;

  // Build the problem.
  Problem problem;

  return 0;
}

λ¬Έμ œκ°€ 없이 λΉŒλ“œ λ˜μ—ˆλ‹€λ©΄ 이 κ²Œμ‹œλ¬Όμ„ κ±΄λ„ˆλ›°μž!
λ‚˜λŠ” λΉŒλ“œμ‘°μ°¨ λ˜μ§€ μ•Šμ•„μ„œ κ½€λ‚˜ 고생을 ν–ˆλ‹€

2. CMakeLists.txt

# cmake μ΅œμ†Œ 버전을 적어쀀닀
cmake_minimum_required(VERSION 2.8.3)

# project 이름을 적어쀀닀 [띄어쓰기 κΈˆμ§€]
project(my_proj)

# C++ 11둜 μ»΄νŒŒμΌν•˜κ² λ‹€λŠ” λœ»μ΄λ‹€!
# ceresλ₯Ό λΉŒλ“œν•˜λŠ” κ³Όμ •μ—μ„œ μ—λŸ¬κ°€ λ‚˜μ„œ ν•΄κ²°ν–ˆλ˜ 방법이닀
set(CMAKE_CXX_STANDARD 11)

# μ•„λž˜ λͺ…령을 μˆœμ„œλŒ€λ‘œ μž…λ ₯ν•΄μ€€λ‹€
find_package(Ceres REQUIRED)

include_directories(${CERES_INCLUDE_DIRS})

add_executable(main src/main.cpp)
target_link_libraries(main ${CERES_LIBRARIES})

μœ„μ™€ 같이 μ„ μ–Έν•˜λ©΄ λ¬Έμ œμ—†μ΄ λΉŒλ“œλ  것이닀 !

Reference

Leave a comment