Merge lp:~jpakkane/unity-scopes-api/randomstuff into lp:unity-scopes-api

Proposed by Jussi Pakkanen
Status: Merged
Approved by: Michi Henning
Approved revision: 5
Merged at revision: 5
Proposed branch: lp:~jpakkane/unity-scopes-api/randomstuff
Merge into: lp:unity-scopes-api
Diff against target: 116 lines (+20/-14)
7 files modified
CMakeLists.txt (+2/-3)
test/CMakeLists.txt (+4/-0)
test/gtest/unity/api/scopes/ScopeBase/CMakeLists.txt (+0/-3)
test/gtest/unity/api/scopes/ScopeBase/ScopeBase_test.cpp (+2/-2)
test/gtest/unity/api/scopes/internal/DynamicLoader/CMakeLists.txt (+0/-3)
test/gtest/unity/api/scopes/internal/DynamicLoader/DynamicLoader_test.cpp (+4/-3)
test/scope-api-testconfig.h.in (+8/-0)
To merge this branch: bzr merge lp:~jpakkane/unity-scopes-api/randomstuff
Reviewer Review Type Date Requested Status
Michi Henning (community) Approve
Review via email: mp+166268@code.launchpad.net

Commit message

Various fixes.

Description of the change

Bunch of random stuff I found.

To post a comment you must log in.
Revision history for this message
Michi Henning (michihenning) wrote :

Thanks for the review!

One minor glitch:

link_directories(${UNITY_API_LIBRARY_DIRS})

I think that line should stay in. That's because it adds the location of libunit-api to the rpath when linking the binaries. Without it, the unity-api lib directory is not in the rpath which means, when I run the tests with a libunity-api that's somewhere in my staging area, and I've set PKG_CONFIG_PATH to point at the install location, the tests fail because they can't locate libunity-api.so at run time.

I'd prefer not to have to set LD_LIBRARY_PATH separately to make it work.

review: Needs Fixing
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

I can see why that would be useful. However:

- CMake documentation recommends against using link_directories

- for consistency we should do this for every dependency

- Debian packagers discourage the use of rpath

- if you want to add stuff to rpath, it should be done explicitly with set_target_properties

- when you have the .so both in a system directory and a custom dir, LD_LIBRARY_PATH is the only sane way to select which one is chosen (and which can be changed without recompiling)

- the simple way of solving this is to have a daily build PPA of unity-api that you can use, which is the way most projects do it

If you still feel it should be there, I can add it back in.

Revision history for this message
Michi Henning (michihenning) wrote :

