Refactor define_source_files macro.
Change the argument names to indicate their intent usage better. Add option to pass in directly globbing patterns.
This commit is contained in:
Родитель
b957f60143
Коммит
6071001b5c
|
@ -262,25 +262,25 @@ function (add_compiler_export_flags)
|
|||
return ()
|
||||
endif ()
|
||||
|
||||
set (EXTRA_FLAGS "-fvisibility=hidden")
|
||||
set (p_FLAGS "-fvisibility=hidden")
|
||||
# Either return the extra flags needed in the supplied argument, or to the
|
||||
# CMAKE_C_FLAGS if no argument is supplied.
|
||||
if (ARGV1)
|
||||
set (${ARGV1} "${EXTRA_FLAGS}" PARENT_SCOPE)
|
||||
set (${ARGV1} "${p_FLAGS}" PARENT_SCOPE)
|
||||
else ()
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_FLAGS}" PARENT_SCOPE)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${p_FLAGS}" PARENT_SCOPE)
|
||||
endif ()
|
||||
|
||||
if (COMPILER_HAS_HIDDEN_INLINE_VISIBILITY)
|
||||
set (EXTRA_FLAGS "${EXTRA_FLAGS} -fvisibility-inlines-hidden")
|
||||
set (p_FLAGS "${p_FLAGS} -fvisibility-inlines-hidden")
|
||||
endif ()
|
||||
|
||||
# Either return the extra flags needed in the supplied argument, or to the
|
||||
# CMAKE_CXX_FLAGS if no argument is supplied.
|
||||
if (ARGV0)
|
||||
set (${ARGV0} "${EXTRA_FLAGS}" PARENT_SCOPE)
|
||||
set (${ARGV0} "${p_FLAGS}" PARENT_SCOPE)
|
||||
else ()
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS}" PARENT_SCOPE)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${p_FLAGS}" PARENT_SCOPE)
|
||||
endif ()
|
||||
endfunction ()
|
||||
|
||||
|
@ -563,28 +563,34 @@ endmacro ()
|
|||
# Macro for defining source files
|
||||
macro (define_source_files)
|
||||
# Parse extra arguments
|
||||
cmake_parse_arguments (EXTRA "PCH;PARENT_SCOPE" "GROUP" "CPP_FILES;H_FILES" ${ARGN})
|
||||
cmake_parse_arguments (ARG "PCH;PARENT_SCOPE" "GROUP" "EXTRA_CPP_FILES;EXTRA_H_FILES;GLOB_CPP_PATTERNS;GLOB_H_PATTERNS" ${ARGN})
|
||||
|
||||
# Source files are defined by globbing source files in current source directory and also by including the extra source files if provided
|
||||
file (GLOB CPP_FILES *.cpp)
|
||||
file (GLOB H_FILES *.h)
|
||||
list (APPEND CPP_FILES ${EXTRA_CPP_FILES})
|
||||
list (APPEND H_FILES ${EXTRA_H_FILES})
|
||||
if (NOT ARG_GLOB_CPP_PATTERNS)
|
||||
set (ARG_GLOB_CPP_PATTERNS *.cpp) # Default glob pattern
|
||||
endif ()
|
||||
if (NOT ARG_GLOB_H_PATTERNS)
|
||||
set (ARG_GLOB_H_PATTERNS *.h)
|
||||
endif ()
|
||||
file (GLOB CPP_FILES ${ARG_GLOB_CPP_PATTERNS})
|
||||
file (GLOB H_FILES ${ARG_GLOB_H_PATTERNS})
|
||||
list (APPEND CPP_FILES ${ARG_EXTRA_CPP_FILES})
|
||||
list (APPEND H_FILES ${ARG_EXTRA_H_FILES})
|
||||
set (SOURCE_FILES ${CPP_FILES} ${H_FILES})
|
||||
|
||||
# Optionally enable PCH
|
||||
if (EXTRA_PCH)
|
||||
if (ARG_PCH)
|
||||
enable_pch ()
|
||||
endif ()
|
||||
|
||||
# Optionally accumulate source files at parent scope
|
||||
if (EXTRA_PARENT_SCOPE)
|
||||
if (ARG_PARENT_SCOPE)
|
||||
get_filename_component (DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
set (${DIR_NAME}_CPP_FILES ${CPP_FILES} PARENT_SCOPE)
|
||||
set (${DIR_NAME}_H_FILES ${H_FILES} PARENT_SCOPE)
|
||||
# Optionally put source files into further sub-group (only works for current scope due to CMake limitation)
|
||||
elseif (EXTRA_GROUP)
|
||||
source_group ("Source Files\\${EXTRA_GROUP}" FILES ${CPP_FILES})
|
||||
source_group ("Header Files\\${EXTRA_GROUP}" FILES ${H_FILES})
|
||||
elseif (ARG_GROUP)
|
||||
source_group ("Source Files\\${ARG_GROUP}" FILES ${CPP_FILES})
|
||||
source_group ("Header Files\\${ARG_GROUP}" FILES ${H_FILES})
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
|
|
@ -108,7 +108,7 @@ foreach (SOURCE Audio Container Core Engine Graphics Input IO Math Navigation Ne
|
|||
list (APPEND ENGINE_SOURCE_FILES ${${SOURCE}_CPP_FILES} ${${SOURCE}_H_FILES})
|
||||
list (APPEND ENGINE_INCLUDE_DIRS_ONLY ${SOURCE})
|
||||
endforeach ()
|
||||
define_source_files (CPP_FILES ${ENGINE_SOURCE_FILES} H_FILES gitversion.h PCH)
|
||||
define_source_files (EXTRA_CPP_FILES ${ENGINE_SOURCE_FILES} EXTRA_H_FILES gitversion.h PCH)
|
||||
list (APPEND SOURCE_FILES ${ALL_OBJ_FILES})
|
||||
set_source_files_properties (${ALL_OBJ_FILES} PROPERTIES GENERATED TRUE)
|
||||
|
||||
|
|
|
@ -26,9 +26,7 @@ if (USE_OPENGL)
|
|||
else ()
|
||||
set (GRAPHICS_SYS_DIR Direct3D9)
|
||||
endif ()
|
||||
file (GLOB SYS_CPP_FILES ${GRAPHICS_SYS_DIR}/*.cpp)
|
||||
file (GLOB SYS_H_FILES ${GRAPHICS_SYS_DIR}/*.h)
|
||||
define_source_files (CPP_FILES ${SYS_CPP_FILES} H_FILES ${SYS_H_FILES} PARENT_SCOPE)
|
||||
define_source_files (GLOB_CPP_PATTERNS *.cpp ${GRAPHICS_SYS_DIR}/*.cpp GLOB_H_PATTERNS *.h ${GRAPHICS_SYS_DIR}/*.h PARENT_SCOPE)
|
||||
|
||||
# Define dependency libs
|
||||
set (ENGINE_LINK_LIBS_ONLY ${ENGINE_LINK_LIBS_ONLY} SDL PARENT_SCOPE)
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
|
||||
# Define source files
|
||||
if (APPLE AND NOT IOS)
|
||||
file (GLOB C_FILES *.m)
|
||||
set (GLOB_OBJC_PATTERN *.m)
|
||||
endif()
|
||||
define_source_files (CPP_FILES ${C_FILES} PARENT_SCOPE)
|
||||
define_source_files (GLOB_CPP_PATTERNS *.cpp ${GLOB_OBJC_PATTERN} PARENT_SCOPE)
|
||||
|
||||
# Define dependency libs
|
||||
set (ENGINE_LIBS ${ENGINE_LIBS} ../ThirdParty/LZ4 PARENT_SCOPE)
|
||||
|
|
|
@ -56,7 +56,7 @@ foreach (API_PKG_FILE ${API_PKG_FILES})
|
|||
endforeach ()
|
||||
|
||||
# Define source files
|
||||
define_source_files (CPP_FILES ${GEN_CPP_FILES})
|
||||
define_source_files (EXTRA_CPP_FILES ${GEN_CPP_FILES})
|
||||
|
||||
# Define dependency libs
|
||||
set (LIBS ../../ThirdParty/Lua${JIT}/src)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 01_HelloWorld)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 02_HelloGUI)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 03_Sprites)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 04_StaticScene)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 05_AnimatingScene)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 06_SkeletalAnimation)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 07_Billboards)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 08_Decals)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 09_MultipleViewports)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 10_RenderToTexture)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 11_Physics)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 12_PhysicsStressTest)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 13_Ragdolls)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 14_SoundEffects)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 15_Navigation)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 16_Chat)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 17_SceneReplication)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 18_CharacterDemo)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 19_VehicleDemo)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 20_HugeObjectCount)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 21_AngelScriptIntegration)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
set (TARGET_NAME 22_LuaIntegration)
|
||||
|
||||
# Define source files
|
||||
define_source_files (H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
define_source_files (EXTRA_H_FILES ${COMMON_SAMPLE_H_FILES})
|
||||
|
||||
# Setup target with resource copying
|
||||
setup_main_executable ()
|
||||
|
|
Загрузка…
Ссылка в новой задаче