Skip to content

Commit

Permalink
only compile gettext & libiconv on Android & macOS (#1754)
Browse files Browse the repository at this point in the history
Not needed on other platforms, fix regression introduced in #1690.
  • Loading branch information
benoit-pierre committed Mar 31, 2024
1 parent 366d9c9 commit 4a94e03
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 36 deletions.
5 changes: 3 additions & 2 deletions Makefile.third
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ $(LIBGETTEXT): $(LIBICONV) $(THIRDPARTY_DIR)/gettext/*.*
$(CURDIR)/thirdparty/gettext && \
$(CMAKE_MAKE_PROGRAM) $(CMAKE_MAKE_PROGRAM_FLAGS)

$(GLIB): $(LIBICONV) $(LIBGETTEXT) $(THIRDPARTY_DIR)/glib/*.*
$(GLIB): $(if $(or $(ANDROID),$(DARWIN)),$(LIBICONV) $(LIBGETTEXT)) $(THIRDPARTY_DIR)/glib/*.*
install -d $(GLIB_BUILD_DIR)
-rm -f $(GLIB_DIR)/../glib-stamp/glib-install
cd $(GLIB_BUILD_DIR) && \
Expand All @@ -419,7 +419,8 @@ $(GLIB): $(LIBICONV) $(LIBGETTEXT) $(THIRDPARTY_DIR)/glib/*.*
-DCFLAGS='$(CFLAGS)' \
-DLDFLAGS='$(LDFLAGS)' \
-DGETTEXT_DIR='$(GETTEXT_DIR)' \
-DLIBICONV_DIR='$(LIBICONV_DIR)' -DWITH_LIBICONV='gnu' \
-DLIBICONV_DIR='$(LIBICONV_DIR)' \
-DWITH_LIBICONV='$(if $(or $(ANDROID),$(DARWIN)),gnu,no)' \
-DHOST_OPTS='$(if $(EMULATE_READER),,--cache-file=arm_cache.conf)' \
$(CURDIR)/$(THIRDPARTY_DIR)/glib && \
$(CMAKE_MAKE_PROGRAM) $(CMAKE_MAKE_PROGRAM_FLAGS)
Expand Down
54 changes: 20 additions & 34 deletions thirdparty/sdcv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,52 +27,38 @@ if(DEFINED ENV{CMAKE_TCF})
endif()
list(APPEND CMAKE_ARGS "-DCMAKE_SKIP_RPATH=TRUE")

# because cmake needs all kinds of annoying special cmake variables
# Compiler and linker flags
if(DEFINED ENV{DARWIN})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreFoundation -framework CoreServices -framework Security")
endif()

if(DEFINED ENV{ANDROID})
set(CMAKE_SYSTEM_NAME Android)
# Android 5+ requires PIE (yum!)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE")
endif()
list(APPEND CMAKE_ARGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}")

# took me an eternity to find $<SEMICOLON>
# important docs here https://cmake.org/cmake/help/v2.8.11/cmake.html#command:add_custom_command
string(APPEND GLIB2_INCLUDE_DIRS
"${GLIB_DIR}/include/glib-2.0"
$<SEMICOLON>
"${GLIB_DIR}/lib/glib-2.0/include"
$<SEMICOLON>
"${GETTEXT_DIR}/include"
$<SEMICOLON>
"${LIBICONV_DIR}/include"
)
list(APPEND CMAKE_ARGS "-DGLIB2_INCLUDE_DIRS=${GLIB2_INCLUDE_DIRS}")

# For some reason this doesn't actually work and CMake keeps finding mostly .so
# Which is funny, because the .a is in the *same* directory. Just saying.
# Instead we add semi-hardcoded references to the right libraries in GLIB2_LIBRARIES
# glib2 also needs to link with libiconv and gettext
# this is a fairly clean hack
# CMAKE_CXX_FLAGS with -I and -L doesn't seem to have much of an effect
string(APPEND GLIB2_LIBRARIES
"${GLIB}"
$<SEMICOLON>
"${GETTEXT}"
$<SEMICOLON>
"${LIBICONV}"
)
# Need pthread library and rt library on old glibc (for `clock_gettime`).
if(NOT DEFINED ENV{DARWIN})
string(APPEND GLIB2_LIBRARIES "${GLIB}")
if(DEFINED ENV{ANDROID} OR DEFINED ENV{DARWIN})
string(APPEND GLIB2_INCLUDE_DIRS
$<SEMICOLON> "${GETTEXT_DIR}/include"
$<SEMICOLON> "${LIBICONV_DIR}/include"
)
string(APPEND GLIB2_LIBRARIES
$<SEMICOLON> "${GETTEXT}"
$<SEMICOLON> "${LIBICONV}"
)
endif()
if(DEFINED ENV{DARWIN})
string(APPEND GLIB2_LIBRARIES
$<SEMICOLON> "-framework CoreFoundation"
$<SEMICOLON> "-framework CoreServices"
$<SEMICOLON> "-framework Security"
)
else()
# Need pthread library and rt library on old glibc (for `clock_gettime`).
string(APPEND GLIB2_LIBRARIES $<SEMICOLON> -pthread)
if(NOT DEFINED ENV{ANDROID})
string(APPEND GLIB2_LIBRARIES $<SEMICOLON> -lrt)
endif()
endif()
list(APPEND CMAKE_ARGS "-DGLIB2_INCLUDE_DIRS=${GLIB2_INCLUDE_DIRS}")
list(APPEND CMAKE_ARGS "-DGLIB2_LIBRARIES=${GLIB2_LIBRARIES}")

list(APPEND CMAKE_ARGS "-DENABLE_NLS=False")
Expand Down

0 comments on commit 4a94e03

Please sign in to comment.