axmol/cmake/Modules/CocosUseLibs.cmake

209 lines
6.4 KiB
CMake
Raw Normal View History

cmake support win32 ,and support generate&use prebuilt libs (#18683) * fix win32 prebuilt error, and set cmake as default android native build * cpp-template support msvc * add msvc version check * add -D_USRLUASTATIC, fix lua lib cmake compile error * fix cpp-empty-test res copy dir, add function needed * improve msvc res copy * refactor cmake copy dll logic * fix cpp-tests compile error * refactor copy dll temp * refactor win32 exe using dlls * js-project compile support cmake using msvc * improve res mark for win32 * update the way of lua project res mark * add D_USRLUASTATIC for lua project * unify RELEASE Release to Release, add CMAKE_CONFIGURATION_TYPES * improve VS shows targets, add folder * improve mac/ios res mark * reduce useless comments * unify cpp src include variable * refactor cpp test project package logic * improve pkg app logic * start support prebuilt libs for cpp project using cmake * improve prebuilt libs generate * expand js/lua support prebuilt libs on mac * adapt IDE generate libs path * start do prebuilt for android * improve the way of using external libs for prebuilt * prebuilt libs support cpp-empty-test on android studio * cpp-tests prebuilt libs, and remove useless * start to improve libs using, to adapt prebuilt * improve cpp tests prebuilt on android * prebuilt support lua & js test on android * prebuilt support cpp&js template * rename prebuilt variabl, detail androd config * finish android support prebuilt using cmake * fix cmake script run in windows error * reduce variable name length * improve the way of win32 use dlls to adapt prebuilt * loosen pick js/lua engine lib condition * self review and start check linux build * unify compile option location * strict copy dlls condition * improve libs link order * start redo the way of copy dlls * unify dlls copy logic * fix linux res copy error * update cmake copy file path in linux * make prebuilt dir if needed, and divide Debug and Release dir * cmake win32 divide Debug and Release dir well * comment Lua Template project, for the unfinished lua simulator support * add simulator cmake file * start support simulator * simulator support cmake build on macOS * fix simulator compile error on win32 * add simulator prebuilt support * improve mark cocos app macro * improve cmake template project format * improve cmake app files format * fix format improve mistake * detail cmake readme * improve readme, useless comments * add game.rc to template project * check travis openssl version * try update travis openssl * upgrade travis openssl * change openssl link * change to upgrade openssl * re install python with upgrade openssl * add comment for macro and func, improve variable name
2018-03-08 09:47:57 +08:00
macro(cocos2d_depend_libs)
# confim the libs, prepare to link
set(PLATFORM_SPECIFIC_LIBS)
# confim the prebuilt libs, prepare to use
set(PREBUILT_SPECIFIC_LIBS)
if(WINDOWS)
foreach(_pkg OPENGL GLEW GLFW3 VORBIS MPG123 OPENAL)
cmake support win32 ,and support generate&use prebuilt libs (#18683) * fix win32 prebuilt error, and set cmake as default android native build * cpp-template support msvc * add msvc version check * add -D_USRLUASTATIC, fix lua lib cmake compile error * fix cpp-empty-test res copy dir, add function needed * improve msvc res copy * refactor cmake copy dll logic * fix cpp-tests compile error * refactor copy dll temp * refactor win32 exe using dlls * js-project compile support cmake using msvc * improve res mark for win32 * update the way of lua project res mark * add D_USRLUASTATIC for lua project * unify RELEASE Release to Release, add CMAKE_CONFIGURATION_TYPES * improve VS shows targets, add folder * improve mac/ios res mark * reduce useless comments * unify cpp src include variable * refactor cpp test project package logic * improve pkg app logic * start support prebuilt libs for cpp project using cmake * improve prebuilt libs generate * expand js/lua support prebuilt libs on mac * adapt IDE generate libs path * start do prebuilt for android * improve the way of using external libs for prebuilt * prebuilt libs support cpp-empty-test on android studio * cpp-tests prebuilt libs, and remove useless * start to improve libs using, to adapt prebuilt * improve cpp tests prebuilt on android * prebuilt support lua & js test on android * prebuilt support cpp&js template * rename prebuilt variabl, detail androd config * finish android support prebuilt using cmake * fix cmake script run in windows error * reduce variable name length * improve the way of win32 use dlls to adapt prebuilt * loosen pick js/lua engine lib condition * self review and start check linux build * unify compile option location * strict copy dlls condition * improve libs link order * start redo the way of copy dlls * unify dlls copy logic * fix linux res copy error * update cmake copy file path in linux * make prebuilt dir if needed, and divide Debug and Release dir * cmake win32 divide Debug and Release dir well * comment Lua Template project, for the unfinished lua simulator support * add simulator cmake file * start support simulator * simulator support cmake build on macOS * fix simulator compile error on win32 * add simulator prebuilt support * improve mark cocos app macro * improve cmake template project format * improve cmake app files format * fix format improve mistake * detail cmake readme * improve readme, useless comments * add game.rc to template project * check travis openssl version * try update travis openssl * upgrade travis openssl * change openssl link * change to upgrade openssl * re install python with upgrade openssl * add comment for macro and func, improve variable name
2018-03-08 09:47:57 +08:00
list(APPEND PREBUILT_SPECIFIC_LIBS ${_pkg})
endforeach()
list(APPEND PLATFORM_SPECIFIC_LIBS ws2_32 winmm Version Iphlpapi)
if(MINGW)
list(APPEND PLATFORM_SPECIFIC_LIBS shlwapi version)
endif()
elseif(LINUX)
# need review those libs: X11 Xi Xrandr Xxf86vm Xinerama Xcursor rt m
list(APPEND PLATFORM_SPECIFIC_LIBS dl X11 Xi Xrandr Xxf86vm Xinerama Xcursor rt m)
foreach(_pkg OPENGL GLEW GLFW3 FMOD FONTCONFIG THREADS GTK3)
cmake support win32 ,and support generate&use prebuilt libs (#18683) * fix win32 prebuilt error, and set cmake as default android native build * cpp-template support msvc * add msvc version check * add -D_USRLUASTATIC, fix lua lib cmake compile error * fix cpp-empty-test res copy dir, add function needed * improve msvc res copy * refactor cmake copy dll logic * fix cpp-tests compile error * refactor copy dll temp * refactor win32 exe using dlls * js-project compile support cmake using msvc * improve res mark for win32 * update the way of lua project res mark * add D_USRLUASTATIC for lua project * unify RELEASE Release to Release, add CMAKE_CONFIGURATION_TYPES * improve VS shows targets, add folder * improve mac/ios res mark * reduce useless comments * unify cpp src include variable * refactor cpp test project package logic * improve pkg app logic * start support prebuilt libs for cpp project using cmake * improve prebuilt libs generate * expand js/lua support prebuilt libs on mac * adapt IDE generate libs path * start do prebuilt for android * improve the way of using external libs for prebuilt * prebuilt libs support cpp-empty-test on android studio * cpp-tests prebuilt libs, and remove useless * start to improve libs using, to adapt prebuilt * improve cpp tests prebuilt on android * prebuilt support lua & js test on android * prebuilt support cpp&js template * rename prebuilt variabl, detail androd config * finish android support prebuilt using cmake * fix cmake script run in windows error * reduce variable name length * improve the way of win32 use dlls to adapt prebuilt * loosen pick js/lua engine lib condition * self review and start check linux build * unify compile option location * strict copy dlls condition * improve libs link order * start redo the way of copy dlls * unify dlls copy logic * fix linux res copy error * update cmake copy file path in linux * make prebuilt dir if needed, and divide Debug and Release dir * cmake win32 divide Debug and Release dir well * comment Lua Template project, for the unfinished lua simulator support * add simulator cmake file * start support simulator * simulator support cmake build on macOS * fix simulator compile error on win32 * add simulator prebuilt support * improve mark cocos app macro * improve cmake template project format * improve cmake app files format * fix format improve mistake * detail cmake readme * improve readme, useless comments * add game.rc to template project * check travis openssl version * try update travis openssl * upgrade travis openssl * change openssl link * change to upgrade openssl * re install python with upgrade openssl * add comment for macro and func, improve variable name
2018-03-08 09:47:57 +08:00
list(APPEND PREBUILT_SPECIFIC_LIBS ${_pkg})
endforeach()
elseif(ANDROID)
list(APPEND PLATFORM_SPECIFIC_LIBS GLESv2 EGL log android OpenSLES)
list(APPEND PREBUILT_SPECIFIC_LIBS TREMOLO PVMP3DEC CPUFEATURES)
elseif(APPLE)
include_directories(/System/Library/Frameworks)
find_library(ICONV_LIBRARY iconv)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
find_library(FOUNDATION_LIBRARY Foundation)
find_library(OPENAL_LIBRARY OpenAL )
find_library(QUARTZCORE_LIBRARY QuartzCore )
set(COCOS_APPLE_LIBS
${OPENAL_LIBRARY}
${AUDIOTOOLBOX_LIBRARY}
${QUARTZCORE_LIBRARY}
${FOUNDATION_LIBRARY}
${ICONV_LIBRARY}
)
if(MACOSX)
list(APPEND PREBUILT_SPECIFIC_LIBS GLFW3)
find_library(COCOA_LIBRARY Cocoa)
find_library(OPENGL_LIBRARY OpenGL )
find_library(APPLICATIONSERVICES_LIBRARY ApplicationServices)
find_library(IOKIT_LIBRARY IOKit)
list(APPEND PLATFORM_SPECIFIC_LIBS
${COCOA_LIBRARY}
${OPENGL_LIBRARY}
${APPLICATIONSERVICES_LIBRARY}
${IOKIT_LIBRARY}
${COCOS_APPLE_LIBS}
)
elseif(IOS)
# Locate system libraries on iOS
find_library(UIKIT_LIBRARY UIKit)
find_library(OPENGLES_LIBRARY OpenGLES )
find_library(CORE_MOTION_LIBRARY CoreMotion)
find_library(MEDIA_PLAYER_LIBRARY MediaPlayer)
find_library(CORE_TEXT_LIBRARY CoreText)
find_library(SECURITY_LIBRARY Security)
find_library(CORE_GRAPHICS_LIBRARY CoreGraphics)
find_library(AV_FOUNDATION_LIBRARY AVFoundation)
find_library(Z_LIBRARY z)
list(APPEND PLATFORM_SPECIFIC_LIBS
${UIKIT_LIBRARY}
${OPENGLES_LIBRARY}
${CORE_MOTION_LIBRARY}
${MEDIA_PLAYER_LIBRARY}
${CORE_TEXT_LIBRARY}
${SECURITY_LIBRARY}
${CORE_GRAPHICS_LIBRARY}
${AV_FOUNDATION_LIBRARY}
${Z_LIBRARY}
${COCOS_APPLE_LIBS}
)
endif()
endif()
foreach(_pkg ZLIB MINIZIP TinyXML2 FREETYPE WEBSOCKETS CURL FLATBUFFERS XXHASH SQLITE3)
cmake support win32 ,and support generate&use prebuilt libs (#18683) * fix win32 prebuilt error, and set cmake as default android native build * cpp-template support msvc * add msvc version check * add -D_USRLUASTATIC, fix lua lib cmake compile error * fix cpp-empty-test res copy dir, add function needed * improve msvc res copy * refactor cmake copy dll logic * fix cpp-tests compile error * refactor copy dll temp * refactor win32 exe using dlls * js-project compile support cmake using msvc * improve res mark for win32 * update the way of lua project res mark * add D_USRLUASTATIC for lua project * unify RELEASE Release to Release, add CMAKE_CONFIGURATION_TYPES * improve VS shows targets, add folder * improve mac/ios res mark * reduce useless comments * unify cpp src include variable * refactor cpp test project package logic * improve pkg app logic * start support prebuilt libs for cpp project using cmake * improve prebuilt libs generate * expand js/lua support prebuilt libs on mac * adapt IDE generate libs path * start do prebuilt for android * improve the way of using external libs for prebuilt * prebuilt libs support cpp-empty-test on android studio * cpp-tests prebuilt libs, and remove useless * start to improve libs using, to adapt prebuilt * improve cpp tests prebuilt on android * prebuilt support lua & js test on android * prebuilt support cpp&js template * rename prebuilt variabl, detail androd config * finish android support prebuilt using cmake * fix cmake script run in windows error * reduce variable name length * improve the way of win32 use dlls to adapt prebuilt * loosen pick js/lua engine lib condition * self review and start check linux build * unify compile option location * strict copy dlls condition * improve libs link order * start redo the way of copy dlls * unify dlls copy logic * fix linux res copy error * update cmake copy file path in linux * make prebuilt dir if needed, and divide Debug and Release dir * cmake win32 divide Debug and Release dir well * comment Lua Template project, for the unfinished lua simulator support * add simulator cmake file * start support simulator * simulator support cmake build on macOS * fix simulator compile error on win32 * add simulator prebuilt support * improve mark cocos app macro * improve cmake template project format * improve cmake app files format * fix format improve mistake * detail cmake readme * improve readme, useless comments * add game.rc to template project * check travis openssl version * try update travis openssl * upgrade travis openssl * change openssl link * change to upgrade openssl * re install python with upgrade openssl * add comment for macro and func, improve variable name
2018-03-08 09:47:57 +08:00
list(APPEND PREBUILT_SPECIFIC_LIBS ${_pkg})
endforeach()
if(NOT EMSCRIPTEN)
list(APPEND PREBUILT_SPECIFIC_LIBS OPENSSL)
endif()
if(USE_JPEG)
add_definitions(-DCC_USE_JPEG=1)
list(APPEND PREBUILT_SPECIFIC_LIBS JPEG)
else()
add_definitions(-DCC_USE_JPEG=0)
endif()
if(USE_WEBP)
add_definitions(-DCC_USE_WEBP=1)
list(APPEND PREBUILT_SPECIFIC_LIBS WEBP)
else()
add_definitions(-DCC_USE_WEBP=0)
endif()
if(USE_TIFF)
add_definitions(-DCC_USE_TIFF=1)
list(APPEND PREBUILT_SPECIFIC_LIBS TIFF)
else()
add_definitions(-DCC_USE_TIFF=0)
endif()
if(USE_PNG)
add_definitions(-DCC_USE_PNG=1)
list(APPEND PREBUILT_SPECIFIC_LIBS PNG)
else()
add_definitions(-DCC_USE_PNG=0)
endif()
if(USE_CHIPMUNK)
list(APPEND PREBUILT_SPECIFIC_LIBS CHIPMUNK)
endif()
if(USE_BOX2D)
list(APPEND PREBUILT_SPECIFIC_LIBS Box2D)
endif()
if(USE_BULLET)
list(APPEND PREBUILT_SPECIFIC_LIBS BULLET)
endif()
if(USE_RECAST)
list(APPEND PREBUILT_SPECIFIC_LIBS RECAST)
endif()
endmacro()
macro(target_use_cocos2d_depend_libs target)
cocos2d_depend_libs()
message(STATUS "${target} prepare to use cpp needed libs: ${PREBUILT_SPECIFIC_LIBS}")
# message(STATUS "${target} prepare to link cpp needed libs: ${PLATFORM_SPECIFIC_LIBS}")
foreach(prebuilt_lib ${PREBUILT_SPECIFIC_LIBS})
cocos_use_pkg(${target} ${prebuilt_lib})
endforeach()
foreach(platform_lib ${PLATFORM_SPECIFIC_LIBS})
target_link_libraries(${target} ${platform_lib})
endforeach()
endmacro()
macro(jscocos2d_depend_libs)
set(PLATFORM_SPECIFIC_LIBS)
set(PREBUILT_SPECIFIC_LIBS)
list(APPEND PREBUILT_SPECIFIC_LIBS SPIDERMONKEY)
cmake support win32 ,and support generate&use prebuilt libs (#18683) * fix win32 prebuilt error, and set cmake as default android native build * cpp-template support msvc * add msvc version check * add -D_USRLUASTATIC, fix lua lib cmake compile error * fix cpp-empty-test res copy dir, add function needed * improve msvc res copy * refactor cmake copy dll logic * fix cpp-tests compile error * refactor copy dll temp * refactor win32 exe using dlls * js-project compile support cmake using msvc * improve res mark for win32 * update the way of lua project res mark * add D_USRLUASTATIC for lua project * unify RELEASE Release to Release, add CMAKE_CONFIGURATION_TYPES * improve VS shows targets, add folder * improve mac/ios res mark * reduce useless comments * unify cpp src include variable * refactor cpp test project package logic * improve pkg app logic * start support prebuilt libs for cpp project using cmake * improve prebuilt libs generate * expand js/lua support prebuilt libs on mac * adapt IDE generate libs path * start do prebuilt for android * improve the way of using external libs for prebuilt * prebuilt libs support cpp-empty-test on android studio * cpp-tests prebuilt libs, and remove useless * start to improve libs using, to adapt prebuilt * improve cpp tests prebuilt on android * prebuilt support lua & js test on android * prebuilt support cpp&js template * rename prebuilt variabl, detail androd config * finish android support prebuilt using cmake * fix cmake script run in windows error * reduce variable name length * improve the way of win32 use dlls to adapt prebuilt * loosen pick js/lua engine lib condition * self review and start check linux build * unify compile option location * strict copy dlls condition * improve libs link order * start redo the way of copy dlls * unify dlls copy logic * fix linux res copy error * update cmake copy file path in linux * make prebuilt dir if needed, and divide Debug and Release dir * cmake win32 divide Debug and Release dir well * comment Lua Template project, for the unfinished lua simulator support * add simulator cmake file * start support simulator * simulator support cmake build on macOS * fix simulator compile error on win32 * add simulator prebuilt support * improve mark cocos app macro * improve cmake template project format * improve cmake app files format * fix format improve mistake * detail cmake readme * improve readme, useless comments * add game.rc to template project * check travis openssl version * try update travis openssl * upgrade travis openssl * change openssl link * change to upgrade openssl * re install python with upgrade openssl * add comment for macro and func, improve variable name
2018-03-08 09:47:57 +08:00
if(APPLE)
find_library(GAME_CONTROLLER GameController)
list(APPEND PLATFORM_SPECIFIC_LIBS ${GAME_CONTROLLER})
endif()
endmacro()
macro(target_use_jscocos2d_depend_libs target)
jscocos2d_depend_libs()
message(STATUS "${target} prepare to use js needed libs: ${PREBUILT_SPECIFIC_LIBS}")
# message(STATUS "${target} prepare to link js needed libs: ${PLATFORM_SPECIFIC_LIBS}")
foreach(prebuilt_lib ${PREBUILT_SPECIFIC_LIBS})
cocos_use_pkg(${target} ${prebuilt_lib})
endforeach()
foreach(platform_lib ${PLATFORM_SPECIFIC_LIBS})
target_link_libraries(${target} ${platform_lib})
endforeach()
endmacro()
macro(luacocos2d_depend_libs)
set(PLATFORM_SPECIFIC_LIBS)
set(PREBUILT_SPECIFIC_LIBS)
list(APPEND PREBUILT_SPECIFIC_LIBS LUAJIT)
endmacro()
macro(target_use_luacocos2d_depend_libs target)
luacocos2d_depend_libs()
message(STATUS "${target} prepare to use lua needed libs: ${PREBUILT_SPECIFIC_LIBS}")
# message(STATUS "${target} prepare to link lua needed libs: ${PLATFORM_SPECIFIC_LIBS}")
foreach(prebuilt_lib ${PREBUILT_SPECIFIC_LIBS})
cocos_use_pkg(${target} ${prebuilt_lib})
endforeach()
foreach(platform_lib ${PLATFORM_SPECIFIC_LIBS})
target_link_libraries(${target} ${platform_lib})
endforeach()
endmacro()
macro(simulator_depend_libs)
set(PLATFORM_SPECIFIC_LIBS)
set(PREBUILT_SPECIFIC_LIBS)
if(MACOSX)
include_directories(/System/Library/Frameworks)
find_library(APPKIT_LIBRARY AppKit)
list(APPEND PLATFORM_SPECIFIC_LIBS ${APPKIT_LIBRARY})
elseif(WINDOWS)
list(APPEND PREBUILT_SPECIFIC_LIBS TinyXML2 CURL)
endif()
endmacro()
macro(target_use_simulator_depend_libs target)
simulator_depend_libs()
message(STATUS "${target} prepare to use simulator needed libs: ${PREBUILT_SPECIFIC_LIBS}")
# message(STATUS "${target} prepare to link simulator needed libs: ${PLATFORM_SPECIFIC_LIBS}")
foreach(prebuilt_lib ${PREBUILT_SPECIFIC_LIBS})
cocos_use_pkg(${target} ${prebuilt_lib})
endforeach()
foreach(platform_lib ${PLATFORM_SPECIFIC_LIBS})
target_link_libraries(${target} ${platform_lib})
endforeach()
endmacro()