ENH: Added RuntimePath test to make sure rpath gets correct order.

This commit is contained in:
Brad King 2008-01-22 09:15:16 -05:00
parent 96fd5909d9
commit d2d18fb565
7 changed files with 50 additions and 0 deletions

View File

@ -498,6 +498,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel
--build-two-config
--test-command bin/example)
IF(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
ADD_TEST_MACRO(RuntimePath RuntimePath)
ENDIF(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
ENDIF("${CMAKE_SYSTEM_NAME}" MATCHES syllable)

View File

@ -0,0 +1,36 @@
project(RuntimePath C)
if(CMAKE_ANSI_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
endif(CMAKE_ANSI_CFLAGS)
# Add a simple chain of shared libraries that must be found.
add_library(foo1 SHARED foo1.c)
set_property(TARGET foo1 PROPERTY OUTPUT_NAME foo)
set_property(TARGET foo1 PROPERTY LIBRARY_OUTPUT_DIRECTORY A)
add_library(bar1 SHARED bar1.c)
set_property(TARGET bar1 PROPERTY OUTPUT_NAME bar)
set_property(TARGET bar1 PROPERTY VERSION 1)
set_property(TARGET bar1 PROPERTY LIBRARY_OUTPUT_DIRECTORY B)
target_link_libraries(bar1 foo1)
add_executable(RuntimePath main.c)
target_link_libraries(RuntimePath bar1)
# Add a library that provides a conflicting location to make sure
# rpath ordering works.
add_library(foo2 SHARED foo2.c)
set_property(TARGET foo2 PROPERTY OUTPUT_NAME foo)
set_property(TARGET foo2 PROPERTY LIBRARY_OUTPUT_DIRECTORY B)
# Add a library that would provide a conflicting location if not for
# soname analysis in rpath ordering. This will also break the old
# link directory ordering to make sure files are linked with full
# paths.
if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG)
add_library(bar2 SHARED bar2.c)
set_property(TARGET bar2 PROPERTY OUTPUT_NAME bar)
set_property(TARGET bar2 PROPERTY LIBRARY_OUTPUT_DIRECTORY A)
target_link_libraries(bar2 foo2)
endif(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG)

2
Tests/RuntimePath/bar1.c Normal file
View File

@ -0,0 +1,2 @@
extern int foo1();
int bar1() { return foo1(); }

2
Tests/RuntimePath/bar2.c Normal file
View File

@ -0,0 +1,2 @@
extern int foo2();
int bar2() { return foo2(); }

1
Tests/RuntimePath/foo1.c Normal file
View File

@ -0,0 +1 @@
int foo1() { return 0; }

1
Tests/RuntimePath/foo2.c Normal file
View File

@ -0,0 +1 @@
int foo2() { return 0; }

5
Tests/RuntimePath/main.c Normal file
View File

@ -0,0 +1,5 @@
extern int bar1();
int main()
{
return bar1();
}