CMake: Build static libs with fPIC when needed

This commit is contained in:
Paweł Bylica 2018-07-16 12:27:29 +02:00
parent 97221d2db7
commit 426ff28d89
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
2 changed files with 6 additions and 0 deletions

View File

@ -12,5 +12,8 @@ add_library(
add_library(evmc::instructions ALIAS instructions) add_library(evmc::instructions ALIAS instructions)
set_target_properties(instructions PROPERTIES OUTPUT_NAME evmc-instructions) set_target_properties(instructions PROPERTIES OUTPUT_NAME evmc-instructions)
target_include_directories(instructions PUBLIC $<BUILD_INTERFACE:${include_dir}>$<INSTALL_INTERFACE:include>) target_include_directories(instructions PUBLIC $<BUILD_INTERFACE:${include_dir}>$<INSTALL_INTERFACE:include>)
if(BUILD_SHARED_LIBS)
set_target_properties(instructions PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
endif()
install(TARGETS instructions EXPORT evmcTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(TARGETS instructions EXPORT evmcTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@ -12,5 +12,8 @@ add_library(evmc::loader ALIAS loader)
set_target_properties(loader PROPERTIES OUTPUT_NAME evmc-loader) set_target_properties(loader PROPERTIES OUTPUT_NAME evmc-loader)
target_include_directories(loader PUBLIC $<BUILD_INTERFACE:${include_dir}>$<INSTALL_INTERFACE:include>) target_include_directories(loader PUBLIC $<BUILD_INTERFACE:${include_dir}>$<INSTALL_INTERFACE:include>)
target_link_libraries(loader INTERFACE ${CMAKE_DL_LIBS}) target_link_libraries(loader INTERFACE ${CMAKE_DL_LIBS})
if(BUILD_SHARED_LIBS)
set_target_properties(loader PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
endif()
install(TARGETS loader EXPORT evmcTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(TARGETS loader EXPORT evmcTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})