Skip to content

Commit c8747ec

Browse files
committed
Make CMake out-of-tree builds work. GPUE srcs must remain at build location, but gpue binary now relocatable with unit tests
1 parent 30180de commit c8747ec

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ set(
88
-O3 -gencode arch=compute_37,code=sm_37 -lcufft -fopenmp
99
)
1010

11+
find_file( EXAMPLE_CFG example.cfg src/ )
12+
add_library(unitTest OBJECT src/unit_test.cu include/unit_test.h include/kernels.h)
13+
set( CFG_FILE_PATH _CFG_FILE_PATH="${EXAMPLE_CFG}" )
14+
target_compile_options(
15+
unitTest PRIVATE -D${CFG_FILE_PATH} -dc
16+
)
17+
1118
add_executable(
1219
gpue
1320
src/dynamic.cu
@@ -54,8 +61,7 @@ add_executable(
5461
src/tracker.cu
5562
include/tracker.h
5663

57-
src/unit_test.cu
58-
include/unit_test.h
64+
$<TARGET_OBJECTS:unitTest>
5965

6066
src/vort.cu
6167
include/vort.h

src/unit_test.cu

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <cufft.h>
1111
#include <vector>
1212
#include <fstream>
13+
#include <sstream>
1314

1415
// Adding tests for mathematical operator kernels
1516
void math_operator_test();
@@ -380,8 +381,17 @@ void dynamic_test(){
380381
}
381382

382383
// Now testing simple parsing of example "example.cfg"
384+
#ifdef _CFG_FILE_PATH
385+
std::stringstream ss;
386+
ss << _CFG_FILE_PATH;
387+
std::string cfg_path;
388+
ss >> cfg_path;
389+
#else
390+
std::string cfg_path = "src/example.cfg";
391+
#endif
392+
383393
std::cout << "Testing simple parameter parsing." << '\n';
384-
par.store("param_file", (std::string)"src/example.cfg");
394+
par.store("param_file", cfg_path);
385395
parse_param_file(par);
386396
EqnNode_gpu *eqn = par.astval("V");
387397
find_field<<<grid, threads>>>(array_gpu, 0.1, 0.1, 0.1, 1, 1, 1, 0, eqn);

0 commit comments

Comments
 (0)