Skip to content

Commit

Permalink
Locating ll files flexibly using build config
Browse files Browse the repository at this point in the history
So far the path to ll files used in unittests are hardcoded
so that we can only run them in the unittests directory of build
directory.

This patch fixes the hardcoded path (using config values) so that
we can run unittests from anywhere.
  • Loading branch information
benquike committed Dec 16, 2020
1 parent 8287b4a commit 992b9ab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ else()
message(STATUS "Dynamic log disabled")
endif()

configure_file(config.h.in config.h @ONLY)
include_directories(${CMAKE_BINARY_DIR})


include_directories(
${PHASAR_SRC_DIR}/include
)
Expand Down
7 changes: 7 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__

#define PHASAR_SRC_DIR "@CMAKE_SOURCE_DIR@"
#define PHASAR_BUILD_DIR "@CMAKE_BINARY_DIR@"

#endif /* __CONFIG_H__ */
4 changes: 3 additions & 1 deletion unittests/TestUtils/TestConfig.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#ifndef UNITTEST_TESTUTILS_TESTCONFIG_H_
#define UNITTEST_TESTUTILS_TESTCONFIG_H_

#include "config.h"

#include <string>

namespace psr::unittest {

inline const std::string PathToLLTestFiles("../test/llvm_test_code/");
inline const std::string PathToLLTestFiles(PHASAR_BUILD_DIR "/test/llvm_test_code/");

} // namespace psr::unittest

Expand Down

0 comments on commit 992b9ab

Please sign in to comment.