From 6b217db2bca1151d78c4294bb58abf12f58f6796 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Sun, 6 Oct 2024 19:13:14 +0200 Subject: [PATCH] Enable PIC for static library on UNIX systems Added an `endif()` statement to close the `if(WIN32)` block. Introduced a new `if(UNIX)` block to set `POSITION_INDEPENDENT_CODE` to `ON` for the `lib` target. This ensures the static library is compiled with Position Independent Code on UNIX systems, which is necessary for creating shared libraries. --- lib/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 3fd5ebe..3b645aa 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -88,4 +88,8 @@ target_include_directories(lib PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # this is if(WIN32) target_compile_definitions(lib PRIVATE _WIN32API=1) +endif() +if(UNIX) + # Enable PIC for the static library + set_target_properties(lib PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() \ No newline at end of file