Skip to content

Commit

Permalink
Translations: handle cross compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
MoroccanMalinois committed Aug 21, 2018
1 parent b780cf4 commit 620105e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,7 @@ add_definition_if_function_found(strptime HAVE_STRPTIME)
add_definitions(-DAUTO_INITIALIZE_EASYLOGGINGPP)

# Generate header for embedded translations
include(ExternalProject)
ExternalProject_Add(generate_translations_header
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/translations"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/translations"
INSTALL_COMMAND cmake -E echo "")
add_subdirectory(translations)
include_directories("${CMAKE_CURRENT_BINARY_DIR}/translations")

add_subdirectory(external)
Expand Down
17 changes: 16 additions & 1 deletion translations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ cmake_minimum_required(VERSION 2.8.7)

project(translations)

add_executable(generate_translations_header generate_translations_header.c)
# when crosscompiling import the executable targets from a file
IF(CMAKE_CROSSCOMPILING)
message(WARNING "CrossCompiling")
SET(IMPORT_EXECUTABLES "${CMAKE_CURRENT_BINARY_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Point it to the export file from a native build")
INCLUDE(${IMPORT_EXECUTABLES})
ENDIF(CMAKE_CROSSCOMPILING)

# only build the generator if not crosscompiling
IF(NOT CMAKE_CROSSCOMPILING)
add_executable(generate_translations_header generate_translations_header.c)
ENDIF(NOT CMAKE_CROSSCOMPILING)

find_program(LRELEASE lrelease)
if(LRELEASE STREQUAL "LRELEASE-NOTFOUND")
Expand Down Expand Up @@ -61,3 +71,8 @@ add_custom_command(TARGET generate_translations_header
COMMAND generate_translations_header ${qm_files}
WORKING_DIRECTORY "${CMAKE_CURRENT_BIN_DIR}"
COMMENT "Generating embedded translations header")

# export the generator target to a file, so it can be imported (see above) by another build
IF(NOT CMAKE_CROSSCOMPILING)
EXPORT(TARGETS generate_translations_header FILE ${CMAKE_CURRENT_BINARY_DIR}/ImportExecutables.cmake )
ENDIF(NOT CMAKE_CROSSCOMPILING)

0 comments on commit 620105e

Please sign in to comment.