From 426ff28d89a1d54f688e20913e3bf217f2e27cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 16 Jul 2018 12:27:29 +0200 Subject: [PATCH] CMake: Build static libs with fPIC when needed --- lib/instructions/CMakeLists.txt | 3 +++ lib/loader/CMakeLists.txt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/instructions/CMakeLists.txt b/lib/instructions/CMakeLists.txt index a9b0d3e..da6b9fb 100644 --- a/lib/instructions/CMakeLists.txt +++ b/lib/instructions/CMakeLists.txt @@ -12,5 +12,8 @@ add_library( add_library(evmc::instructions ALIAS instructions) set_target_properties(instructions PROPERTIES OUTPUT_NAME evmc-instructions) target_include_directories(instructions PUBLIC $$) +if(BUILD_SHARED_LIBS) + set_target_properties(instructions PROPERTIES POSITION_INDEPENDENT_CODE TRUE) +endif() install(TARGETS instructions EXPORT evmcTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/lib/loader/CMakeLists.txt b/lib/loader/CMakeLists.txt index fbc6b6e..4d06b9b 100644 --- a/lib/loader/CMakeLists.txt +++ b/lib/loader/CMakeLists.txt @@ -12,5 +12,8 @@ add_library(evmc::loader ALIAS loader) set_target_properties(loader PROPERTIES OUTPUT_NAME evmc-loader) target_include_directories(loader PUBLIC $$) 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})