Last active
May 21, 2024 20:28
-
-
Save jlgerber/eafc4ee2b9954e27dd2bb009496b1b03 to your computer and use it in GitHub Desktop.
cmake - handling executable and library with same name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lets say we want to add a library and an executable, both with the same name. | |
# In this example, it is resman | |
add_library(resman ${src_cpps} ${src_hpps} ) | |
target_link_libraries(resman ${Boost_LIBRARIES} ${LIBYAML} ${LIBFMT}) | |
# | |
# Add resman executable | |
# | |
# We call the executable resman-bin | |
add_executable(resman-bin main.cpp ) | |
target_link_libraries(resman-bin resman) | |
# now we rename resman-bin executable to resman using target properties | |
set_target_properties(resman-bin | |
PROPERTIES OUTPUT_NAME resman) | |
# |
Thanks!!
Cheers!
ty
Thanks !
๐
OUTPUT_NAME
doesn't work with MSVC as it issues /implib
with the same name as the library resulting in LNK1149 error. What does work is to use RUNTIME_OUTPUT_NAME
๐
thank you!
Heh, thanks a lot!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you