2021年1月6日星期三

How to setup cmake to share one codebase for android and pc

I want to share a codebase between android and pc, what I am doing now is I created an intermediate library that abstracts what I need, and then I have two targets in my CMake file one for creating android lib for JNI and one for creating executable for pc. Here is what I am doing in CMake

add_library(game_base ${SRCS})  target_include_directories(game_base PUBLIC include)    add_library(gl2jni SHARED          ${ANDROID_SRCS})  target_link_libraries(gl2jni          game_base          android          log          EGL          GLESv2)  add_executable(pc_test ${PC_SRCS})  target_link_libraries(pc_test game_base)  

Now it works but questions are is it "correct" or "best practice" to do it like this? Currently, I am building pc version from the terminal, is it possible to somehow build and run the executable from android studio or is it possible to test with the android device using Clion, so basically is it possible to create a setup where I can select one of the targets from the IDE and test?

https://stackoverflow.com/questions/65606127/how-to-setup-cmake-to-share-one-codebase-for-android-and-pc January 07, 2021 at 11:07AM

没有评论:

发表评论