From 90265dd628f3146428690855c5340ba35035d002 Mon Sep 17 00:00:00 2001 From: seleznevae Date: Sat, 22 Feb 2020 13:33:36 +0300 Subject: [PATCH] [A] Add option `POSITION_INDEPENDENT_CODE` for library target (libfort::fort). --- ChangeLog.md | 1 + lib/CMakeLists.txt | 7 +++++-- tests/package_tests/CMakeLists.txt | 9 +++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 6b85c0d..0248ee6 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -17,6 +17,7 @@ - Refactoring of code that uses vectors. - Add target export in cmake. - Add option `FORT_ENABLE_TESTING` to turn on/off building tests and examples. +- Add option `POSITION_INDEPENDENT_CODE` for library target (libfort::fort). ### Docs diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 0ed5b4a..c171655 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -11,8 +11,11 @@ target_include_directories(fort ) set_target_properties(fort - PROPERTIES VERSION ${libfort_VERSION} - SOVERSION ${libfort_SOVERSION}) + PROPERTIES + VERSION ${libfort_VERSION} + SOVERSION ${libfort_SOVERSION} + POSITION_INDEPENDENT_CODE ON +) if(NOT FORT_HAVE_WCHAR) target_compile_definitions(fort diff --git a/tests/package_tests/CMakeLists.txt b/tests/package_tests/CMakeLists.txt index 247bbca..5584df3 100644 --- a/tests/package_tests/CMakeLists.txt +++ b/tests/package_tests/CMakeLists.txt @@ -28,11 +28,16 @@ target_link_libraries(foo-app add_library(foo-lib foo-lib.cpp) target_link_libraries(foo-lib - PRIVATE libfort::fort) + PRIVATE libfort::fort) + +add_library(foo-lib-shared SHARED + foo-lib.cpp) +target_link_libraries(foo-lib-shared + PRIVATE libfort::fort) include(GNUInstallDirs) install( - TARGETS foo-lib + TARGETS foo-lib foo-lib-shared EXPORT ${PROJECT_NAME}-targets INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}