From a1e0a80a15f52f364ed56f1e00b27b901d4499a8 Mon Sep 17 00:00:00 2001 From: Taylor Barnes Date: Tue, 7 Jan 2025 18:56:52 +0000 Subject: [PATCH] Compile static build with position independent code --- MDI_Library/CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MDI_Library/CMakeLists.txt b/MDI_Library/CMakeLists.txt index 56a4ccb..17ac73d 100644 --- a/MDI_Library/CMakeLists.txt +++ b/MDI_Library/CMakeLists.txt @@ -60,9 +60,6 @@ endif() if ( libtype STREQUAL "SHARED" ) set(BUILD_SHARED_LIBS ON) endif() -if ( NOT libtype ) - set(BUILD_SHARED_LIBS ON) -endif() if (BUILD_SHARED_LIBS) set(mdi_STATIC_BUILD OFF) else() @@ -76,6 +73,11 @@ add_library(mdi) target_sources(mdi PRIVATE ${sources}) +# If this is a static library, should compile with position independent code +if ( mdi_STATIC_BUILD ) + set_target_properties(mdi PROPERTIES POSITION_INDEPENDENT_CODE ON) +endif() + # Set API version of MDI Library set_target_properties(mdi PROPERTIES SOVERSION 1) # bump whenever interface has changes or removals