summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglx22 <glx@openttd.org>2020-07-01 02:52:32 +0200
committerOwen Rudge <owen@owenrudge.net>2020-12-04 09:49:31 +0000
commita06fe8e8a7d749f1fbd08102a9516acd51171b24 (patch)
tree97b90a5a5229c8c1fae0729cf8ccba18d08243f5 /src
parent0b2dd2c5cd39833945fcea3a39811898bf40c6b5 (diff)
downloadopenttd-a06fe8e8a7d749f1fbd08102a9516acd51171b24.tar.xz
Fix: [CMake] cross-compiling requires native tools
Diffstat (limited to 'src')
-rw-r--r--src/lang/CMakeLists.txt4
-rw-r--r--src/settingsgen/CMakeLists.txt25
-rw-r--r--src/strgen/CMakeLists.txt30
-rw-r--r--src/table/CMakeLists.txt4
4 files changed, 40 insertions, 23 deletions
diff --git a/src/lang/CMakeLists.txt b/src/lang/CMakeLists.txt
index d9243b531..75d06f530 100644
--- a/src/lang/CMakeLists.txt
+++ b/src/lang/CMakeLists.txt
@@ -59,6 +59,10 @@ set(LANG_SOURCE_FILES
set(LANG_BINARY_DIR ${CMAKE_BINARY_DIR}/lang)
+if (HOST_BINARY_DIR)
+ include(${HOST_BINARY_DIR}/strgen.cmake)
+endif()
+
# Walk over all the (finished) language files, and generate a command to compile them
foreach(LANG_SOURCE_FILE IN LISTS LANG_SOURCE_FILES)
get_filename_component(LANG_SOURCE_FILE_NAME_WE ${LANG_SOURCE_FILE} NAME_WE)
diff --git a/src/settingsgen/CMakeLists.txt b/src/settingsgen/CMakeLists.txt
index e17b8ad6b..69b209201 100644
--- a/src/settingsgen/CMakeLists.txt
+++ b/src/settingsgen/CMakeLists.txt
@@ -1,13 +1,18 @@
cmake_minimum_required(VERSION 3.5)
-project(settingsgen)
+if (NOT HOST_BINARY_DIR)
+ project(settingsgen)
-set(sourcefiles
- settingsgen.cpp
- ../core/alloc_func.cpp
- ../misc/getoptdata.cpp
- ../ini_load.cpp
- ../string.cpp
-)
-add_definitions(-DSETTINGSGEN)
-add_executable(settingsgen ${sourcefiles})
+ set(sourcefiles
+ settingsgen.cpp
+ ../core/alloc_func.cpp
+ ../misc/getoptdata.cpp
+ ../ini_load.cpp
+ ../string.cpp
+ )
+ add_definitions(-DSETTINGSGEN)
+ add_executable(settingsgen ${sourcefiles})
+
+ export(TARGETS settingsgen FILE ${CMAKE_BINARY_DIR}/settingsgen.cmake)
+ add_dependencies(tools settingsgen)
+endif()
diff --git a/src/strgen/CMakeLists.txt b/src/strgen/CMakeLists.txt
index b8f61cde3..c638b5c6e 100644
--- a/src/strgen/CMakeLists.txt
+++ b/src/strgen/CMakeLists.txt
@@ -1,22 +1,26 @@
cmake_minimum_required(VERSION 3.5)
-project(strgen)
+if (NOT HOST_BINARY_DIR)
+ project(strgen)
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
-set(sourcefiles
- strgen.cpp
- strgen_base.cpp
- ../core/alloc_func.cpp
- ../misc/getoptdata.cpp
- ../string.cpp
-)
-add_definitions(-DSTRGEN)
-add_executable(strgen ${sourcefiles})
+ set(sourcefiles
+ strgen.cpp
+ strgen_base.cpp
+ ../core/alloc_func.cpp
+ ../misc/getoptdata.cpp
+ ../string.cpp
+ )
+ add_definitions(-DSTRGEN)
+ add_executable(strgen ${sourcefiles})
-include(Endian)
-add_endian_definition()
+ include(Endian)
+ add_endian_definition()
+ export(TARGETS strgen FILE ${CMAKE_BINARY_DIR}/strgen.cmake)
+ add_dependencies(tools strgen)
+endif()
# Source Files
add_files(strgen_base.cpp)
diff --git a/src/table/CMakeLists.txt b/src/table/CMakeLists.txt
index 23b4724e3..e63337b8a 100644
--- a/src/table/CMakeLists.txt
+++ b/src/table/CMakeLists.txt
@@ -11,6 +11,10 @@ set(TABLE_INI_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/window_settings.ini
)
+if (HOST_BINARY_DIR)
+ include(${HOST_BINARY_DIR}/settingsgen.cmake)
+endif()
+
# Generate a command and target to create the settings table
add_custom_command_timestamp(OUTPUT ${TABLE_BINARY_DIR}/settings.h
COMMAND ${CMAKE_COMMAND} -E make_directory ${TABLE_BINARY_DIR}