From: José Fonseca Date: Wed, 10 Apr 2013 15:20:30 +0000 (+0100) Subject: cli: Fix script search for out of source build. X-Git-Url: https://git.cworth.org/git?p=apitrace;a=commitdiff_plain;h=4cf9606b3c75478fe7b8258d89b504f854e1de21 cli: Fix script search for out of source build. Only for debug builds. Release must be installed. --- 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;