CMake - Copying resource folder

The structure of my Resources folder is

Resources
General
Midnight
Revenge

Now ideally what I want when CMake builds the project is to exclude a combination of the folders based on a variable that I pass in. I have my CMake project make either a Midnight build or a Revenge build depending on a variable I pass in. But I can’t work out to do resources files on a variable because it looks like it all gets copied in one go.

Any thoughts?

I’m not entirely sure if there is a way to exclude resources because on the way they are copied, but, consider handling this in a different way.

How about you construct the Resources folder based on your build variables before it gets to the resource copying stage. For example, say you have this folder structure for your resources:

/Resources_Common/
/Resources_Midnight/
/Resources_Revenge/

In CMakeLists.txt, you first delete the contents of the existing Resources folder, then copy the contents of both the Common and one of the other two (Midnight or Revenge) resource folders into the /Resources/ folder. Does this make sense?

Ok. Yes I think that makes sense. I shall see if I can work that out in cmake! Thanks.

So here was my solution.

Top of my CMake is

if(TME STREQUAL "LOM")
  set(APP_BUILD _LOM_)
  set(APP_NAME midnight)
elseif(TME STREQUAL "DDR")
  set(APP_BUILD _DDR_)
  set(APP_NAME revenge)
endif()

as I already build my project with

cmake .. -GXcode -DCMAKE_SYSTEM_NAME=iOS -DTME:string=LOM

I have 3 folders

/Resources
/Resources-midnight/lom
/Resources-revenge/ddr

And my CMake changes accordingly

set(GAME_RES_FOLDER
    "${CMAKE_CURRENT_SOURCE_DIR}/Resources"
    "${CMAKE_CURRENT_SOURCE_DIR}/Resources-${APP_NAME}"
    )

if(APPLE OR WINDOWS)
    cocos_mark_multi_resources(common_res_files RES_TO "Resources" FOLDERS ${GAME_RES_FOLDER})
endif()

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.