Browse Source

Create srcref in BasicConfig.cmake

experiment/srcref_basic_cfg
Martchus 4 years ago
parent
commit
969c574806
  1. 4
      cmake/modules/BasicConfig.cmake
  2. 3
      cmake/modules/TestTarget.cmake
  3. 2
      tests/testutils.cpp

4
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)

3
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()

2
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;

Loading…
Cancel
Save