OK, you've convinced me. I'll live with setting LD_LIBRARY_PATH :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-05-29 08:51:07 +0000
3+++ CMakeLists.txt 2013-05-29 14:36:31 +0000
4@@ -63,8 +63,7 @@
5 find_package(Boost 1.49.0 COMPONENTS regex REQUIRED)
6 pkg_check_modules(UNITY_API libunity-api REQUIRED)
7 set(OTHER_INCLUDE_DIRS ${OTHER_INCLUDE_DIRS} ${UNITY_API_INCLUDE_DIRS})
8-set(OTHER_LIBS ${OTHER_LIBS} ${UNITY_API_LIBRARIES})
9-link_directories(${UNITY_API_LIBRARY_DIRS})
10+set(OTHER_LIBS ${OTHER_LIBS} ${UNITY_API_LDFLAGS})
11
12 # Standard install paths
13 include(GNUInstallDirs)
14@@ -113,7 +112,7 @@
15 set(LIBS ${UNITY_SCOPES_LIB} ${OTHER_LIBS})
16
17 # Library install prefix
18-set(LIB_INSTALL_PREFIX lib/${CMAKE_LIBRARY_ARCHITECTURE})
19+set(LIB_INSTALL_PREFIX "lib" CACHE PATH "Destination install dir for the library")
20
21 set(LIBDIR ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_PREFIX} CACHE PATH "Destination install dir for the library")
22 set(libdir ${LIBDIR})
23
24=== modified file 'test/CMakeLists.txt'
25--- test/CMakeLists.txt 2013-05-29 04:57:50 +0000
26+++ test/CMakeLists.txt 2013-05-29 14:36:31 +0000
27@@ -1,3 +1,7 @@
28+set(TEST_BUILD_ROOT ${CMAKE_CURRENT_BINARY_DIR})
29+configure_file(scope-api-testconfig.h.in scope-api-testconfig.h @ONLY)
30+include_directories(${CMAKE_CURRENT_BINARY_DIR})
31+
32 add_subdirectory(gtest)
33 add_subdirectory(headers)
34 add_subdirectory(copyright)
35
36=== modified file 'test/gtest/unity/api/scopes/ScopeBase/CMakeLists.txt'
37--- test/gtest/unity/api/scopes/ScopeBase/CMakeLists.txt 2013-05-29 04:57:50 +0000
38+++ test/gtest/unity/api/scopes/ScopeBase/CMakeLists.txt 2013-05-29 14:36:31 +0000
39@@ -1,6 +1,3 @@
40-# This allows us to use a shared library in the current dir for testing without having to set LD_LIBRARY_PATH
41-add_definitions(-DTESTLIBDIR=\"${CMAKE_CURRENT_BINARY_DIR}\")
42-
43 add_executable(ScopeBase_test ScopeBase_test.cpp)
44 target_link_libraries(ScopeBase_test ${LIBS} ${TESTLIBS})
45
46
47=== modified file 'test/gtest/unity/api/scopes/ScopeBase/ScopeBase_test.cpp'
48--- test/gtest/unity/api/scopes/ScopeBase/ScopeBase_test.cpp 2013-05-29 04:57:50 +0000
49+++ test/gtest/unity/api/scopes/ScopeBase/ScopeBase_test.cpp 2013-05-29 14:36:31 +0000
50@@ -19,7 +19,7 @@
51 #include <unity/api/scopes/internal/ScopeBaseImpl.h>
52 #include <unity/api/scopes/internal/DynamicLoader.h>
53 #include <unity/UnityExceptions.h>
54-
55+#include <scope-api-testconfig.h>
56 #include <gtest/gtest.h>
57
58 using namespace unity::api::scopes;
59@@ -27,7 +27,7 @@
60
61 namespace
62 {
63- char const* scopelib = TESTLIBDIR "/libscopelib.so";
64+ char const* scopelib = TEST_BUILD_ROOT "/gtest/unity/api/scopes/ScopeBase/libscopelib.so";
65 }
66
67 bool create_called = false;
68
69=== modified file 'test/gtest/unity/api/scopes/internal/DynamicLoader/CMakeLists.txt'
70--- test/gtest/unity/api/scopes/internal/DynamicLoader/CMakeLists.txt 2013-05-29 04:57:50 +0000
71+++ test/gtest/unity/api/scopes/internal/DynamicLoader/CMakeLists.txt 2013-05-29 14:36:31 +0000
72@@ -1,6 +1,3 @@
73-# This allows us to use a shared library in the current dir for testing without having to set LD_LIBRARY_PATH
74-add_definitions(-DTESTLIBDIR=\"${CMAKE_CURRENT_BINARY_DIR}\")
75-
76 add_executable(DynamicLoader_test DynamicLoader_test.cpp)
77 target_link_libraries(DynamicLoader_test ${LIBS} ${TESTLIBS})
78
79
80=== modified file 'test/gtest/unity/api/scopes/internal/DynamicLoader/DynamicLoader_test.cpp'
81--- test/gtest/unity/api/scopes/internal/DynamicLoader/DynamicLoader_test.cpp 2013-05-29 04:57:50 +0000
82+++ test/gtest/unity/api/scopes/internal/DynamicLoader/DynamicLoader_test.cpp 2013-05-29 14:36:31 +0000
83@@ -20,15 +20,16 @@
84 #include <unity/UnityExceptions.h>
85
86 #include <gtest/gtest.h>
87-#include <boost/regex.hpp> // BUGFIX: We don't use std::regex because, as of gcc 4.7.2, it is still broken
88+#include <boost/regex.hpp> // Use Boost implementation until http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631 is fixed.
89+#include <scope-api-testconfig.h>
90
91 using namespace std;
92 using namespace unity::api::scopes::internal;
93
94 namespace
95 {
96- char const* goodlib = TESTLIBDIR "/libtestlib.so";
97- char const* badlib = TESTLIBDIR "/libbadtestlib.so";
98+ char const* goodlib = TEST_BUILD_ROOT "/gtest/unity/api/scopes/internal/DynamicLoader/libtestlib.so";
99+ char const* badlib = TEST_BUILD_ROOT "/gtest/unity/api/scopes/internal/DynamicLoader/libbadtestlib.so";
100 }
101
102 // Basic test.
103
104=== added file 'test/scope-api-testconfig.h.in'
105--- test/scope-api-testconfig.h.in 1970-01-01 00:00:00 +0000
106+++ test/scope-api-testconfig.h.in 2013-05-29 14:36:31 +0000
107@@ -0,0 +1,8 @@
108+/* This file contains all configuration data needed to run unit tests. */
109+
110+#ifndef SCOPE_API_TESTCONFIG
111+#define SCOPE_API_TESTCONFIG
112+
113+#define TEST_BUILD_ROOT "@TEST_BUILD_ROOT@"
114+
115+#endif
116\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: