From 969c574806b491bb92c57ee894a0927b8fc39964 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 12 Nov 2017 17:00:07 +0100 Subject: [PATCH] Create srcref in BasicConfig.cmake --- cmake/modules/BasicConfig.cmake | 4 ++++ cmake/modules/TestTarget.cmake | 3 --- tests/testutils.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmake/modules/BasicConfig.cmake b/cmake/modules/BasicConfig.cmake index 6cfebaa..3cbb0b2 100644 --- a/cmake/modules/BasicConfig.cmake +++ b/cmake/modules/BasicConfig.cmake @@ -283,4 +283,8 @@ if(NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS) 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) diff --git a/cmake/modules/TestTarget.cmake b/cmake/modules/TestTarget.cmake index 426fa9b..e08e971 100644 --- a/cmake/modules/TestTarget.cmake +++ b/cmake/modules/TestTarget.cmake @@ -302,9 +302,6 @@ if(CPP_UNIT_LIB OR META_NO_CPP_UNIT) 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) else() diff --git a/tests/testutils.cpp b/tests/testutils.cpp index 9ed5593..1925b14 100644 --- a/tests/testutils.cpp +++ b/tests/testutils.cpp @@ -446,7 +446,7 @@ void TestApplication::readFallbackTestfilePathFromSrcRef() { try { // 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)); if (srcDirContent.empty()) { cerr << Phrases::Warning << "The file \"srcdirref\" is empty." << Phrases::EndFlush;