fixed CMake dependant header file generation
authorAdam Kosiorek <a.kosiorek@samsung.com>
Tue, 22 Jul 2014 12:44:19 +0000 (14:44 +0200)
committerJeff Donahue <jeff.donahue@gmail.com>
Sun, 17 Aug 2014 08:07:16 +0000 (01:07 -0700)
include/caffe/test/test_caffe_main.hpp
src/caffe/test/CMakeLists.txt
src/caffe/test/test_caffe_main.hpp [deleted file]

index 40b9eff..e02e67e 100644 (file)
 using std::cout;
 using std::endl;
 
+#ifdef CMAKE_BUILD
+  #include <cmake_test_defines.hpp.gen.cmake>
+#else
+  #define CUDA_TEST_DEVICE -1
+  #define CMAKE_SOURCE_DIR "src/"
+  #define Examples_SOURCE_DIR "examples/"
+  #define CMAKE_EXT ""
+#endif
+
 int main(int argc, char** argv);
 
 namespace caffe {
index 721df27..f64d5da 100644 (file)
@@ -8,18 +8,41 @@ project( Test )
 
 #    Set CUDA Device number and CMAKE_SOURCE_DIR
 add_definitions(-DCMAKE_BUILD)
-configure_file(
-    ${CMAKE_CURRENT_SOURCE_DIR}/cmake_test_defines.hpp.in
-    ${CMAKE_CURRENT_SOURCE_DIR}/cmake_test_defines.hpp.gen.cmake
-)
 
-configure_file(
-    ${CMAKE_CURRENT_SOURCE_DIR}/test_data/sample_data_list.txt.in
-    ${CMAKE_CURRENT_SOURCE_DIR}/test_data/sample_data_list.txt.gen.cmake
+#    Generate config files
+set(IN_EXT .in)
+set(GEN_EXT .gen.cmake)
+set(TEST_DEFINES_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake_test_defines.hpp)
+set(TEST_DATA_FILE ${CMAKE_CURRENT_SOURCE_DIR}/test_data/sample_data_list.txt)
+
+set(IN_FILES 
+    ${TEST_DEFINES_FILE}
+    ${TEST_DATA_FILE}
 )
 
+foreach(in_file ${IN_FILES})
+    
+    configure_file(
+        ${in_file}${IN_EXT}
+        ${in_file}${GEN_EXT}
+    )
+    
+endforeach()       
+
+
+#configure_file(
+#    ${CMAKE_CURRENT_SOURCE_DIR}/cmake_test_defines.hpp.in
+#    ${CMAKE_CURRENT_SOURCE_DIR}/cmake_test_defines.hpp.gen.cmake
+#)
+#
+#configure_file(
+#    ${CMAKE_CURRENT_SOURCE_DIR}/test_data/sample_data_list.txt.in
+#    ${CMAKE_CURRENT_SOURCE_DIR}/test_data/sample_data_list.txt.gen.cmake
+#)
+
 include_directories(
         ${Caffe_SOURCE_DIR}
+        ${CMAKE_CURRENT_SOURCE_DIR}
 )
 
 set(TEST_MAIN test_caffe_main.cpp)
diff --git a/src/caffe/test/test_caffe_main.hpp b/src/caffe/test/test_caffe_main.hpp
deleted file mode 100644 (file)
index 76f50be..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2014 BVLC and contributors.
-
-// The main caffe test code. Your test cpp code should include this hpp
-// to allow a main function to be compiled into the binary.
-#ifndef CAFFE_TEST_TEST_CAFFE_MAIN_HPP_
-#define CAFFE_TEST_TEST_CAFFE_MAIN_HPP_
-
-#include <cuda_runtime.h>
-#include <glog/logging.h>
-#include <gtest/gtest.h>
-
-#include <cstdlib>
-#include <cstdio>
-
-using std::cout;
-using std::endl;
-
-#ifdef CMAKE_BUILD
-       #include "cmake_test_defines.hpp.gen.cmake"
-#else
-       #define CUDA_TEST_DEVICE -1
-       #define CMAKE_SOURCE_DIR "src/"
-       #define Examples_SOURCE_DIR "examples/"
-       #define CMAKE_EXT ""
-#endif
-
-int main(int argc, char** argv);
-
-#endif  // CAFFE_TEST_TEST_CAFFE_MAIN_HPP_