From 994cec9ee8330951c897fc2de034174eb1457e69 Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Fri, 12 Feb 2021 19:48:41 +0800 Subject: [PATCH] Add Android-specific conditionals. --- CMakeLists.txt | 67 ++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c955156d5..e49d09a0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,10 +145,10 @@ if(MEGA) # automatically. endif() else() - if(MSVC) + if(MSVC or ANDROID) message(FATAL_ERROR " -It is currently only possible to build with megasource on Windows. -Please see http://bitbucket.org/rude/megasource +It is currently only possible to build with megasource on Windows and Android. +Please see https://github.com/love2d/megasource ") endif() @@ -1696,6 +1696,13 @@ if(MSVC) ) endif() +if(ANDROID) + # In Android, the LOVE main entrypoint needs to be compiled + # as shared library, so change the library name and add love.cpp + set(LOVE_LIB_NAME ${LOVE_EXE_NAME}) + set(LOVE_LIB_SRC ${LOVE_LIB_SRC} src/love.cpp) +endif() + add_library(${LOVE_LIB_NAME} SHARED ${LOVE_LIB_SRC} ${LOVE_RC}) target_link_libraries(${LOVE_LIB_NAME} ${LOVE_LINK_LIBRARIES} ${LOVE_3P}) @@ -1711,35 +1718,37 @@ endif() # # love (executable) # -add_executable(${LOVE_EXE_NAME} WIN32 src/love.cpp ${LOVE_RC}) -target_link_libraries(${LOVE_EXE_NAME} ${LOVE_LIB_NAME}) +if(NOT ANDROID) + add_executable(${LOVE_EXE_NAME} WIN32 src/love.cpp ${LOVE_RC}) + target_link_libraries(${LOVE_EXE_NAME} ${LOVE_LIB_NAME}) -if(MSVC) - add_executable(${LOVE_CONSOLE_EXE_NAME} src/love.cpp ${LOVE_RC}) - target_link_libraries(${LOVE_CONSOLE_EXE_NAME} ${LOVE_LIB_NAME}) -endif() - -function(post_step_move_dll ARG_POST_TARGET ARG_TARGET_OR_FILE) - if(TARGET ${ARG_TARGET_OR_FILE}) - add_custom_command(TARGET ${ARG_POST_TARGET} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - $ - ${CMAKE_CURRENT_BINARY_DIR}/$/$) - else() - get_filename_component(TEMP_FILENAME ${ARG_TARGET_OR_FILE} NAME) - add_custom_command(TARGET ${ARG_POST_TARGET} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${ARG_TARGET_OR_FILE} - ${CMAKE_CURRENT_BINARY_DIR}/$/${TEMP_FILENAME}) + if(MSVC) + add_executable(${LOVE_CONSOLE_EXE_NAME} src/love.cpp ${LOVE_RC}) + target_link_libraries(${LOVE_CONSOLE_EXE_NAME} ${LOVE_LIB_NAME}) endif() -endfunction() -# Add post build steps to move the DLLs next to the binary. Otherwise -# running/debugging the binary will not work from inside VS. -if(LOVE_MOVE_DLLS) - foreach(DLL ${LOVE_MOVE_DLLS}) - post_step_move_dll(love ${DLL}) - endforeach() + function(post_step_move_dll ARG_POST_TARGET ARG_TARGET_OR_FILE) + if(TARGET ${ARG_TARGET_OR_FILE}) + add_custom_command(TARGET ${ARG_POST_TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + $ + ${CMAKE_CURRENT_BINARY_DIR}/$/$) + else() + get_filename_component(TEMP_FILENAME ${ARG_TARGET_OR_FILE} NAME) + add_custom_command(TARGET ${ARG_POST_TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${ARG_TARGET_OR_FILE} + ${CMAKE_CURRENT_BINARY_DIR}/$/${TEMP_FILENAME}) + endif() + endfunction() + + # Add post build steps to move the DLLs next to the binary. Otherwise + # running/debugging the binary will not work from inside VS. + if(LOVE_MOVE_DLLS) + foreach(DLL ${LOVE_MOVE_DLLS}) + post_step_move_dll(love ${DLL}) + endforeach() + endif() endif() if (NOT MSVC)