Create srcref in BasicConfig.cmake

This commit is contained in:
Martchus 2017-11-12 17:00:07 +01:00
parent ab42e9d96c
commit 969c574806
3 changed files with 5 additions and 4 deletions

View File

@ -283,4 +283,8 @@ if(NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
endif() endif()
endif() endif()
# add a file called "srcdirref" to the build directory; this file contains the path of the sources so tests can easily find test files contained in the source directory
# note: This is also useful when using the TestApplication class in the regular target, so this is created in BasicConfig.cmake (rather than only TestTarget.cmake)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/srcdirref" "${CMAKE_CURRENT_SOURCE_DIR}")
set(BASIC_PROJECT_CONFIG_DONE YES) set(BASIC_PROJECT_CONFIG_DONE YES)

View File

@ -302,9 +302,6 @@ if(CPP_UNIT_LIB OR META_NO_CPP_UNIT)
endif() endif()
endif() endif()
# add a file called "srcdirref" to the build directory; this file contains the path of the sources so tests can easily find test files contained in the source directory
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/srcdirref" "${CMAKE_CURRENT_SOURCE_DIR}")
set(META_HAVE_TESTS YES) set(META_HAVE_TESTS YES)
else() else()

View File

@ -446,7 +446,7 @@ void TestApplication::readFallbackTestfilePathFromSrcRef()
{ {
try { try {
// read "srcdirref" file which should contain the path of the source directory; this file should have been // read "srcdirref" file which should contain the path of the source directory; this file should have been
// create by the CMake module "TestTarget.cmake" // create by the CMake module "BasicConfig.cmake"
const string srcDirContent(readFile("srcdirref", 2 * 1024)); const string srcDirContent(readFile("srcdirref", 2 * 1024));
if (srcDirContent.empty()) { if (srcDirContent.empty()) {
cerr << Phrases::Warning << "The file \"srcdirref\" is empty." << Phrases::EndFlush; cerr << Phrases::Warning << "The file \"srcdirref\" is empty." << Phrases::EndFlush;