Thanks Matthias,

What I've tried is to 
ADD_DEFINITION(-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}) in the 
CMakeLists.txt in the test directory. I tried tesing SOURCE_DIR in *.cc 
file like: std::cout << SOURCE_DIR << std::endl;

When I did "make", screen printout shows: 
"<command line>:2:20: note: expanded from here

#define SOURCE_DIR /Users/GrillCheese/UCB/Research/xtrans/tests/mesh

Following that it has errors like:

*/Users/GrillCheese/UCB/Research/xtrans/tests/mesh/mesh_generator_01.cc:57:17: 
**error: **expected expression*

 std::cout << (SOURCE_DIR) << std::endl;
and

*/Users/GrillCheese/UCB/Research/xtrans/tests/mesh/mesh_generator_01.cc:57:17: 
**error: **use of undeclared identifier 'Users'*

*<command line>:2:21: **note: *expanded from here

#define SOURCE_DIR /Users/GrillCheese/UCB/Research/xtrans/tests/mesh
and other same type of error saying "use of undeclared identifier 'xxx'" 
where xxx can be GrillCheese, UCB, Research etc.

Anything obviously wrong to you?

Thanks,
Weixiong



在 2018年2月5日星期一 UTC-8下午9:25:22,Matthias Maier写道:
>
>
> On Mon, Feb  5, 2018, at 22:15 CST, Weixiong Zheng <zwxn...@gmail.com 
> <javascript:>> wrote: 
>
> > Hello All, 
> > 
> > I am trying to get unit test work for my project. It works until 
> reaching 
> > the point of reading input data. I tried to specify the directory using 
> > getcwd() though it didn't work with ctest. I noticed there was another 
> user 
> > having the same issue and the resolution was to use SOURCE_DIR directly 
> in 
> > *.cc file. It turns out it was not recognized. Any quick idea how to fix 
> it 
> > would be appreciated. Thanks! 
>
> SOURCE_DIR is defined when compiling the *.cc file of a test [1]. For 
> example, if you have the test layout 
>
>   my_test.cc 
>   my_test.output 
>
> and you call DEAL_II_PICKUP_TESTS() in that subdirectory. In that case 
> the my_test.cc file will be compiled with a compiler flag similar to 
>
>  -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} 
>
> It is not available in any other compilation unit (i.e. *.cc file). Or 
> for the second class of tests where you specify a *.prm file [2]. 
>
> Best, 
> Matthias 
>
> [1] The SOURCE_DIR preprocessor definition is set up in line 266 of the 
> macro cmake/macros/macro_deal_ii_add_test.cmake. 
>
> [2] In this case a test gets the full path to the parameter file as 
> first argument. So simply stripping of the filename should be enough to 
> get the source directory of the tests. 
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to