diff --git a/include/light/light.hh b/include/light/light.hh index 95717ac5..fb5cdd1f 100644 --- a/include/light/light.hh +++ b/include/light/light.hh @@ -394,5 +394,6 @@ const vec_t *GetSurfaceVertexNormal(const bsp2_t *bsp, const bsp2_dface_t *f, co const bsp2_dface_t *Face_EdgeIndexSmoothed(const bsp2_t *bsp, const bsp2_dface_t *f, const int edgeindex); const std::vector &BounceLights(); bool Leaf_HasSky(const bsp2_t *bsp, const bsp2_dleaf_t *leaf); +int light_main(int argc, const char **argv); #endif /* __LIGHT_LIGHT_H__ */ diff --git a/light/CMakeLists.txt b/light/CMakeLists.txt index 1803cc4a..cc946e7d 100644 --- a/light/CMakeLists.txt +++ b/light/CMakeLists.txt @@ -42,7 +42,7 @@ if (embree_FOUND) endif(embree_FOUND) -add_executable(light ${LIGHT_SOURCES}) +add_executable(light ${LIGHT_SOURCES} main.cc) target_link_libraries (light ${CMAKE_THREAD_LIBS_INIT}) if (embree_FOUND) @@ -87,3 +87,22 @@ endif(embree_FOUND) install(TARGETS light RUNTIME DESTINATION bin) install(FILES ${CMAKE_SOURCE_DIR}/gpl_v3.txt DESTINATION bin) + +# test + +set(GOOGLETEST_SOURCES ${CMAKE_SOURCE_DIR}/3rdparty/googletest/src/gtest-all.cc) +include_directories(${CMAKE_SOURCE_DIR}/3rdparty/googletest/include) +include_directories(${CMAKE_SOURCE_DIR}/3rdparty/googletest) + +set(LIGHT_TEST_SOURCE + ${LIGHT_SOURCES} + ${GOOGLETEST_SOURCES} + test.cc) + +add_executable(testlight ${LIGHT_TEST_SOURCE}) + +target_link_libraries (testlight ${CMAKE_THREAD_LIBS_INIT}) +if (embree_FOUND) + target_link_libraries (testlight ${EMBREE_LIBRARY}) + add_definitions(-DHAVE_EMBREE) +endif (embree_FOUND) diff --git a/light/light.cc b/light/light.cc index a0e6a269..05ffb692 100644 --- a/light/light.cc +++ b/light/light.cc @@ -1346,7 +1346,7 @@ static const char *ParseString(int *i_inout, int argc, const char **argv) * ================== */ int -main(int argc, const char **argv) +light_main(int argc, const char **argv) { bspdata_t bspdata; bsp2_t *const bsp = &bspdata.data.bsp2; diff --git a/light/main.cc b/light/main.cc new file mode 100644 index 00000000..163fe6fb --- /dev/null +++ b/light/main.cc @@ -0,0 +1,25 @@ +/* Copyright (C) 1996-1997 Id Software, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + See file, 'COPYING', for details. +*/ + +#include + +int main(int argc, const char **argv) +{ + return light_main(argc, argv); +} diff --git a/light/test.cc b/light/test.cc new file mode 100644 index 00000000..4483c91a --- /dev/null +++ b/light/test.cc @@ -0,0 +1,6 @@ +#include "gtest/gtest.h" + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}