summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Le Cuirot <chewi@aura-online.co.uk>2014-04-27 00:02:19 +0100
committerJames Le Cuirot <chewi@aura-online.co.uk>2014-04-27 00:02:19 +0100
commitcdc38712e4d359348346758e47e1ebc7d1743f82 (patch)
tree369cb23b079daf840b5df010b7b5e5ca99a3a958
parentfbfa0043279757b2860e846c82cbf55ab92af9b8 (diff)
downloadmariadb-git-cdc38712e4d359348346758e47e1ebc7d1743f82.tar.gz
MySQL Bug #61340: Use CMake EXPORT feature to aid cross-compiling.
This technique is documented at: http://www.cmake.org/Wiki/CMake_Cross_Compiling#Using_executables_in_the_build_created_during_the_build Basic steps are: # mkdir native cross # cd native # cmake /path/to/maria # make IMPORT_EXECUTABLES # cd ../cross # cmake -DCMAKE_TOOLCHAIN_FILE=foo -DIMPORT_EXECUTABLES=/path/to/native/import_executables.cmake /path/to/maria # make
-rw-r--r--CMakeLists.txt10
-rw-r--r--dbug/CMakeLists.txt16
-rw-r--r--sql/CMakeLists.txt4
3 files changed, 22 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f8ebddc70fe..20067ad5363 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -380,6 +380,11 @@ ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO")
SET(CMAKE_CXX_FLAGS_DEBUG "${MY_MAINTAINER_CXX_WARNINGS} ${CMAKE_CXX_FLAGS_DEBUG}")
ENDIF()
+IF(CMAKE_CROSSCOMPILING)
+ SET(IMPORT_EXECUTABLES "IMPORT_EXECUTABLES_NOT_SET" CACHE FILEPATH "Path to import_executables.cmake from a native build")
+ INCLUDE(${IMPORT_EXECUTABLES})
+ENDIF()
+
IF(WITH_UNIT_TESTS)
ENABLE_TESTING()
ADD_SUBDIRECTORY(unittest/mytap)
@@ -443,6 +448,11 @@ IF(WIN32)
ENDIF()
ADD_SUBDIRECTORY(packaging/solaris)
+IF(NOT CMAKE_CROSSCOMPILING)
+ ADD_CUSTOM_TARGET(IMPORT_EXECUTABLES DEPENDS comp_err comp_sql factorial gen_lex_hash)
+ EXPORT(TARGETS comp_err comp_sql factorial gen_lex_hash FILE ${CMAKE_BINARY_DIR}/import_executables.cmake)
+ENDIF()
+
CONFIGURE_FILE(config.h.cmake ${CMAKE_BINARY_DIR}/include/my_config.h)
CONFIGURE_FILE(config.h.cmake ${CMAKE_BINARY_DIR}/include/config.h)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in
diff --git a/dbug/CMakeLists.txt b/dbug/CMakeLists.txt
index fddf234a4f1..bc4288c157c 100644
--- a/dbug/CMakeLists.txt
+++ b/dbug/CMakeLists.txt
@@ -24,8 +24,10 @@ TARGET_LINK_LIBRARIES(dbug mysys)
ADD_EXECUTABLE(tests tests.c)
TARGET_LINK_LIBRARIES(tests dbug)
-ADD_EXECUTABLE(factorial my_main.c factorial.c)
-TARGET_LINK_LIBRARIES(factorial dbug)
+IF(NOT CMAKE_CROSSCOMPILING)
+ ADD_EXECUTABLE(factorial my_main.c factorial.c)
+ TARGET_LINK_LIBRARIES(factorial dbug)
+ENDIF()
IF(NOT WIN32 AND NOT CMAKE_GENERATOR MATCHES Xcode)
FIND_PROGRAM(GROFF groff)
@@ -34,11 +36,11 @@ IF(NOT WIN32 AND NOT CMAKE_GENERATOR MATCHES Xcode)
SET(SOURCE_INC factorial.r main.r example1.r example2.r example3.r)
ADD_CUSTOM_COMMAND(OUTPUT ${OUTPUT_INC}
DEPENDS factorial
- COMMAND ./factorial 1 2 3 4 5 > output1.r
- COMMAND ./factorial -\#t:o 2 3 > output2.r
- COMMAND ./factorial -\#d:t:o 3 > output3.r
- COMMAND ./factorial -\#d,result:o 4 > output4.r
- COMMAND ./factorial -\#d:f,factorial:F:L:o 3 > output5.r)
+ COMMAND factorial 1 2 3 4 5 > output1.r
+ COMMAND factorial -\#t:o 2 3 > output2.r
+ COMMAND factorial -\#d:t:o 3 > output3.r
+ COMMAND factorial -\#d,result:o 4 > output4.r
+ COMMAND factorial -\#d:f,factorial:F:L:o 3 > output5.r)
FOREACH(file ${SOURCE_INC})
STRING(REGEX REPLACE "\\.r" ".c" srcfile ${file})
ADD_CUSTOM_COMMAND(OUTPUT ${file} DEPENDS ${srcfile}
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index ad4b12813d3..7d2b329f300 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -218,7 +218,9 @@ RUN_BISON(
)
# Gen_lex_hash
-ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc)
+IF(NOT CMAKE_CROSSCOMPILING)
+ ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc)
+ENDIF()
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h