axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
868 stars 195 forks source link

cmake is not triggered on build command #1544

Closed Nordsoft91 closed 9 months ago

Nordsoft91 commented 9 months ago

Expected: xcode project is updated, new source file is added Actual: nothing changed, to get actual update you must delete CMakeCache.txt and do full rebuild

rh101 commented 9 months ago

If you're using GLOB or GLOB_RECURSE in your project CMakeLists.txt, then that would most likely be the source of the problem, and has nothing to do with Axmol.

Check this section in the file:

file(GLOB_RECURSE GAME_HEADER
    Source/*.h
    )
file(GLOB_RECURSE GAME_SOURCE
    Source/*.cpp
    )

From the CMake docs: image

It only takes you a few seconds to manually add a new cpp/h file reference to CMakeLists.txt, so save yourself the hassle and avoid using GLOB/GLOB_RECURSE.

Nordsoft91 commented 9 months ago

Yes, but CMakeLists.txt is generated by axmol automatically and it's quite big. Possible solution would be to generate short CMakeLists.txt in Source directory automatically which will be much shorter and contain (almost) those lines and include it in root CMakeLists.txt. Thus will be much easier to work with it.

Nordsoft91 commented 9 months ago

I replaced adding of sources in root CMakeLists.txt:

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Source)

Now Source/CMakeLists.txt:

# The common cross-platforms source files and header files
file(GLOB_RECURSE GAME_HEADER
    *.h
    )
file(GLOB_RECURSE GAME_SOURCE
    *.cpp
    )

set(GAME_HEADER ${GAME_HEADER} PARENT_SCOPE)
set(GAME_SOURCE ${GAME_SOURCE} PARENT_SCOPE)
halx99 commented 9 months ago

Try add param: -force

rh101 commented 9 months ago

Yes, but CMakeLists.txt is generated by axmol automatically and it's quite big. Possible solution would be to generate short CMakeLists.txt in Source directory automatically which will be much shorter and contain (almost) those lines and include it in root CMakeLists.txt. Thus will be much easier to work with it.

That is something developers would most likely be doing already, but it may help to add it to the project templates just to make things a little clearer. Consider submitting a PR with the change.