On the target_link_libraries() command documentation page, it is written
that it is possible to pass flags to this function, if they start with a
'-' character.
This functionnality seems to be broken with Visual Studio. Indeed flags
in the Visual Studio linker are using slashes instead of dash.
For instance, trying to enable map file generation in the linkers is
failing:
target_link_libraries(${PROJECT_NAME} -MAP)
Resulting output in the linker command line is "-MAP" (note the presence
of quotes). It should be /MAP (without quotes) in order to be properly
recognized by the linker command-line parser. After few researches, it
seems that this issue is
similar:http://public.kitware.com/pipermail/cmake/2015-June/060989.html
<http://public.kitware.com/pipermail/cmake/2015-June/060989.html>
Context:
I have a library called lib_project. I have an executable my_project
that links against lib_project. When linking the final binary, I need to
enable UAC support in order to force execution of the binary as
administrator
(http://stackoverflow.com/questions/1655089/cmake-requireadministrator).
lib_project uses a Windows API that needs administrator level set in the
final executable. So I would like to force my_project to set this
specific flag, but I would like to see this set in the CmakeLists.txt of
lib_project. Regarding the documentation, the following command should
do the trick (but not working currently):
target_link_libraries(lib_project PUBLIC -level='requireAdministrator'
-uiAccess='false')
Please not that the -level can bring bugs as it could be interpreted by
Cmake as "link against 'evel' library".
Do I have pointed a new bug in the Visual Studio generator? Would a
target_link_flags() command be a good idea to implement?
Best regards,
L-P
--
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