2018-05-09 18:07:18 +08:00
|
|
|
cmake_minimum_required(VERSION 2.6)
|
|
|
|
|
|
|
|
project(box86)
|
|
|
|
|
2018-12-22 01:17:44 +08:00
|
|
|
enable_testing()
|
|
|
|
|
2018-05-09 18:07:18 +08:00
|
|
|
option(PANDORA "Set to ON if targeting an OpenPandora device" ${PANDORA})
|
2018-11-10 16:47:20 +08:00
|
|
|
option(USE_CCACHE "Set to ON to use ccache if present in the system" ${USE_CCACHE})
|
2019-01-14 16:19:18 +08:00
|
|
|
option(LD80BITS "Set to ON if host device have 80bits long double (i.e. i386)" ${LD80BITS})
|
|
|
|
option(NOALIGN "Set to ON if host device doesn't need re-align (i.e. i386)" ${NOALIGN})
|
2019-01-31 18:48:25 +08:00
|
|
|
option(HAVE_TRACE "Set to ON to have Trace ability (needs ZydisInfo library)" ${HAVE_TRACE})
|
2019-02-24 20:58:31 +08:00
|
|
|
option(USE_FLOAT "Set to ON to use only float, no double, in all x87 Emulation" ${USE_FLOAT})
|
2019-06-20 22:50:19 +08:00
|
|
|
option(NOLOADADDR "Set to ON to avoid fixing the load address of Box86" ${NO_LOADAADR})
|
2019-06-23 20:33:54 +08:00
|
|
|
option(X86_CPP_LIBRARY_PRESENT "Set to ON if you have an accessible libstdc++.so.6 32bit ELF lib in your PATH" ${X86_CPP_LIBRARY_PRESENT})
|
2018-05-09 18:07:18 +08:00
|
|
|
|
2019-09-15 15:05:32 +08:00
|
|
|
find_package(PythonInterp)
|
|
|
|
if(NOT PYTHONINTERP_FOUND)
|
|
|
|
message( FATAL_ERROR "You need a Python interpretor, CMake will exit." )
|
|
|
|
endif()
|
|
|
|
|
2018-05-09 18:07:18 +08:00
|
|
|
# Pandora
|
|
|
|
if(PANDORA)
|
|
|
|
add_definitions(-DPANDORA)
|
2019-01-31 00:08:46 +08:00
|
|
|
#add_definitions(-mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize -fsingle-precision-constant -ffast-math)
|
2018-05-09 18:07:18 +08:00
|
|
|
endif()
|
|
|
|
|
2019-01-14 16:19:18 +08:00
|
|
|
if(LD80BITS)
|
|
|
|
add_definitions(-DHAVE_LD80BITS)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOALIGN)
|
|
|
|
add_definitions(-DNOALIGN)
|
|
|
|
endif()
|
|
|
|
|
2019-01-31 18:48:25 +08:00
|
|
|
if(HAVE_TRACE)
|
|
|
|
add_definitions(-DHAVE_TRACE)
|
|
|
|
endif()
|
|
|
|
|
2019-02-24 20:58:31 +08:00
|
|
|
if(USE_FLOAT)
|
|
|
|
add_definitions(-DUSE_FLOAT)
|
|
|
|
endif()
|
|
|
|
|
2019-02-26 04:36:00 +08:00
|
|
|
add_definitions(-g -std=gnu99 -funwind-tables -O3 -fvisibility=hidden)
|
2018-05-09 18:07:18 +08:00
|
|
|
|
2018-11-10 16:47:20 +08:00
|
|
|
if(USE_CCACHE)
|
|
|
|
find_program(CCACHE_FOUND ccache)
|
|
|
|
if(CCACHE_FOUND)
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-07-28 20:01:19 +08:00
|
|
|
include_directories(
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/include"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/generated"
|
|
|
|
)
|
2018-05-09 18:07:18 +08:00
|
|
|
|
2019-01-03 01:28:15 +08:00
|
|
|
set(ELFLOADER_SRC
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/main.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/box86context.c"
|
2019-07-28 20:01:19 +08:00
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/tools/bridge.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/tools/pathcoll.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/tools/fileutils.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/tools/callback.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/tools/box86stack.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/elfs/elfloader.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/elfs/elfparser.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/elfs/elfload_dump.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/librarian/library.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/librarian/librarian.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/generated/wrapper.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/emu/x86emu.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/emu/x86run.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/emu/x86run66.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/emu/x86run_private.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/emu/x86syscall.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/emu/x86primop.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/emu/x86trace.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/emu/x86int3.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/emu/x87emu_private.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/emu/x87run.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/libtools/myalign.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/libtools/threads.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/libtools/sdl1rwops.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/libtools/sdl2rwops.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/libtools/signals.c"
|
2018-05-09 18:07:18 +08:00
|
|
|
)
|
|
|
|
|
2019-01-03 01:28:15 +08:00
|
|
|
set(WRAPPEDS
|
2019-07-28 20:01:19 +08:00
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibc.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibpthread.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibrt.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibgl.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibglu.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibx11.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibasound.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibdl.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibm.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedsdl1.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedsdl1mixer.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedsdl1image.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedsdl1ttf.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedsdl2.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedsdl2mixer.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedsdl2image.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedsmpeg2.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedvorbisfile.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibvorbis.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibogg.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedpng12.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedpng16.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibxxf86vm.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibxrandr.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibxext.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedxinerama.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibxfixes.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibxcursor.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibxrender.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibxi.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibxss.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibxau.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibxdmcp.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibx11xcb.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibxcb.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibz.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedopenal.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedalut.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibjpeg.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedcurl.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedudev0.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappeddbus.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappediconv.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedcrypto.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibssl.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedutil.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibuuid.c"
|
2019-07-29 21:06:49 +08:00
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedlibresolv.c"
|
2019-07-28 20:01:19 +08:00
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedmonounity.c"
|
|
|
|
"${CMAKE_HOME_DIRECTORY}/src/wrapped/wrappedldlinux.c"
|
2019-01-03 01:28:15 +08:00
|
|
|
)
|
2019-07-28 20:01:19 +08:00
|
|
|
set(WRAPPER "${CMAKE_HOME_DIRECTORY}/src/wrapped/generated/wrapper.c" "${CMAKE_HOME_DIRECTORY}/src/wrapped/generated/wrapper.h")
|
2019-09-15 15:05:32 +08:00
|
|
|
add_custom_command(OUTPUT ${WRAPPER} COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_HOME_DIRECTORY}/rebuild_wrappers.py" "${CMAKE_HOME_DIRECTORY}" "PANDORA" "HAVE_LD80BITS" "NOALIGN" "HAVE_TRACE" "USE_FLOAT" MAIN_DEPENDENCY "${CMAKE_HOME_DIRECTORY}/rebuild_wrappers.py" DEPENDS ${WRAPPEDS} BYPRODUCTS ${WRAPPER})
|
2019-01-03 01:28:15 +08:00
|
|
|
|
2019-02-24 20:58:31 +08:00
|
|
|
if(USE_FLOAT)
|
|
|
|
set(BOX86 box86f)
|
2019-08-11 23:13:35 +08:00
|
|
|
elseif(HAVE_TRACE)
|
|
|
|
set(BOX86 box86t)
|
2019-02-24 20:58:31 +08:00
|
|
|
else()
|
|
|
|
set(BOX86 box86)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_executable(${BOX86} ${ELFLOADER_SRC} ${WRAPPEDS})
|
|
|
|
target_link_libraries(${BOX86} m dl rt pthread)
|
2018-12-22 01:17:44 +08:00
|
|
|
|
2019-06-20 17:09:17 +08:00
|
|
|
if(NOT NOLOADADDR)
|
|
|
|
target_link_libraries(${BOX86} -Wl,-Ttext-segment,0xA8000000)
|
|
|
|
endif()
|
2018-12-28 15:45:52 +08:00
|
|
|
|
2019-02-24 20:58:31 +08:00
|
|
|
add_test(test01 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
|
2018-12-22 01:17:44 +08:00
|
|
|
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test01 -D TEST_OUTPUT=tmpfile.txt
|
|
|
|
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref01.txt
|
2018-12-22 03:25:35 +08:00
|
|
|
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|
|
|
|
|
2019-02-24 20:58:31 +08:00
|
|
|
add_test(test02 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
|
2018-12-22 19:29:56 +08:00
|
|
|
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test02 -D TEST_OUTPUT=tmpfile.txt
|
|
|
|
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref02.txt
|
|
|
|
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|
2018-12-22 03:25:35 +08:00
|
|
|
|
2019-02-24 20:58:31 +08:00
|
|
|
add_test(test03 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
|
2018-12-22 19:36:26 +08:00
|
|
|
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test03 -D TEST_OUTPUT=tmpfile.txt
|
|
|
|
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref03.txt
|
|
|
|
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|
2018-12-22 03:25:35 +08:00
|
|
|
|
2019-02-24 20:58:31 +08:00
|
|
|
add_test(test04 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
|
2018-12-22 23:15:26 +08:00
|
|
|
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test04 -D TEST_ARGS2=yeah -D TEST_OUTPUT=tmpfile.txt
|
|
|
|
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref04.txt
|
2018-12-24 18:57:42 +08:00
|
|
|
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|
|
|
|
|
2019-02-24 20:58:31 +08:00
|
|
|
add_test(test05 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
|
2018-12-24 18:57:42 +08:00
|
|
|
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test05 -D TEST_ARGS2=7 -D TEST_OUTPUT=tmpfile.txt
|
|
|
|
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref05.txt
|
2018-12-25 01:24:43 +08:00
|
|
|
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|
|
|
|
|
2019-02-24 20:58:31 +08:00
|
|
|
add_test(test06 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
|
2018-12-25 01:24:43 +08:00
|
|
|
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test06 -D TEST_OUTPUT=tmpfile.txt
|
|
|
|
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref06.txt
|
2018-12-28 06:13:37 +08:00
|
|
|
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|
|
|
|
|
2019-02-24 20:58:31 +08:00
|
|
|
add_test(test07 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
|
2018-12-28 06:13:37 +08:00
|
|
|
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test07 -D TEST_OUTPUT=tmpfile.txt
|
|
|
|
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref07.txt
|
2019-01-03 01:28:15 +08:00
|
|
|
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|
2019-01-13 22:22:41 +08:00
|
|
|
|
2019-02-24 20:58:31 +08:00
|
|
|
add_test(test08 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
|
2019-01-13 22:22:41 +08:00
|
|
|
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test08 -D TEST_OUTPUT=tmpfile.txt
|
|
|
|
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref08.txt
|
|
|
|
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|
2019-01-19 22:07:38 +08:00
|
|
|
|
2019-02-24 20:58:31 +08:00
|
|
|
add_test(test09 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
|
2019-01-19 22:07:38 +08:00
|
|
|
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test09 -D TEST_OUTPUT=tmpfile.txt
|
|
|
|
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref09.txt
|
|
|
|
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|
2019-06-23 20:33:54 +08:00
|
|
|
|
|
|
|
if(X86_CPP_LIBRARY_PRESENT)
|
|
|
|
add_test(test10 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
|
|
|
|
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test10 -D TEST_OUTPUT=tmpfile.txt
|
|
|
|
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref10.txt
|
|
|
|
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|
|
|
|
endif(X86_CPP_LIBRARY_PRESENT)
|
2019-07-01 01:47:54 +08:00
|
|
|
|
|
|
|
add_test(test11 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
|
|
|
|
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test11 -D TEST_OUTPUT=tmpfile.txt
|
|
|
|
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref11.txt
|
|
|
|
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
|