Skip to content

Commit

Permalink
update cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Xrysnow committed May 28, 2021
1 parent 1dda054 commit 543aab8
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 20 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ set(APP_NAME LuaSTG-x)

project(${APP_NAME})

option(LSTGX_NO_LIVE2D "No live2d module" OFF)
option(LSTGX_NO_VIDEO "No video module" OFF)
option(LSTGX_NO_FAIRY_GUI "No FairyGUI module" OFF)
option(LSTGX_NO_YASIO "No YASIO module" OFF)
option(LSTGX_NO_YUESCRIPT "No Yuescript module" OFF)
option(LSTGX_USE_ANGLE "Use angle on windows" ON)

set(CC_USE_ANGLE LSTGX_USE_ANGLE)

if(XCODE)
if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET)
set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 8.0)
Expand Down
81 changes: 61 additions & 20 deletions modules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,30 @@ set(LSTGX_EXT_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/external)

# ffmpeg, video

set(CC_VIDEO_DEPEND_LIBS)
add_subdirectory(${LSTGX_EXT_ROOT}/ffmpeg)
if(APPLE)
include_directories(${LSTGX_EXT_ROOT}/ffmpeg/include)
#target_link_libraries(${APP_NAME} ${FFMPEG_LIBRARY})
target_link_options(${APP_NAME} PRIVATE -F ${FFMPEG_FRAMEWORK_PATH})
target_link_options(${APP_NAME} PRIVATE -framework libffmpeg.4.dylib)
# copy to Frameworks, need to check sign option in Xcode project
target_sources(${APP_NAME} PUBLIC ${FFMPEG_LIBRARY})
set_source_files_properties(${FFMPEG_LIBRARY} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks HEADER_FILE_ONLY 1)
set_target_properties(${APP_NAME} PROPERTIES XCODE_ATTRIBUTE_FRAMEWORK_SEARCH_PATHS ${FFMPEG_FRAMEWORK_PATH})
# set rpath
target_link_options(${APP_NAME} PRIVATE -Wl,-rpath,@loader_path/../Frameworks/${FFMPEG_FRAMEWORK})
# set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS "-Wl,-rpath,@loader_path/../Frameworks/${FFMPEG_FRAMEWORK}")
if(NOT LSTGX_NO_VIDEO)
set(CC_VIDEO_DEPEND_LIBS)
add_subdirectory(${LSTGX_EXT_ROOT}/ffmpeg)
if(APPLE)
include_directories(${LSTGX_EXT_ROOT}/ffmpeg/include)
#target_link_libraries(${APP_NAME} ${FFMPEG_LIBRARY})
target_link_options(${APP_NAME} PRIVATE -F ${FFMPEG_FRAMEWORK_PATH})
target_link_options(${APP_NAME} PRIVATE -framework libffmpeg.4.dylib)
# copy to Frameworks, need to check sign option in Xcode project
target_sources(${APP_NAME} PUBLIC ${FFMPEG_LIBRARY})
set_source_files_properties(${FFMPEG_LIBRARY} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks HEADER_FILE_ONLY 1)
set_target_properties(${APP_NAME} PROPERTIES XCODE_ATTRIBUTE_FRAMEWORK_SEARCH_PATHS ${FFMPEG_FRAMEWORK_PATH})
# set rpath
target_link_options(${APP_NAME} PRIVATE -Wl,-rpath,@loader_path/../Frameworks/${FFMPEG_FRAMEWORK})
# set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS "-Wl,-rpath,@loader_path/../Frameworks/${FFMPEG_FRAMEWORK}")
else()
list(APPEND CC_VIDEO_DEPEND_LIBS ext_ffmpeg)
endif()
add_subdirectory(${LSTGX_MOD_ROOT}/Video)
list(APPEND EXTERNAL_LIBS cc_video)
else()
list(APPEND CC_VIDEO_DEPEND_LIBS ext_ffmpeg)
target_compile_definitions(${APP_NAME} PUBLIC LSTGX_NO_VIDEO)
endif()

add_subdirectory(${LSTGX_MOD_ROOT}/Video)
list(APPEND EXTERNAL_LIBS cc_video)

# ogg, OpenalSoft, audio

set(CC_AUDIO_DEPEND_LIBS)
Expand Down Expand Up @@ -75,8 +78,12 @@ list(APPEND EXTERNAL_LIBS cc_imgui)

# Live2D

add_subdirectory(${LSTGX_MOD_ROOT}/Live2D)
list(APPEND EXTERNAL_LIBS cc_live2d)
if(NOT LSTGX_NO_LIVE2D)
add_subdirectory(${LSTGX_MOD_ROOT}/Live2D)
list(APPEND EXTERNAL_LIBS cc_live2d)
else()
target_compile_definitions(${APP_NAME} PUBLIC LSTGX_NO_LIVE2D)
endif()

# math

Expand Down Expand Up @@ -121,10 +128,44 @@ if(WINDOWS OR LINUX OR MACOSX)
list(APPEND EXTERNAL_LIBS ext_NativeFileDialog)
endif()

# FairyGUI

if(NOT LSTGX_NO_FAIRY_GUI)
add_subdirectory(${LSTGX_EXT_ROOT}/FairyGUI)
list(APPEND EXTERNAL_LIBS ext_FairyGUI)
else()
target_compile_definitions(${APP_NAME} PUBLIC LSTGX_NO_FAIRY_GUI)
endif()

# yasio

if(NOT LSTGX_NO_YASIO)
add_subdirectory(${LSTGX_EXT_ROOT}/yasio)
list(APPEND EXTERNAL_LIBS ext_yasio)
else()
target_compile_definitions(${APP_NAME} PUBLIC LSTGX_NO_YASIO)
endif()

# Yuescript

if(NOT LSTGX_NO_YUESCRIPT)
add_subdirectory(${LSTGX_EXT_ROOT}/Yuescript)
list(APPEND EXTERNAL_LIBS ext_Yuescript)
else()
target_compile_definitions(${APP_NAME} PUBLIC LSTGX_NO_YUESCRIPT)
endif()

# windows

if(WINDOWS)
list(APPEND EXTERNAL_LIBS imm32.lib)
# ANGLE
if(LSTGX_USE_ANGLE)
add_subdirectory(${LSTGX_EXT_ROOT}/ANGLE)
target_include_directories(cocos2d PUBLIC ${LSTGX_EXT_ROOT}/ANGLE/include)
target_compile_definitions(cocos2d PUBLIC CC_USE_ANGLE)
list(APPEND EXTERNAL_LIBS ext_ANGLE ext_ANGLE_es2)
endif()
endif()

target_link_libraries(${APP_NAME} ${EXTERNAL_LIBS})
11 changes: 11 additions & 0 deletions src.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,17 @@ set(GAME_INCLUDE
${LSTGX_SRC_ROOT}/Video
)

if(NOT LSTGX_NO_FAIRY_GUI)
list(APPEND GAME_HEADER
${LSTGX_SRC_ROOT}/LuaBindings/lua_cc_fairygui_auto.hpp
${LSTGX_SRC_ROOT}/LuaBindings/lua_cc_fairygui_manual.hpp
)
list(APPEND GAME_SOURCE
${LSTGX_SRC_ROOT}/LuaBindings/lua_cc_fairygui_auto.cpp
${LSTGX_SRC_ROOT}/LuaBindings/lua_cc_fairygui_manual.cpp
)
endif()

if(ANDROID)
list(APPEND GAME_SOURCE ${RUNTIME_SRC_ROOT}/proj.android/app/jni/hellolua/main.cpp)
elseif(LINUX)
Expand Down

0 comments on commit 543aab8

Please sign in to comment.