[CMake] target_link_libraries and flags issue with Visual Studio
Louis-Paul CORDIER
lp.cordier at dynamixyz.com
Wed Aug 3 07:02:08 EDT 2016
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160803/b69dcf8b/attachment.html>
More information about the CMake
mailing list