Improve adding RapidJSON include dirs to tests
* Also check for `RapidJSON_INCLUDE_DIRS` which seems to be used now * Do not add `-I` without subsequent path if the include directory is missing/empty which would lead to the Clang error: `error: unable to handle compilation, expected exactly one compiler job in ''`
This commit is contained in:
parent
f21f255e94
commit
fecde7d2d1
|
@ -94,7 +94,13 @@ endif ()
|
|||
# add paths for include dirs of c++utilities and RapidJSON to config header so test cases can use it
|
||||
set(META_CUSTOM_CONFIG "#define CPP_UTILITIES_INCLUDE_DIRS \"${CPP_UTILITIES_INCLUDE_DIRS}\"\n")
|
||||
if (RapidJSON_FOUND)
|
||||
string(APPEND META_CUSTOM_CONFIG "#define RAPIDJSON_INCLUDE_DIRS \"${RAPIDJSON_INCLUDE_DIRS}\"\n")
|
||||
# add include dirs either from RapidJSON_INCLUDE_DIRS or RAPIDJSON_INCLUDE_DIRS
|
||||
if (RapidJSON_INCLUDE_DIRS)
|
||||
set(RAPIDJSON_INCLUDE_DIRS ${RapidJSON_INCLUDE_DIRS})
|
||||
endif ()
|
||||
if (RAPIDJSON_INCLUDE_DIRS)
|
||||
string(APPEND META_CUSTOM_CONFIG "#define RAPIDJSON_INCLUDE_DIRS \"${RAPIDJSON_INCLUDE_DIRS}\"\n")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# add path of Clang's resource dir to config header so test cases can use it
|
||||
|
|
|
@ -66,8 +66,11 @@ void JsonGeneratorTests::testGeneratorItself()
|
|||
{
|
||||
const string inputFilePath(testFilePath("some_structs.h"));
|
||||
const vector<const char *> inputFiles{ inputFilePath.data() };
|
||||
const vector<string> clangOptions{ "-resource-dir", REFLECTION_GENERATOR_CLANG_RESOURCE_DIR, "-I", CPP_UTILITIES_INCLUDE_DIRS, "-I",
|
||||
RAPIDJSON_INCLUDE_DIRS };
|
||||
const vector<string> clangOptions{ "-resource-dir", REFLECTION_GENERATOR_CLANG_RESOURCE_DIR, "-I", CPP_UTILITIES_INCLUDE_DIRS,
|
||||
#ifdef RAPIDJSON_INCLUDE_DIRS
|
||||
"-I", RAPIDJSON_INCLUDE_DIRS
|
||||
#endif
|
||||
};
|
||||
|
||||
stringstream buffer;
|
||||
JsonSerializationCodeGenerator::Options jsonOptions;
|
||||
|
@ -90,9 +93,12 @@ void JsonGeneratorTests::testCLI()
|
|||
string stdout, stderr;
|
||||
|
||||
const string inputFilePath(testFilePath("some_structs.h"));
|
||||
const char *const args1[]
|
||||
= { PROJECT_NAME, "--input-file", inputFilePath.data(), "--json-classes", "TestNamespace2::ThirdPartyStruct", "--clang-opt", "-resource-dir",
|
||||
REFLECTION_GENERATOR_CLANG_RESOURCE_DIR, "-I", CPP_UTILITIES_INCLUDE_DIRS, "-I", RAPIDJSON_INCLUDE_DIRS, nullptr };
|
||||
const char *const args1[] = { PROJECT_NAME, "--input-file", inputFilePath.data(), "--json-classes", "TestNamespace2::ThirdPartyStruct",
|
||||
"--clang-opt", "-resource-dir", REFLECTION_GENERATOR_CLANG_RESOURCE_DIR, "-I", CPP_UTILITIES_INCLUDE_DIRS,
|
||||
#ifdef RAPIDJSON_INCLUDE_DIRS
|
||||
"-I", RAPIDJSON_INCLUDE_DIRS,
|
||||
#endif
|
||||
nullptr };
|
||||
TESTUTILS_ASSERT_EXEC(args1);
|
||||
assertEqualityLinewise(m_expectedCode, toArrayOfLines(stdout));
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue