summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Lundborg <lundborg.magnus@gmail.com>2012-12-14 12:00:49 (GMT)
committerMagnus Lundborg <lundborg.magnus@gmail.com>2012-12-14 12:00:49 (GMT)
commitd0c948844f398f291c1d014ff1a2791414b74d9c (patch)
treec397827fd1dff67cb7bba0ac422a26efe6ace6da
parentdd767425b489541585c526ebfb629538269afd54 (diff)
Copy example files to build directory and set constants to find them
-rw-r--r--CMakeLists.txt4
-rw-r--r--INSTALL6
-rw-r--r--src/tests/CMakeLists.txt5
-rw-r--r--src/tests/tng_io_testing.c20
-rw-r--r--src/tests/tng_io_testing.h.in6
5 files changed, 30 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ba7b366..c459d69 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.6)
+cmake_minimum_required(VERSION 2.8)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
@@ -8,6 +8,8 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
add_subdirectory(src)
+file(COPY example_files DESTINATION .)
+
#-- Add an Option to toggle the generation of the API documentation
option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" OFF)
if(BUILD_DOCUMENTATION)
diff --git a/INSTALL b/INSTALL
index 8253479..b63fd35 100644
--- a/INSTALL
+++ b/INSTALL
@@ -10,12 +10,6 @@ bin/tng_testing
No system wide installations are made yet (no 'make install'), which means that
programs using the library must specify explicitly where to look for it.
-(currently 'bin/tng_testing' requires a tng_example.tng in the directory
- the command is invoked. This will be fixed soon:
-
- cp ../example_files/tng_example.tng .
-
- )
Useful cmake flags:
-DBUILD_DOCUMENTATION=ON to build the API documentation (requires doxygen)
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 9b9afe5..6747eb6 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -1,5 +1,10 @@
include_directories(${TRAJECTORY_SOURCE_DIR}/src/lib)
link_directories(${TRAJECTORY_BINARY_DIR}/src/lib)
+set(EXAMPLE_FILES_DIR ${CMAKE_BINARY_DIR}/example_files/ CACHE STRING "Directory where to find input test files and save output files.")
+
+configure_file(tng_io_testing.h.in ${CMAKE_BINARY_DIR}/generated/tng_io_testing.h)
+include_directories(${CMAKE_BINARY_DIR}/generated/)
+
add_executable(tng_testing tng_io_testing.c)
target_link_libraries(tng_testing tng_io) \ No newline at end of file
diff --git a/src/tests/tng_io_testing.c b/src/tests/tng_io_testing.c
index 34234ec..1506f68 100644
--- a/src/tests/tng_io_testing.c
+++ b/src/tests/tng_io_testing.c
@@ -2,9 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include "tng_io.h"
-
-
-
+#include "tng_io_testing.h"
static tng_function_status tng_test_setup_molecules(tng_trajectory_t traj)
{
@@ -301,7 +299,11 @@ static tng_function_status tng_test_write_and_read_traj(tng_trajectory_t traj)
free(data);
tng_trajectory_destroy(traj);
+#ifdef EXAMPLE_FILES_DIR
+ tng_input_file_set(traj, EXAMPLE_FILES_DIR "tng_test.tng");
+#else
tng_input_file_set(traj, "/tmp/tng_test.tng");
+#endif
stat = tng_file_headers_read(traj, TNG_SKIP_HASH);
@@ -407,9 +409,15 @@ int main()
tng_time_get_str(&traj, time_str);
printf("Creation time: %s\n", time_str);
-
+
+#ifdef EXAMPLE_FILES_DIR
+ tng_input_file_set(&traj, EXAMPLE_FILES_DIR "tng_example.tng");
+ tng_output_file_set(&traj, EXAMPLE_FILES_DIR "tng_example_out.tng");
+#else
tng_input_file_set(&traj, "tng_example.tng");
tng_output_file_set(&traj, "/tmp/tng_example_out.tng");
+#endif
+
// if(tng_test_endianness(&traj) != TNG_SUCCESS)
// {
@@ -448,7 +456,11 @@ int main()
}
+#ifdef EXAMPLE_FILES_DIR
+ tng_output_file_set(&traj, EXAMPLE_FILES_DIR "tng_test.tng");
+#else
tng_output_file_set(&traj, "/tmp/tng_test.tng");
+#endif
if(tng_test_write_and_read_traj(&traj) == TNG_CRITICAL)
{
diff --git a/src/tests/tng_io_testing.h.in b/src/tests/tng_io_testing.h.in
new file mode 100644
index 0000000..b0d45a1
--- /dev/null
+++ b/src/tests/tng_io_testing.h.in
@@ -0,0 +1,6 @@
+#ifndef _TNG_IO_TESTING_H
+#define _TNG_IO_TESTING_H
+
+#define EXAMPLE_FILES_DIR "@EXAMPLE_FILES_DIR@"
+
+#endif \ No newline at end of file
contact: Jan Huwald // Impressum