From 4cf9606b3c75478fe7b8258d89b504f854e1de21 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 10 Apr 2013 16:20:30 +0100 Subject: [PATCH] cli: Fix script search for out of source build. Only for debug builds. Release must be installed. --- CMakeLists.txt | 1 - cli/CMakeLists.txt | 7 +++++++ cli/cli_resources.cpp | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccaddd0..9394282 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -317,7 +317,6 @@ add_library (common STATIC ) set_target_properties (common PROPERTIES - COMPILE_DEFINITIONS APITRACE_SOURCE_DIR="${CMAKE_SOURCE_DIR}" # Ensure it can be statically linked in shared libraries COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}" ) diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 5f8e116..689374d 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -33,4 +33,11 @@ target_link_libraries (apitrace ${GETOPT_LIBRARIES} ) +if (NOT CMAKE_CROSSCOMPILING) + set_target_properties (apitrace PROPERTIES + # On debug builds tell where the source is so that scripts can be found + COMPILE_DEFINITIONS_DEBUG APITRACE_SOURCE_DIR="${CMAKE_SOURCE_DIR}" + ) +endif () + install (TARGETS apitrace RUNTIME DESTINATION bin) diff --git a/cli/cli_resources.cpp b/cli/cli_resources.cpp index 255a98b..a533b01 100644 --- a/cli/cli_resources.cpp +++ b/cli/cli_resources.cpp @@ -112,12 +112,14 @@ findScript(const char *scriptFilename) // Try relative build directory // XXX: Just make build and install directory layout match - scriptPath = processDir; +#if defined(APITRACE_SOURCE_DIR) + scriptPath = APITRACE_SOURCE_DIR; scriptPath.join("scripts"); scriptPath.join(scriptFilename); if (scriptPath.exists()) { return scriptPath; } +#endif // Try relative install directory scriptPath = processDir; -- 2.43.0