1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#!/bin/bash
tmpdir=$(mktemp -d)
trap "rm -rf $tmpdir" EXIT
cd "$tmpdir"
cat >"CMakeLists.txt" <<EOF
cmake_minimum_required(VERSION 3.1)
project(test_tinyobjloader)
find_package(tinyobjloader REQUIRED)
add_executable(test_float test.cpp)
target_link_libraries(test_float tinyobjloader::tinyobjloader)
target_compile_definitions(test_float PRIVATE EXPECTED_TYPE=float)
add_executable(test_double test.cpp)
target_link_libraries(test_double tinyobjloader::tinyobjloader_double)
target_compile_definitions(test_double PRIVATE EXPECTED_TYPE=double)
EOF
cat >"test.cpp" << EOF
#include <tiny_obj_loader.h>
#include <type_traits>
int main (int argc, char** argv)
{
tinyobj::attrib_t attrib;
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
std::string warn;
std::string err;
static_assert(std::is_same<tinyobj::real_t, EXPECTED_TYPE>::value, "wrong floating point preision");
bool ok = tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, "some.obj");
return 0;
}
EOF
echo '$' cmake .
cmake .
echo '$' make VERBOSE=ON
make VERBOSE=ON
|