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
This commit is contained in:
James Le Cuirot 2014-04-27 00:02:19 +01:00
commit cdc38712e4
3 changed files with 22 additions and 8 deletions

View file

@ -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}