mirror of
https://github.com/reactos/CMake.git
synced 2025-01-31 17:12:49 +00:00
ENH: Added test for linking to a static library that is next to a shared library. See bug#1644 for related changes.
This commit is contained in:
parent
1d0502927c
commit
07ec25e383
@ -37,6 +37,12 @@ ELSE(UNIX)
|
|||||||
ENDIF(NOT BORLAND)
|
ENDIF(NOT BORLAND)
|
||||||
ENDIF (UNIX)
|
ENDIF (UNIX)
|
||||||
|
|
||||||
|
# Test linking to static lib when a shared lib has the same name.
|
||||||
|
IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS)
|
||||||
|
ADD_DEFINITIONS(-DCOMPLEX_TEST_LINK_STATIC)
|
||||||
|
TARGET_LINK_LIBRARIES(complex CMakeTestLinkStatic)
|
||||||
|
ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS)
|
||||||
|
|
||||||
# can we get the path to a source file
|
# can we get the path to a source file
|
||||||
GET_SOURCE_FILE_PROPERTY(A_LOCATION A.cxx LOCATION)
|
GET_SOURCE_FILE_PROPERTY(A_LOCATION A.cxx LOCATION)
|
||||||
IF ("${A_LOCATION}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/A.cxx")
|
IF ("${A_LOCATION}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/A.cxx")
|
||||||
|
@ -23,6 +23,12 @@ extern "C" {
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef COMPLEX_TEST_LINK_STATIC
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
int TestLinkGetType();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int cm_passed = 0;
|
int cm_passed = 0;
|
||||||
int cm_failed = 0;
|
int cm_failed = 0;
|
||||||
@ -1270,7 +1276,18 @@ int main()
|
|||||||
// Test the generated file stream.
|
// Test the generated file stream.
|
||||||
TestCMGeneratedFileSTream();
|
TestCMGeneratedFileSTream();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef COMPLEX_TEST_LINK_STATIC
|
||||||
|
if(TestLinkGetType())
|
||||||
|
{
|
||||||
|
cmPassed("Link to static over shared worked.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmFailed("Link to static over shared failed.");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Summary
|
// Summary
|
||||||
|
|
||||||
|
@ -53,6 +53,13 @@ ELSE(${FOO_BAR_VAR} MATCHES "BAR")
|
|||||||
MESSAGE(SEND_ERROR "SET_TARGET_PROPERTIES or GET_TARGET_PROPERTY failed, FOO_BAR_VAR should be BAR, but is ${FOO_BAR_VAR}")
|
MESSAGE(SEND_ERROR "SET_TARGET_PROPERTIES or GET_TARGET_PROPERTY failed, FOO_BAR_VAR should be BAR, but is ${FOO_BAR_VAR}")
|
||||||
ENDIF(${FOO_BAR_VAR} MATCHES "BAR")
|
ENDIF(${FOO_BAR_VAR} MATCHES "BAR")
|
||||||
|
|
||||||
|
# Create static and shared lib of same name.
|
||||||
|
IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS)
|
||||||
|
ADD_LIBRARY(CMakeTestLinkStatic STATIC TestLink.c)
|
||||||
|
ADD_LIBRARY(CMakeTestLinkShared SHARED TestLink.c)
|
||||||
|
SET_TARGET_PROPERTIES(CMakeTestLinkStatic CMakeTestLinkShared
|
||||||
|
PROPERTIES OUTPUT_NAME CMakeTestLink CLEAN_DIRECT_OUTPUT 1)
|
||||||
|
ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Attach pre-build/pre-link/post-build custom-commands to the lib.
|
# Attach pre-build/pre-link/post-build custom-commands to the lib.
|
||||||
|
8
Tests/Complex/Library/TestLink.c
Normal file
8
Tests/Complex/Library/TestLink.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
int TestLinkGetType()
|
||||||
|
{
|
||||||
|
#ifdef CMakeTestLinkShared_EXPORTS
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
@ -37,6 +37,12 @@ ELSE(UNIX)
|
|||||||
ENDIF(NOT BORLAND)
|
ENDIF(NOT BORLAND)
|
||||||
ENDIF (UNIX)
|
ENDIF (UNIX)
|
||||||
|
|
||||||
|
# Test linking to static lib when a shared lib has the same name.
|
||||||
|
IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS)
|
||||||
|
ADD_DEFINITIONS(-DCOMPLEX_TEST_LINK_STATIC)
|
||||||
|
TARGET_LINK_LIBRARIES(complex CMakeTestLinkStatic)
|
||||||
|
ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS)
|
||||||
|
|
||||||
# can we get the path to a source file
|
# can we get the path to a source file
|
||||||
GET_SOURCE_FILE_PROPERTY(A_LOCATION A.cxx LOCATION)
|
GET_SOURCE_FILE_PROPERTY(A_LOCATION A.cxx LOCATION)
|
||||||
IF ("${A_LOCATION}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/A.cxx")
|
IF ("${A_LOCATION}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/A.cxx")
|
||||||
|
@ -23,6 +23,12 @@ extern "C" {
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef COMPLEX_TEST_LINK_STATIC
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
int TestLinkGetType();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int cm_passed = 0;
|
int cm_passed = 0;
|
||||||
int cm_failed = 0;
|
int cm_failed = 0;
|
||||||
@ -1270,7 +1276,18 @@ int main()
|
|||||||
// Test the generated file stream.
|
// Test the generated file stream.
|
||||||
TestCMGeneratedFileSTream();
|
TestCMGeneratedFileSTream();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef COMPLEX_TEST_LINK_STATIC
|
||||||
|
if(TestLinkGetType())
|
||||||
|
{
|
||||||
|
cmPassed("Link to static over shared worked.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmFailed("Link to static over shared failed.");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Summary
|
// Summary
|
||||||
|
|
||||||
|
@ -53,6 +53,13 @@ ELSE(${FOO_BAR_VAR} MATCHES "BAR")
|
|||||||
MESSAGE(SEND_ERROR "SET_TARGET_PROPERTIES or GET_TARGET_PROPERTY failed, FOO_BAR_VAR should be BAR, but is ${FOO_BAR_VAR}")
|
MESSAGE(SEND_ERROR "SET_TARGET_PROPERTIES or GET_TARGET_PROPERTY failed, FOO_BAR_VAR should be BAR, but is ${FOO_BAR_VAR}")
|
||||||
ENDIF(${FOO_BAR_VAR} MATCHES "BAR")
|
ENDIF(${FOO_BAR_VAR} MATCHES "BAR")
|
||||||
|
|
||||||
|
# Create static and shared lib of same name.
|
||||||
|
IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS)
|
||||||
|
ADD_LIBRARY(CMakeTestLinkStatic STATIC TestLink.c)
|
||||||
|
ADD_LIBRARY(CMakeTestLinkShared SHARED TestLink.c)
|
||||||
|
SET_TARGET_PROPERTIES(CMakeTestLinkStatic CMakeTestLinkShared
|
||||||
|
PROPERTIES OUTPUT_NAME CMakeTestLink CLEAN_DIRECT_OUTPUT 1)
|
||||||
|
ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Attach pre-build/pre-link/post-build custom-commands to the lib.
|
# Attach pre-build/pre-link/post-build custom-commands to the lib.
|
||||||
|
8
Tests/ComplexOneConfig/Library/TestLink.c
Normal file
8
Tests/ComplexOneConfig/Library/TestLink.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
int TestLinkGetType()
|
||||||
|
{
|
||||||
|
#ifdef CMakeTestLinkShared_EXPORTS
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
@ -37,6 +37,12 @@ ELSE(UNIX)
|
|||||||
ENDIF(NOT BORLAND)
|
ENDIF(NOT BORLAND)
|
||||||
ENDIF (UNIX)
|
ENDIF (UNIX)
|
||||||
|
|
||||||
|
# Test linking to static lib when a shared lib has the same name.
|
||||||
|
IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS)
|
||||||
|
ADD_DEFINITIONS(-DCOMPLEX_TEST_LINK_STATIC)
|
||||||
|
TARGET_LINK_LIBRARIES(complex CMakeTestLinkStatic)
|
||||||
|
ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS)
|
||||||
|
|
||||||
# can we get the path to a source file
|
# can we get the path to a source file
|
||||||
GET_SOURCE_FILE_PROPERTY(A_LOCATION A.cxx LOCATION)
|
GET_SOURCE_FILE_PROPERTY(A_LOCATION A.cxx LOCATION)
|
||||||
IF ("${A_LOCATION}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/A.cxx")
|
IF ("${A_LOCATION}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/A.cxx")
|
||||||
|
@ -23,6 +23,12 @@ extern "C" {
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef COMPLEX_TEST_LINK_STATIC
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
int TestLinkGetType();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int cm_passed = 0;
|
int cm_passed = 0;
|
||||||
int cm_failed = 0;
|
int cm_failed = 0;
|
||||||
@ -1270,7 +1276,18 @@ int main()
|
|||||||
// Test the generated file stream.
|
// Test the generated file stream.
|
||||||
TestCMGeneratedFileSTream();
|
TestCMGeneratedFileSTream();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef COMPLEX_TEST_LINK_STATIC
|
||||||
|
if(TestLinkGetType())
|
||||||
|
{
|
||||||
|
cmPassed("Link to static over shared worked.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmFailed("Link to static over shared failed.");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Summary
|
// Summary
|
||||||
|
|
||||||
|
@ -53,6 +53,13 @@ ELSE(${FOO_BAR_VAR} MATCHES "BAR")
|
|||||||
MESSAGE(SEND_ERROR "SET_TARGET_PROPERTIES or GET_TARGET_PROPERTY failed, FOO_BAR_VAR should be BAR, but is ${FOO_BAR_VAR}")
|
MESSAGE(SEND_ERROR "SET_TARGET_PROPERTIES or GET_TARGET_PROPERTY failed, FOO_BAR_VAR should be BAR, but is ${FOO_BAR_VAR}")
|
||||||
ENDIF(${FOO_BAR_VAR} MATCHES "BAR")
|
ENDIF(${FOO_BAR_VAR} MATCHES "BAR")
|
||||||
|
|
||||||
|
# Create static and shared lib of same name.
|
||||||
|
IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS)
|
||||||
|
ADD_LIBRARY(CMakeTestLinkStatic STATIC TestLink.c)
|
||||||
|
ADD_LIBRARY(CMakeTestLinkShared SHARED TestLink.c)
|
||||||
|
SET_TARGET_PROPERTIES(CMakeTestLinkStatic CMakeTestLinkShared
|
||||||
|
PROPERTIES OUTPUT_NAME CMakeTestLink CLEAN_DIRECT_OUTPUT 1)
|
||||||
|
ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Attach pre-build/pre-link/post-build custom-commands to the lib.
|
# Attach pre-build/pre-link/post-build custom-commands to the lib.
|
||||||
|
8
Tests/ComplexRelativePaths/Library/TestLink.c
Normal file
8
Tests/ComplexRelativePaths/Library/TestLink.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
int TestLinkGetType()
|
||||||
|
{
|
||||||
|
#ifdef CMakeTestLinkShared_EXPORTS
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user