The following issue has been SUBMITTED. ====================================================================== https://cmake.org/Bug/view.php?id=15885 ====================================================================== Reported By: Pavel Solodovnikov Assigned To: ====================================================================== Project: CMake Issue ID: 15885 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2015-12-16 05:22 EST Last Modified: 2015-12-16 05:22 EST ====================================================================== Summary: Ninja always relinks libraries that doesn't export any symbols (on Windows) Description: Consider the following test case:
CMakeLists.txt: cmake_minimum_required(VERSION 2.8) project(foo CXX) add_library(foo SHARED test.cpp) test.cpp: void foo() {} With such setup when I run cmake (cmake -G Ninja) and execute several consecutive builds, each time ninja relinks "foo" library. If test.cpp instead contains exported symbol, for example: __declspec( dllexport ) void foo(){} ninja works as expected, reporting for the second build "ninja: no work to do". The cause of the problem is that cmake generates link rule for "foo.dll" in such a way that it depends on "foo.lib" file existence: build foo.dll foo.lib: CXX_SHARED_LIBRARY_LINKER__foo CMakeFiles\foo.dir\test.cpp.obj If a library has no exported symbols, MSVC doesn't produce a ".lib" file for it during a build. Because of that ninja assumes it needs to relink again to produce import library for "foo.dll". Steps to Reproduce: 1) extract attached archive with test files (CMakeLists.txt and test.cpp). 2) run "cmake -G Ninja" 3) ninja (builds and links library) 4) ninja (should report "no work to do" but relinks the library again) Additional Information: It's a windows-specific case (more specifically Windows + MSVC, I assume, at least not tested with MinGW toolchain), does not occur on linux since there is no such thing as "import library" for shared libraries. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2015-12-16 05:22 Pavel SolodovnikovNew Issue 2015-12-16 05:22 Pavel SolodovnikovFile Added: cmake_relink_test.zip ====================================================================== -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers