mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-31 01:20:38 +08:00
032d5844c2
This patch integrates the code generation module into the build system. All depenendcies are tracked through CMake targets. Modifying the cost functor will automatically trigger code re-generation. All this functionality is defined in the CMake function ceres_generate_cost_function_implementation_for_functor in CeresCodeGeneration.cmake. A hello world usage example is included in examples/CMakeLists.txt. Change-Id: I23b8b6698d1ea51cf3d788a47afcf39f8c5ce327
28 lines
764 B
Plaintext
28 lines
764 B
Plaintext
// This file is generated by Ceres autodiff code generation."
|
|
// http://ceres-solver.org/
|
|
|
|
#include <cstdlib>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "ceres/codegen/generate_code_for_functor.h"
|
|
#include "@COST_FUNCTOR_INPUT_FILE@"
|
|
|
|
int main() {
|
|
const std::vector<std::string> lines =
|
|
ceres::GenerateCodeForFunctor<@FULL_CXX_FUNCTOR_TYPE_NAME@>(
|
|
ceres::AutoDiffCodeGenOptions());
|
|
const std::string output_file = "@GENERATED_EVALUATION_IMPL_FILE@";
|
|
std::ofstream stream(output_file);
|
|
if (!stream.is_open()) {
|
|
std::cerr << "Could not open file " << output_file << std::endl;
|
|
return EXIT_FAILURE;
|
|
}
|
|
for (auto line : lines) {
|
|
stream << line << std::endl;
|
|
}
|
|
return EXIT_SUCCESS;
|
|
}
|