From e9c672b29771433cd73e1bd560da62049e9bf38c Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 18 Feb 2024 19:14:51 +0100 Subject: [PATCH 1/2] Fix build with cmake flag BUILD_SHARED_LIBS=ON Always build opencs-lib as static library instead of BUILD_SHARED_LIBS deciding whether it's static or shared library. --- .gitlab-ci.yml | 1 + CI/before_script.linux.sh | 2 +- apps/opencs/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7dc69484c6d..1a8e22ed826 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -210,6 +210,7 @@ Ubuntu_GCC_Debug: CCACHE_SIZE: 3G CMAKE_BUILD_TYPE: Debug CMAKE_CXX_FLAGS_DEBUG: -O0 + BUILD_SHARED_LIBS: 1 # When CCache doesn't exist (e.g. first build on a fork), build takes more than 1h, which is the default for forks. timeout: 2h diff --git a/CI/before_script.linux.sh b/CI/before_script.linux.sh index 0edd38628f8..ab61ed3e596 100755 --- a/CI/before_script.linux.sh +++ b/CI/before_script.linux.sh @@ -22,7 +22,7 @@ declare -a CMAKE_CONF_OPTS=( -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=install - -DBUILD_SHARED_LIBS=OFF + -DBUILD_SHARED_LIBS="${BUILD_SHARED_LIBS:-OFF}" -DUSE_SYSTEM_TINYXML=ON -DOPENMW_USE_SYSTEM_RECASTNAVIGATION=ON -DOPENMW_CXX_FLAGS="-Werror -Werror=implicit-fallthrough" # flags specific to OpenMW project diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 610c5157aac..9bf02e10c9d 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -172,7 +172,7 @@ else() set (OPENCS_OPENMW_CFG "") endif(APPLE) -add_library(openmw-cs-lib +add_library(openmw-cs-lib STATIC ${OPENCS_SRC} ${OPENCS_UI_HDR} ${OPENCS_MOC_SRC} From efbc37d22fec87633e39a02fc19a54908201cccb Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 18 Feb 2024 19:36:53 +0100 Subject: [PATCH 2/2] Build components with position independent code only for Android openmw is build as shared library with position independent code enabled there so linked static libraries need to have this too. --- components/CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 317786e96a1..dc195d8d0b9 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -526,11 +526,9 @@ if (USE_QT) QT_WRAP_UI(ESM_UI_HDR ${ESM_UI}) endif() -if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" AND NOT APPLE) - add_definitions(-fPIC) - endif() -endif () +if (ANDROID) + set_property(TARGET components PROPERTY POSTION_INDEPENDENT_CODE ON) +endif() include_directories(${BULLET_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})