Adding a plurality of source code CMakeLists.txt

coos2d-x 3.17.2 C ++ project, Andrews compiled using CMake, in accordance with the template to the wording, can only add a source file;
if you need to add a lot of C ++ source code, this approach is certainly not desirable;
the original wording:

1 list(APPEND GAME_SOURCE
2         Classes/AppDelegate.cpp
3         Classes/HelloWorldScene.cpp)
4 list(APPEND GAME_HEADER
5         Classes/AppDelegate.h
6         Classes/HelloWorldScene.h)

This form were added to each .cpp file and a .h corresponding GAME_SOURCE and GAME_HEADER

Match mode:

1 file(GLOB_RECURSE GAME_COMMON_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "Classes/*")

Using the file command, from $ {CMAKE_CURRENT_SOURCE_DIR} relative path specified variable, with recursive regular expression matched all of the source code directory Classes;

Reference:
https://www.hahack.com/codes/cmake/

CMake official document: file commands

Guess you like

Origin www.cnblogs.com/ayou007/p/12073970.html