diff options
author | Brad King <brad.king@kitware.com> | 2009-04-08 20:29:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-04-08 20:29:04 (GMT) |
commit | d05e98f8d77e03c0c68ae3d7b5e5617f54dc6b07 (patch) | |
tree | 6e74a9ece72ee60b14423a2312ffc9add11ab0ef /Tests/ExportImport | |
parent | 5886d103348ba7c14e464c851d3316f09cc2c0c6 (diff) | |
download | CMake-d05e98f8d77e03c0c68ae3d7b5e5617f54dc6b07.zip CMake-d05e98f8d77e03c0c68ae3d7b5e5617f54dc6b07.tar.gz CMake-d05e98f8d77e03c0c68ae3d7b5e5617f54dc6b07.tar.bz2 |
ENH: Allow IMPORTED_IMPLIB w/o IMPORTED_LOCATION
Linking to a Windows shared library (.dll) requires only its import
library (.lib). This teaches CMake to recognize SHARED IMPORTED library
targets that set only IMPORTED_IMPLIB and not IMPORTED_LOCATION.
Diffstat (limited to 'Tests/ExportImport')
-rw-r--r-- | Tests/ExportImport/Export/CMakeLists.txt | 16 | ||||
-rw-r--r-- | Tests/ExportImport/Export/testLib5.c | 7 | ||||
-rw-r--r-- | Tests/ExportImport/Import/A/CMakeLists.txt | 14 | ||||
-rw-r--r-- | Tests/ExportImport/Import/A/imp_testExe1.c | 2 |
4 files changed, 36 insertions, 3 deletions
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 26687b1..19cd22f 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -39,6 +39,8 @@ set_property(TARGET testLib3 PROPERTY SOVERSION 3) add_library(testLib4 SHARED testLib4.c) set_property(TARGET testLib4 PROPERTY FRAMEWORK 1) +add_library(testLib5 SHARED testLib5.c) + # Work-around: Visual Studio 6 does not support per-target object files. set(VS6) if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6") @@ -85,15 +87,27 @@ install( LIBRARY DESTINATION lib/impl ARCHIVE DESTINATION lib/impl ) +install( + TARGETS testLib5 + EXPORT exp + # Leave out RUNTIME DESTINATION to test implib-only export. + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + ) install(EXPORT exp NAMESPACE exp_ DESTINATION lib/exp) +# Install testLib5.dll outside the export. +if(WIN32) + install(TARGETS testLib5 RUNTIME DESTINATION bin) +endif(WIN32) + # Export from build tree. export(TARGETS testExe1 testLib1 testLib2 testLib3 testExe2libImp testLib3Imp NAMESPACE bld_ FILE ExportBuildTree.cmake ) -export(TARGETS testExe2 testLib4 testExe3 testExe2lib +export(TARGETS testExe2 testLib4 testLib5 testExe3 testExe2lib testLib4lib testLib4libdbg testLib4libopt NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake diff --git a/Tests/ExportImport/Export/testLib5.c b/Tests/ExportImport/Export/testLib5.c new file mode 100644 index 0000000..20a8215 --- /dev/null +++ b/Tests/ExportImport/Export/testLib5.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) || defined(__CYGWIN__) +# define testLib5_EXPORT __declspec(dllexport) +#else +# define testLib5_EXPORT +#endif + +testLib5_EXPORT int testLib5(void) { return 0; } diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 16cff2d..e874cdb 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -23,7 +23,12 @@ add_executable(imp_testExe1 ) # Try linking to a library imported from the install tree. -target_link_libraries(imp_testExe1 exp_testLib2 exp_testLib3 exp_testLib4) +target_link_libraries(imp_testExe1 + exp_testLib2 + exp_testLib3 + exp_testLib4 + exp_testLib5 + ) # Try building a plugin to an executable imported from the install tree. add_library(imp_mod1 MODULE imp_mod1.c) @@ -48,7 +53,12 @@ add_executable(imp_testExe1b ) # Try linking to a library imported from the build tree. -target_link_libraries(imp_testExe1b bld_testLib2 bld_testLib3 bld_testLib4) +target_link_libraries(imp_testExe1b + bld_testLib2 + bld_testLib3 + bld_testLib4 + bld_testLib5 + ) # Try building a plugin to an executable imported from the build tree. add_library(imp_mod1b MODULE imp_mod1.c) diff --git a/Tests/ExportImport/Import/A/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c index 6424d33..6a6ba0f 100644 --- a/Tests/ExportImport/Import/A/imp_testExe1.c +++ b/Tests/ExportImport/Import/A/imp_testExe1.c @@ -4,6 +4,7 @@ extern int testLib2(); extern int testLib3(); extern int testLib4(); extern int testLib4lib(); +extern int testLib5(); /* Switch a symbol between debug and optimized builds to make sure the proper library is found from the testLib4 link interface. */ @@ -17,5 +18,6 @@ extern testLib4libcfg(void); int main() { return (testLib2() + generated_by_testExe1() + testLib3() + testLib4() + + testLib5() + generated_by_testExe3() + testLib4lib() + testLib4libcfg()); } |