The following issue has been SUBMITTED. ====================================================================== https://cmake.org/Bug/view.php?id=16074 ====================================================================== Reported By: Antonio Assigned To: ====================================================================== Project: CMake Issue ID: 16074 Category: (No Category) Reproducibility: have not tried Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2016-04-21 09:58 EDT Last Modified: 2016-04-21 09:58 EDT ====================================================================== Summary: Setting link_directories in toolchain file is only used for compiler tests, and inhibits effect of repeating the command Description: In the attached example, TOOLCHAIN FILE: link_directories("D:/abcd")
CMAKELISTS.TXT: project(dummyProject) cmake_minimum_required(VERSION 3.4) link_directories("D:/abcd") link_directories("D:/efgh") add_library(dummyTarget SHARED dummy.cpp) At linking stage, only the "-LD:/efgh" will be there: cmd.exe /C "cd . && <compiler> -shared -o libdummyTarget.dll -Wl,--out-implib,libdummyTarget.dll.a -Wl,--major-image-version,0,--minor-image-version,0 CMakeFiles/dummyTarget.dir/dummy.cpp.obj -LD:/efgh -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." Note: In the CMakeOutput.log file is possible to see that -LD:/abcd is used in the preliminary compiler tests. Use case: I am dealing with a toolchain where the std library is in a specific location, and to pass the preliminary cmake compiler tests I must set the std library location with a link_directories command. Since it is toolchain specific, it makes sense to set in the toolchain file. I can pass the compiler tests if I call `link_directories` in the toolchain file. The only workaround I could find so far was to directly set the flag (still in the toolchain file): # SET(CMAKE_EXE_LINKER_FLAGS "-LD:/abcd") # SET(CMAKE_SHARED_LINKER_FLAGS "-LD:/abcd") # SET(CMAKE_MODULE_LINKER_FLAGS "-LD:/abcd") Steps to Reproduce: 1) Take the project in attachment 2) Configure with the attached toolchain, for example using ninja generator 3a) With ninja, run ninja -v to see the command line 3b) With make, run make.exe VERBOSE=1 to see the command line ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2016-04-21 09:58 Antonio New Issue 2016-04-21 09:58 Antonio File Added: CMakeBugProject.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