Created
December 14, 2017 14:50
-
-
Save robertmaynard/b4c1edaf9c8896fea877ff571e899f80 to your computer and use it in GitHub Desktop.
CMake switch impl on fpic
This file contains hidden or 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
add_library(I INTERFACE) | |
add_library(IA STATIC impl1.cpp) | |
set_target_properties(IA PROPERTIES POSITION_INDEPENDENT_CODE ON) | |
add_library(IB STATIC impl2.cpp) | |
set(has_iface "$<BOOL:$<TARGET_PROPERTY:POSITION_INDEPENDENT_CODE>>") | |
target_link_libraries(I | |
INTERFACE | |
$<${has_iface}:IA> | |
$<$<NOT:${has_iface}>:IB> | |
) | |
add_executable(Foo foo.cpp) | |
target_link_libraries(Foo PUBLIC I) #links to IB | |
add_library(Bar SHARED bar.cpp) | |
target_link_libraries(Bar PUBLIC I) #links to IA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment