2016-07-03 20:34:31 +02:00
|
|
|
if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
|
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
add_definitions(-D_XOPEN_SOURCE=600)
|
2016-07-02 23:23:08 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
add_definitions(-DLIBSUPERDERPY_ORIENTATION_${LIBSUPERDERPY_ORIENTATION}=true)
|
2017-06-26 03:18:54 +02:00
|
|
|
|
2017-08-24 21:09:07 +02:00
|
|
|
set(EMSCRIPTEN_TOTAL_MEMORY "32" CACHE STRING "Amount of memory allocated by Emscripten (MB, must be multiple of 16)" )
|
|
|
|
|
2017-09-10 21:35:14 +02:00
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
set(CMAKE_C_STANDARD_REQUIRED true)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
2017-08-19 01:26:53 +02:00
|
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O1 -fno-optimize-sibling-calls -fno-omit-frame-pointer -fsanitize=leak -DLEAK_SANITIZER=1 -fno-common -fsanitize-recover=all")
|
|
|
|
if(APPLE)
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,error")
|
|
|
|
else(APPLE)
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
|
|
|
|
endif(APPLE)
|
2016-08-11 19:32:49 +02:00
|
|
|
|
2017-09-10 22:53:41 +02:00
|
|
|
set(USE_CLANG_TIDY "yes" CACHE STRING "Analyze the code with clang-tidy" )
|
2018-07-04 18:51:52 +02:00
|
|
|
if(USE_CLANG_TIDY AND NOT MINGW)
|
2017-09-10 22:53:41 +02:00
|
|
|
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable")
|
|
|
|
if(NOT CLANG_TIDY_EXE)
|
|
|
|
message(STATUS "clang-tidy not found, analysis disabled")
|
|
|
|
else()
|
2018-07-04 19:08:39 +02:00
|
|
|
set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY_EXE}" "-checks=*,-clang-analyzer-alpha.*,-hicpp-no-assembler,-google-readability-todo,-performance-type-promotion-in-math-fn,-misc-unused-parameters,-cert-msc30-c,-cert-msc50-cpp,-hicpp-signed-bitwise")
|
2017-09-10 22:53:41 +02:00
|
|
|
endif()
|
2017-09-10 21:35:14 +02:00
|
|
|
endif()
|
|
|
|
|
2018-07-06 15:43:56 +02:00
|
|
|
set(LIBSUPERDERPY_STATIC_DEPS "no" CACHE STRING "Link dependencies (e.g. Allegro) statically." )
|
|
|
|
if(LIBSUPERDERPY_STATIC_DEPS)
|
|
|
|
SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a)
|
|
|
|
endif(LIBSUPERDERPY_STATIC_DEPS)
|
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
if(APPLE)
|
|
|
|
if(CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
|
|
|
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}")
|
|
|
|
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIBSUPERDERPY_GAMENAME}.app/Contents/MacOS/")
|
|
|
|
endif(CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
|
2016-07-05 01:30:06 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
set(MACOSX_BUNDLE_ICON_FILE ${LIBSUPERDERPY_GAMENAME})
|
|
|
|
set(MACOSX_BUNDLE_BUNDLE_NAME ${LIBSUPERDERPY_GAMENAME_PRETTY})
|
2016-07-05 01:30:06 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
endif(APPLE)
|
2016-07-02 23:23:08 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
include_directories("libsuperderpy/src")
|
2016-07-02 23:23:08 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
if(MINGW)
|
|
|
|
# Guess MINGDIR from the value of CMAKE_C_COMPILER if it's not set.
|
|
|
|
if(NOT MINGDIR)
|
|
|
|
if("$ENV{MINGDIR}" STREQUAL "")
|
|
|
|
string(REGEX REPLACE "/bin/[^/]*$" "" MINGDIR "${CMAKE_C_COMPILER}")
|
|
|
|
message(STATUS "Guessed MinGW directory: ${MINGDIR}")
|
|
|
|
else("$ENV{MINGDIR}" STREQUAL "")
|
|
|
|
file(TO_CMAKE_PATH "$ENV{MINGDIR}" MINGDIR)
|
|
|
|
message(STATUS "Using MINGDIR: ${MINGDIR}")
|
|
|
|
endif("$ENV{MINGDIR}" STREQUAL "")
|
|
|
|
endif(NOT MINGDIR)
|
2016-07-02 23:23:08 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
# Search in MINGDIR for headers and libraries.
|
|
|
|
set(CMAKE_PREFIX_PATH "${MINGDIR}")
|
2016-07-02 23:23:08 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
endif(MINGW)
|
2016-07-02 23:23:08 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib/${LIBSUPERDERPY_GAMENAME}:\$ORIGIN/gamestates:\$ORIGIN:\$ORIGIN/../lib:\$ORIGIN/lib:\$ORIGIN/bin")
|
2016-07-02 23:23:08 +02:00
|
|
|
|
2017-08-24 21:09:07 +02:00
|
|
|
if(EMSCRIPTEN)
|
2018-07-06 22:07:13 +02:00
|
|
|
set(CMAKE_EXECUTABLE_SUFFIX ".bc")
|
|
|
|
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -s SIDE_MODULE=1")
|
2018-07-06 03:55:07 +02:00
|
|
|
set(EMSCRIPTEN_USE_FLAGS -s USE_SDL=2 -s USE_FREETYPE=1 -s USE_LIBPNG=1 -s USE_ZLIB=1 -s USE_OGG=1 -s USE_VORBIS=1 -s FULL_ES2=1 -s WASM=0)
|
2018-07-06 22:07:13 +02:00
|
|
|
set(LIBSUPERDERPY_EMSCRIPTEN_MODE "asm.js" CACHE STRING "Emscripten compilation mode (JavaScript or WebAssembly)")
|
|
|
|
set_property(CACHE LIBSUPERDERPY_EMSCRIPTEN_MODE PROPERTY STRINGS "asm.js;wasm")
|
|
|
|
if("${LIBSUPERDERPY_EMSCRIPTEN_MODE}" STREQUAL "wasm")
|
|
|
|
# https://github.com/kripken/emscripten/issues/5436
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -s WASM=1")
|
|
|
|
set(EMSCRIPTEN_USE_FLAGS ${EMSCRIPTEN_USE_FLAGS} -s WASM=1)
|
|
|
|
set(CMAKE_SHARED_MODULE_SUFFIX ".wasm")
|
2018-07-06 23:17:09 +02:00
|
|
|
add_definitions(-DLIBSUPERDERPY_WASM=1)
|
2018-07-06 22:07:13 +02:00
|
|
|
else()
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -s WASM=0")
|
|
|
|
set(EMSCRIPTEN_USE_FLAGS ${EMSCRIPTEN_USE_FLAGS} -s WASM=0)
|
|
|
|
set(CMAKE_SHARED_MODULE_SUFFIX ".js")
|
|
|
|
endif()
|
2018-07-06 04:04:05 +02:00
|
|
|
set(LIBSUPERDERPY_USE_WEBGL2 "no" CACHE STRING "Use WebGL 2 context")
|
|
|
|
if(LIBSUPERDERPY_USE_WEBGL2)
|
|
|
|
set(EMSCRIPTEN_USE_FLAGS ${EMSCRIPTEN_USE_FLAGS} -s USE_WEBGL2=1)
|
|
|
|
endif(LIBSUPERDERPY_USE_WEBGL2)
|
2017-08-24 21:09:07 +02:00
|
|
|
# FIXME
|
|
|
|
set(ALLEGRO5_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
|
|
|
set(ALLEGRO5_ACODEC_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
|
|
|
set(ALLEGRO5_FONT_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
|
|
|
set(ALLEGRO5_TTF_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
|
|
|
set(ALLEGRO5_PRIMITIVES_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
|
|
|
set(ALLEGRO5_AUDIO_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
|
|
|
set(ALLEGRO5_ACODEC_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
|
|
|
set(ALLEGRO5_IMAGE_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
|
|
|
set(ALLEGRO5_COLOR_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
|
|
|
set(ALLEGRO5_VIDEO_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
|
|
|
|
|
|
|
if(CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
|
|
|
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/output")
|
|
|
|
endif(CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
|
|
|
|
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
set(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
2017-09-09 00:11:43 +02:00
|
|
|
if(ANDROID OR EMSCRIPTEN)
|
|
|
|
add_definitions(-DLIBSUPERDERPY_SINGLE_THREAD=1)
|
|
|
|
endif()
|
|
|
|
|
2017-08-24 21:09:07 +02:00
|
|
|
find_package(Allegro5 REQUIRED)
|
2017-07-22 21:01:29 +02:00
|
|
|
find_package(Allegro5Font REQUIRED)
|
|
|
|
find_package(Allegro5TTF REQUIRED)
|
|
|
|
find_package(Allegro5Primitives REQUIRED)
|
|
|
|
find_package(Allegro5Audio REQUIRED)
|
|
|
|
find_package(Allegro5ACodec REQUIRED)
|
|
|
|
find_package(Allegro5Image REQUIRED)
|
|
|
|
find_package(Allegro5Color REQUIRED)
|
|
|
|
find_package(Allegro5Video REQUIRED)
|
|
|
|
if(APPLE)
|
|
|
|
find_package(Allegro5Main)
|
|
|
|
endif(APPLE)
|
2016-07-02 23:23:08 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
include_directories(${ALLEGRO5_INCLUDE_DIR} ${ALLEGRO5_FONT_INCLUDE_DIR} ${ALLEGRO5_TTF_INCLUDE_DIR} ${ALLEGRO5_PRIMITIVES_INCLUDE_DIR} ${ALLEGRO5_AUDIO_INCLUDE_DIR} ${ALLEGRO5_ACODEC_INCLUDE_DIR} ${ALLEGRO5_VIDEO_INCLUDE_DIR} ${ALLEGRO5_IMAGE_INCLUDE_DIR})
|
2016-11-06 03:10:43 +01:00
|
|
|
|
2018-05-16 20:51:38 +02:00
|
|
|
MACRO(register_gamestate name sources)
|
2017-07-22 21:01:29 +02:00
|
|
|
|
2018-07-06 22:07:13 +02:00
|
|
|
add_library("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" MODULE ${sources})
|
2016-07-02 23:23:08 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
set_target_properties("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" PROPERTIES PREFIX "")
|
|
|
|
|
|
|
|
target_link_libraries("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_VIDEO_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} ${ALLEGRO5_COLOR_LIBRARIES} m libsuperderpy)
|
2016-07-02 23:23:08 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
if (TARGET libsuperderpy-${LIBSUPERDERPY_GAMENAME})
|
|
|
|
target_link_libraries("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" libsuperderpy-${LIBSUPERDERPY_GAMENAME})
|
2018-07-06 22:07:13 +02:00
|
|
|
endif(TARGET libsuperderpy-${LIBSUPERDERPY_GAMENAME})
|
2017-07-22 21:01:29 +02:00
|
|
|
|
|
|
|
install(TARGETS "libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" DESTINATION ${LIB_INSTALL_DIR})
|
|
|
|
|
|
|
|
if (ANDROID)
|
|
|
|
add_dependencies(${LIBSUPERDERPY_GAMENAME}_apk "libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}")
|
|
|
|
endif()
|
|
|
|
|
2017-08-24 21:09:07 +02:00
|
|
|
if (EMSCRIPTEN)
|
|
|
|
string(TOUPPER "CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}" CFLAGS)
|
|
|
|
string(REPLACE " " ";" CFLAGS_L ${CMAKE_C_FLAGS})
|
|
|
|
set(CFLAGS_LIST ${CFLAGS_L} ${${CFLAGS}})
|
|
|
|
|
2018-07-06 22:07:13 +02:00
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/src/gamestates/libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}${CMAKE_SHARED_MODULE_SUFFIX}" DESTINATION ${CMAKE_INSTALL_PREFIX}/${LIBSUPERDERPY_GAMENAME}/gamestates)
|
|
|
|
endif()
|
2017-08-24 21:09:07 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
MACRO(libsuperderpy_copy EXECUTABLE)
|
|
|
|
|
2018-07-06 22:07:13 +02:00
|
|
|
if (NOT APPLE AND NOT ANDROID)
|
2017-07-22 21:01:29 +02:00
|
|
|
add_custom_command(TARGET "${EXECUTABLE}" PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "../libsuperderpy/src/libsuperderpy${CMAKE_SHARED_LIBRARY_SUFFIX}" $<TARGET_FILE_DIR:${EXECUTABLE}>)
|
|
|
|
endif (NOT APPLE AND NOT ANDROID)
|
|
|
|
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
include(InstallRequiredSystemLibraries)
|
|
|
|
|
|
|
|
if(LIBSUPERDERPY_GAMENAME)
|
|
|
|
configure_file("${CMAKE_SOURCE_DIR}/libsuperderpy/src/defines.h.in" "${CMAKE_BINARY_DIR}/gen/defines.h")
|
|
|
|
include_directories("${CMAKE_BINARY_DIR}/gen")
|
|
|
|
endif(LIBSUPERDERPY_GAMENAME)
|
2016-11-07 01:45:12 +01:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
if (NOT DEFINED LIBSUPERDERPY_VERSION)
|
|
|
|
set(LIBSUPERDERPY_VERSION "0.1")
|
|
|
|
endif(NOT DEFINED LIBSUPERDERPY_VERSION)
|
2017-07-22 01:12:05 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
if (NOT DEFINED LIBSUPERDERPY_RELEASE)
|
|
|
|
set(LIBSUPERDERPY_RELEASE "1")
|
|
|
|
endif(NOT DEFINED LIBSUPERDERPY_RELEASE)
|
2017-06-26 15:40:04 +02:00
|
|
|
|
2017-08-24 21:09:07 +02:00
|
|
|
if (ANDROID OR EMSCRIPTEN)
|
|
|
|
if (ANDROID)
|
2017-09-25 00:36:45 +02:00
|
|
|
set(FLACTOOGG_DATADIR "${CMAKE_BINARY_DIR}/android/assets/data")
|
2017-08-24 21:09:07 +02:00
|
|
|
set(FLACTOOGG_DEPEND "")
|
|
|
|
else (EMSCRIPTEN)
|
|
|
|
set(FLACTOOGG_DATADIR "${CMAKE_INSTALL_PREFIX}/${LIBSUPERDERPY_GAMENAME}/data")
|
|
|
|
set(FLACTOOGG_DEPEND ${LIBSUPERDERPY_GAMENAME}_install)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_custom_target(${LIBSUPERDERPY_GAMENAME}_flac_to_ogg
|
|
|
|
DEPENDS ${FLACTOOGG_DEPEND}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -DDATADIR=${FLACTOOGG_DATADIR} -P ${CMAKE_SOURCE_DIR}/libsuperderpy/cmake/FlacToOgg.cmake)
|
|
|
|
|
|
|
|
endif(ANDROID OR EMSCRIPTEN)
|
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
MACRO(add_libsuperderpy_target EXECUTABLE_SRC_LIST)
|
2018-07-06 22:07:13 +02:00
|
|
|
if(ANDROID)
|
2017-07-22 21:01:29 +02:00
|
|
|
set(EXECUTABLE game)
|
|
|
|
add_library(${EXECUTABLE} SHARED ${EXECUTABLE_SRC_LIST})
|
2016-11-07 01:45:12 +01:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
set(APK_PATH ${CMAKE_BINARY_DIR}/android/bin/${LIBSUPERDERPY_GAMENAME}-debug.apk)
|
2016-11-07 01:45:12 +01:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
add_custom_target(${LIBSUPERDERPY_GAMENAME}_apk ALL
|
2017-08-24 21:09:07 +02:00
|
|
|
DEPENDS ${EXECUTABLE} ${LIBSUPERDERPY_GAMENAME}_flac_to_ogg
|
|
|
|
BYPRODUCTS ${APK_PATH}
|
2017-07-22 21:01:29 +02:00
|
|
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/android"
|
|
|
|
COMMAND ${ANT_COMMAND} debug
|
|
|
|
)
|
|
|
|
|
2017-08-24 21:09:07 +02:00
|
|
|
add_custom_target(${LIBSUPERDERPY_GAMENAME}_install_apk
|
2017-07-22 21:01:29 +02:00
|
|
|
DEPENDS ${LIBSUPERDERPY_GAMENAME}_apk
|
|
|
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/android"
|
|
|
|
COMMAND adb -d install -r ${APK_PATH}
|
|
|
|
)
|
2016-11-07 01:45:12 +01:00
|
|
|
|
2017-08-24 21:09:07 +02:00
|
|
|
add_custom_target(${LIBSUPERDERPY_GAMENAME}_run_apk
|
|
|
|
DEPENDS ${LIBSUPERDERPY_GAMENAME}_install_apk
|
2017-07-22 21:01:29 +02:00
|
|
|
COMMAND adb -d shell
|
|
|
|
'am start -a android.intent.action.MAIN -n net.dosowisko.${LIBSUPERDERPY_GAMENAME}/.SuperDerpyActivity'
|
|
|
|
)
|
|
|
|
|
|
|
|
else(ANDROID)
|
|
|
|
add_executable(${EXECUTABLE} WIN32 MACOSX_BUNDLE ${EXECUTABLE_SRC_LIST})
|
|
|
|
endif(ANDROID)
|
2017-08-24 21:09:07 +02:00
|
|
|
|
|
|
|
if(EMSCRIPTEN)
|
|
|
|
|
|
|
|
add_custom_target(${LIBSUPERDERPY_GAMENAME}_install
|
|
|
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}" --build . --target install
|
|
|
|
)
|
|
|
|
string(TOUPPER "CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}" CFLAGS)
|
|
|
|
string(REPLACE " " ";" CFLAGS_L ${CMAKE_C_FLAGS})
|
|
|
|
set(CFLAGS_LIST ${CFLAGS_L} ${${CFLAGS}})
|
|
|
|
|
|
|
|
math(EXPR EMSCRIPTEN_TOTAL_MEMORY_BYTES "${EMSCRIPTEN_TOTAL_MEMORY} * 1024 * 1024")
|
|
|
|
|
|
|
|
|
|
|
|
add_custom_target(${LIBSUPERDERPY_GAMENAME}_js
|
|
|
|
DEPENDS ${LIBSUPERDERPY_GAMENAME}_install ${LIBSUPERDERPY_GAMENAME}_flac_to_ogg
|
|
|
|
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}/${LIBSUPERDERPY_GAMENAME}"
|
2018-07-06 22:07:13 +02:00
|
|
|
COMMAND "${CMAKE_C_COMPILER}" ${CFLAGS_LIST} ../${LIBSUPERDERPY_GAMENAME}${CMAKE_EXECUTABLE_SUFFIX} ../libsuperderpy${CMAKE_SHARED_LIBRARY_SUFFIX} ../libsuperderpy-${LIBSUPERDERPY_GAMENAME}${CMAKE_SHARED_LIBRARY_SUFFIX} ${ALLEGRO_LIBRARY_PATH} ${EMSCRIPTEN_USE_FLAGS} -s MAIN_MODULE=1 -s TOTAL_MEMORY=${EMSCRIPTEN_TOTAL_MEMORY_BYTES} -o ${LIBSUPERDERPY_GAMENAME}.html --preload-file data --preload-file gamestates@/
|
2017-08-24 21:09:07 +02:00
|
|
|
COMMAND rm -rf data gamestates
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
endif(EMSCRIPTEN)
|
2017-07-22 21:01:29 +02:00
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
if(ANDROID)
|
2017-08-14 02:02:37 +02:00
|
|
|
set(ANDROID_TARGET "android-23" CACHE STRING "What Android target to compile for.")
|
2017-08-19 01:25:02 +02:00
|
|
|
STRING(REGEX REPLACE "^android-" "" ANDROID_TARGET_VERSION ${ANDROID_TARGET})
|
2016-11-07 01:45:12 +01:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
# The android tool on Windows is a batch file wrapper, which cannot be
|
|
|
|
# started by MSYS shell directly. We invoke it via cmd.exe instead.
|
|
|
|
# We don't use the full path to avoid problems with spaces,
|
|
|
|
# and hope that android.bat is somewhere on the PATH.
|
|
|
|
if(ANDROID_TOOL MATCHES "[.]bat$")
|
|
|
|
set(ANDROID_UPDATE_COMMAND
|
|
|
|
cmd.exe /c "android.bat update project -p . -t ${ANDROID_TARGET}")
|
|
|
|
else()
|
|
|
|
set(ANDROID_UPDATE_COMMAND
|
|
|
|
"${ANDROID_TOOL}" update project -p . -t ${ANDROID_TARGET})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/android")
|
|
|
|
file(COPY "${CMAKE_SOURCE_DIR}/libsuperderpy/android" DESTINATION "${CMAKE_BINARY_DIR}")
|
2016-11-07 01:45:12 +01:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
MACRO(configure_android_file PATH)
|
2018-07-06 22:07:13 +02:00
|
|
|
configure_file("${CMAKE_BINARY_DIR}/android/${PATH}.in" "${CMAKE_BINARY_DIR}/android/${PATH}" ${ARGN})
|
2017-07-22 21:01:29 +02:00
|
|
|
file(REMOVE "${CMAKE_BINARY_DIR}/android/${PATH}.in")
|
|
|
|
ENDMACRO()
|
2016-11-07 01:45:12 +01:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
if (LIBSUPERDERPY_ORIENTATION STREQUAL "PORTRAIT")
|
|
|
|
set(LIBSUPERDERPY_ANDROID_ORIENTATION "sensorPortrait")
|
|
|
|
elseif(LIBSUPERDERPY_ORIENTATION STREQUAL "LANDSCAPE")
|
|
|
|
set(LIBSUPERDERPY_ANDROID_ORIENTATION "sensorLandscape")
|
|
|
|
else()
|
|
|
|
set(LIBSUPERDERPY_ANDROID_ORIENTATION "unspecified")
|
|
|
|
endif()
|
2017-06-26 03:18:54 +02:00
|
|
|
|
2017-07-22 21:01:29 +02:00
|
|
|
if (NOT DEFINED LIBSUPERDERPY_ANDROID_DEBUGGABLE)
|
|
|
|
set(LIBSUPERDERPY_ANDROID_DEBUGGABLE "true")
|
|
|
|
endif(NOT DEFINED LIBSUPERDERPY_ANDROID_DEBUGGABLE)
|
|
|
|
|
|
|
|
configure_android_file("AndroidManifest.xml")
|
|
|
|
configure_android_file("localgen.properties")
|
|
|
|
configure_android_file("build.xml" @ONLY)
|
|
|
|
configure_android_file("project.properties" @ONLY)
|
|
|
|
configure_android_file("res/values/strings.xml")
|
|
|
|
configure_android_file("jni/localgen.mk")
|
|
|
|
if (ALLEGRO5_LIBRARIES MATCHES "^.*-debug.*$")
|
2017-08-14 02:02:37 +02:00
|
|
|
set(ALLEGRO_DEBUG_SUFFIX "-debug")
|
2017-07-22 21:01:29 +02:00
|
|
|
endif()
|
2017-08-14 02:02:37 +02:00
|
|
|
configure_file("${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy/SuperDerpyActivity.java.in" "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy/SuperDerpyActivity.java")
|
2017-07-22 21:01:29 +02:00
|
|
|
file(REMOVE "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy/SuperDerpyActivity.java.in")
|
|
|
|
|
|
|
|
file(RENAME "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy" "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/${LIBSUPERDERPY_GAMENAME}")
|
|
|
|
|
|
|
|
file(COPY ${ALLEGRO5_LIBS} DESTINATION ${LIBRARY_OUTPUT_PATH})
|
|
|
|
file(COPY "${ANDROID_ALLEGRO_ROOT}/lib/Allegro5.jar" DESTINATION ${LIBRARY_OUTPUT_PATH})
|
|
|
|
|
2017-09-25 00:36:45 +02:00
|
|
|
file(COPY "${CMAKE_SOURCE_DIR}/data" DESTINATION "${CMAKE_BINARY_DIR}/android/assets/")
|
2017-07-22 21:01:29 +02:00
|
|
|
|
2017-08-09 19:59:08 +02:00
|
|
|
file(COPY "${CMAKE_SOURCE_DIR}/data/icons/48/${LIBSUPERDERPY_GAMENAME}.png" DESTINATION "${CMAKE_BINARY_DIR}/android/res/mipmap-mdpi/")
|
|
|
|
file(COPY "${CMAKE_SOURCE_DIR}/data/icons/72/${LIBSUPERDERPY_GAMENAME}.png" DESTINATION "${CMAKE_BINARY_DIR}/android/res/mipmap-hdpi/")
|
|
|
|
file(COPY "${CMAKE_SOURCE_DIR}/data/icons/96/${LIBSUPERDERPY_GAMENAME}.png" DESTINATION "${CMAKE_BINARY_DIR}/android/res/mipmap-xhdpi/")
|
|
|
|
file(COPY "${CMAKE_SOURCE_DIR}/data/icons/144/${LIBSUPERDERPY_GAMENAME}.png" DESTINATION "${CMAKE_BINARY_DIR}/android/res/mipmap-xxhdpi/")
|
|
|
|
file(COPY "${CMAKE_SOURCE_DIR}/data/icons/192/${LIBSUPERDERPY_GAMENAME}.png" DESTINATION "${CMAKE_BINARY_DIR}/android/res/mipmap-xxxhdpi/")
|
2017-07-22 21:01:29 +02:00
|
|
|
|
|
|
|
execute_process(COMMAND ${ANDROID_UPDATE_COMMAND} WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/android")
|
|
|
|
|
|
|
|
endif(ANDROID)
|
|
|
|
|
|
|
|
set(LIBSUPERDERPY_CONFIG_INCLUDED 1)
|
2016-07-03 20:34:31 +02:00
|
|
|
|
|
|
|
endif (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
|