The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=13363 ====================================================================== Reported By: Orçun Gökbulut Assigned To: ====================================================================== Project: CMake Issue ID: 13363 Category: CMake Reproducibility: always Severity: feature Priority: normal Status: new ====================================================================== Date Submitted: 2012-06-30 11:50 WAT Last Modified: 2012-06-30 11:50 WAT ====================================================================== Summary: target_link_libraries does not sets target's include and link paths according to li Description: When target_link_libraries used with a cmake static library target as a link library, CMake does not combine linked static library targets include and linker directory paths to target's include and linker directory paths.
Suppose that there is a directory like this; + Project | + Sub Project | | +-Dependencies | | |-Library.h | | |-Library.lib | |-CMakeLists.txt | |-SubProject.cpp |-Main.cpp |-CMakeLists.txt Content of SubProject/CMakeLists.txt; link_directories(Dependencies) include_directories(Dependencies) add_library(SubProject SubProject.cpp) target_link_library(SubProject Library.lib) Content of /CMakeLists.txt add_executable(Main) target_link_libraries(Main SubProject) This setup causes linker and include problems in visual studio becouse linker or compiler can not find Library.lib or Library.h while compiling Main target. In order to work around this problem we have to move link_directories and include_directories SubProject/CMakeLists.txt to /CMakeLists.txt. This work around causes problems in big projects which uses different libraries on different project configurations. In this kind of project, when a new sub project/module added to the project it's library and include directories should be added to /CMakeLists.txt. If a sub project's/module's dependent library has some constrains like platform dependency (like external library is a windows library and does not work on linux but we have a linux alternative which is implamented on an other sub project/module) we have to use many if clauses on include_directories and library_directory. In summary, missing of this feature prevents more moduler and non-centered project structures becouse we have to modify or maintain when a new module with non-shared library dependency added to project instead of just a simple add_subdirectory command. Steps to Reproduce: Create a project structure like this one; + Project | + Sub Project | | +-Dependencies | | |-Library.h | | |-Library.lib | |-CMakeLists.txt | |-SubProject.cpp |-Main.cpp |-CMakeLists.txt Content of SubProject/CMakeLists.txt; link_directories(Dependencies) include_directories(Dependencies) add_library(SubProject SubProject.cpp) target_link_library(SubProject Library.lib) Content of /CMakeLists.txt add_executable(Main) target_link_libraries(Main SubProject) Compiler can not find Library.lib when linking target named 'Main'. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2012-06-30 11:50 Orçun Gökbulut New Issue ====================================================================== -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
