Set "position independent code" property unconditionally in os, util
Previously it wasn't set for all platforms, breaking, e.g., Linux on ARM. The property also does the trick for OpenIndiana, so that hack can be removed as well Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
0db99fbf4e
commit
cef4a51810
2 changed files with 3 additions and 15 deletions
|
@ -57,6 +57,7 @@ add_library(OSAPI ${sources})
|
||||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
target_link_libraries(OSAPI INTERFACE Threads::Threads)
|
target_link_libraries(OSAPI INTERFACE Threads::Threads)
|
||||||
|
set_property(TARGET OSAPI PROPERTY POSITION_INDEPENDENT_CODE TRUE)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
# Link with Win32 core-libraries
|
# Link with Win32 core-libraries
|
||||||
|
@ -73,12 +74,7 @@ if(WIN32)
|
||||||
target_compile_definitions(OSAPI PRIVATE _WINSOCK_DEPRECATED_NO_WARNINGS)
|
target_compile_definitions(OSAPI PRIVATE _WINSOCK_DEPRECATED_NO_WARNINGS)
|
||||||
# Disable warnings for deprecated POSIX names.
|
# Disable warnings for deprecated POSIX names.
|
||||||
target_compile_definitions(OSAPI PRIVATE -D_CRT_NONSTDC_NO_DEPRECATE)
|
target_compile_definitions(OSAPI PRIVATE -D_CRT_NONSTDC_NO_DEPRECATE)
|
||||||
elseif(UNIX AND NOT APPLE)
|
elseif(UNIX)
|
||||||
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
|
|
||||||
# Shared libs will have this by default. Static libs need it too on x86_64.
|
|
||||||
set_property(TARGET OSAPI PROPERTY POSITION_INDEPENDENT_CODE TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
check_library_exists(c clock_gettime "" HAVE_CLOCK_GETTIME)
|
check_library_exists(c clock_gettime "" HAVE_CLOCK_GETTIME)
|
||||||
if(NOT HAVE_CLOCK_GETTIME)
|
if(NOT HAVE_CLOCK_GETTIME)
|
||||||
# Before glibc 2.17, clock_gettime was in librt.
|
# Before glibc 2.17, clock_gettime was in librt.
|
||||||
|
@ -95,7 +91,6 @@ endif()
|
||||||
|
|
||||||
if(${CMAKE_C_COMPILER_ID} STREQUAL "SunPro")
|
if(${CMAKE_C_COMPILER_ID} STREQUAL "SunPro")
|
||||||
target_link_libraries(OSAPI INTERFACE -lsocket -lnsl)
|
target_link_libraries(OSAPI INTERFACE -lsocket -lnsl)
|
||||||
add_definitions(-KPIC)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Determine if platform is big or little endian.
|
# Determine if platform is big or little endian.
|
||||||
|
|
|
@ -19,10 +19,7 @@ add_library(util ${srcs_util})
|
||||||
generate_export_header(util EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/exports/util/ut_export.h")
|
generate_export_header(util EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/exports/util/ut_export.h")
|
||||||
target_link_libraries(util PUBLIC OSAPI)
|
target_link_libraries(util PUBLIC OSAPI)
|
||||||
|
|
||||||
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
|
set_property(TARGET util PROPERTY POSITION_INDEPENDENT_CODE TRUE)
|
||||||
# Shared libs will have this by default. Static libs need it too on x86_64.
|
|
||||||
set_property(TARGET util PROPERTY POSITION_INDEPENDENT_CODE TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
util PUBLIC
|
util PUBLIC
|
||||||
|
@ -31,10 +28,6 @@ target_include_directories(
|
||||||
"$<INSTALL_INTERFACE:${INSTALL_PREFIX}/include/>"
|
"$<INSTALL_INTERFACE:${INSTALL_PREFIX}/include/>"
|
||||||
"$<INSTALL_INTERFACE:${INSTALL_PREFIX}/exports/>")
|
"$<INSTALL_INTERFACE:${INSTALL_PREFIX}/exports/>")
|
||||||
|
|
||||||
if(${CMAKE_C_COMPILER_ID} STREQUAL "SunPro")
|
|
||||||
add_definitions(-KPIC)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# TODO: improve test inclusion.
|
# TODO: improve test inclusion.
|
||||||
if((BUILD_TESTING) AND ((NOT DEFINED MSVC_VERSION) OR (MSVC_VERSION GREATER "1800")))
|
if((BUILD_TESTING) AND ((NOT DEFINED MSVC_VERSION) OR (MSVC_VERSION GREATER "1800")))
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue