The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=15775 ====================================================================== Reported By: James Johnston Assigned To: ====================================================================== Project: CMake Issue ID: 15775 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2015-10-07 18:34 EDT Last Modified: 2015-10-07 18:34 EDT ====================================================================== Summary: Ninja will unnecessarily relink on windows if a library exports no symbols Description: This is very similar to the issue reported by Nils Gladitz: 0015666: Ninja may unnecessarily relink on windows http://public.kitware.com/Bug/view.php?id=15666
However, my test case does not work on CMake 3.4.0-rc1 either. In this situation, the issue arises when the library exports no symbols. My test case is almost identical to the one from Nils, except notice that test.cpp is now a blank file: I don't export any symbols. If the project does not export any symbols, the linker *will not emit a LIB file at all.* It initially sounds non-sensical, but not exporting any symbols is not as uncommon as one might think; some examples: * It is common that a .NET C++/CLR project will not export unmanaged symbols, as it is exporting directly through the DLL (i.e. no LIB file). * A DLL being used for the purpose of storing Win32 resources would not export any symbols. * Some 3rd-party libraries (e.g. FLANN) happily seem to link an empty library... Steps to Reproduce: My test case, as you can see it's basically the same as Nils in http://public.kitware.com/Bug/view.php?id=15666 except no symbols: CMakeLists.txt -------------- # Using CMake 3.4.0-rc1 here: cmake_minimum_required(VERSION 3.4) project(Foo CXX) if(NOT EXISTS test.cpp) # Unlike Nils, I emit no symbols at all here: file(WRITE test.cpp "") endif() add_custom_target(touch COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_SOURCE_DIR}/test.cpp ) add_library(foo SHARED test.cpp) Procedure: ---------- 1. Configure with Ninja from a Visual C++ 2008 command prompt. (Other VC++ versions will likely exhibit the same issue). 2. ninja # builds as expected 3. ninja # continues to build 4. ninja -d explain ninja explain: output foo.lib doesn't exist ninja explain: foo.dll is dirty [1/1] Linking CXX shared library foo.dll ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2015-10-07 18:34 James Johnston New Issue ====================================================================== -- 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
