|
@@ -894,12 +894,10 @@ endmacro ()
|
|
|
# EXTRA_CPP_FILES <list> - Include the provided list of files into CPP_FILES result
|
|
# EXTRA_CPP_FILES <list> - Include the provided list of files into CPP_FILES result
|
|
|
# EXTRA_H_FILES <list> - Include the provided list of files into H_FILES result
|
|
# EXTRA_H_FILES <list> - Include the provided list of files into H_FILES result
|
|
|
# PCH <list> - Enable precompiled header support on the defined source files using the specified header file, the list is "<path/to/header> [C++|C]"
|
|
# PCH <list> - Enable precompiled header support on the defined source files using the specified header file, the list is "<path/to/header> [C++|C]"
|
|
|
-# PARENT_SCOPE - Glob source files in current directory but set the result in parent-scope's variable ${DIR}_CPP_FILES and ${DIR}_H_FILES instead
|
|
|
|
|
# RECURSE - Option to glob recursively
|
|
# RECURSE - Option to glob recursively
|
|
|
-# GROUP - Option to group source files based on its relative path to the corresponding parent directory (only works when PARENT_SCOPE option is not in use)
|
|
|
|
|
macro (define_source_files)
|
|
macro (define_source_files)
|
|
|
# Source files are defined by globbing source files in current source directory and also by including the extra source files if provided
|
|
# Source files are defined by globbing source files in current source directory and also by including the extra source files if provided
|
|
|
- cmake_parse_arguments (ARG "PARENT_SCOPE;RECURSE;GROUP" "" "PCH;EXTRA_CPP_FILES;EXTRA_H_FILES;GLOB_CPP_PATTERNS;GLOB_H_PATTERNS;EXCLUDE_PATTERNS" ${ARGN})
|
|
|
|
|
|
|
+ cmake_parse_arguments (ARG "RECURSE" "" "PCH;EXTRA_CPP_FILES;EXTRA_H_FILES;GLOB_CPP_PATTERNS;GLOB_H_PATTERNS;EXCLUDE_PATTERNS" ${ARGN})
|
|
|
if (NOT ARG_GLOB_CPP_PATTERNS)
|
|
if (NOT ARG_GLOB_CPP_PATTERNS)
|
|
|
set (ARG_GLOB_CPP_PATTERNS *.cpp) # Default glob pattern
|
|
set (ARG_GLOB_CPP_PATTERNS *.cpp) # Default glob pattern
|
|
|
endif ()
|
|
endif ()
|
|
@@ -928,34 +926,25 @@ macro (define_source_files)
|
|
|
list (APPEND CPP_FILES ${ARG_EXTRA_CPP_FILES})
|
|
list (APPEND CPP_FILES ${ARG_EXTRA_CPP_FILES})
|
|
|
list (APPEND H_FILES ${ARG_EXTRA_H_FILES})
|
|
list (APPEND H_FILES ${ARG_EXTRA_H_FILES})
|
|
|
set (SOURCE_FILES ${CPP_FILES} ${H_FILES})
|
|
set (SOURCE_FILES ${CPP_FILES} ${H_FILES})
|
|
|
-
|
|
|
|
|
|
|
+ # Group the source files accordingly on IDE that supports it
|
|
|
|
|
+ foreach (CPP_FILE ${CPP_FILES})
|
|
|
|
|
+ get_filename_component (PATH ${CPP_FILE} PATH)
|
|
|
|
|
+ if (PATH)
|
|
|
|
|
+ string (REPLACE / \\ PATH ${PATH})
|
|
|
|
|
+ source_group ("Source Files\\${PATH}" FILES ${CPP_FILE})
|
|
|
|
|
+ endif ()
|
|
|
|
|
+ endforeach ()
|
|
|
|
|
+ foreach (H_FILE ${H_FILES})
|
|
|
|
|
+ get_filename_component (PATH ${H_FILE} PATH)
|
|
|
|
|
+ if (PATH)
|
|
|
|
|
+ string (REPLACE / \\ PATH ${PATH})
|
|
|
|
|
+ source_group ("Header Files\\${PATH}" FILES ${H_FILE})
|
|
|
|
|
+ endif ()
|
|
|
|
|
+ endforeach ()
|
|
|
# Optionally enable PCH
|
|
# Optionally enable PCH
|
|
|
if (ARG_PCH)
|
|
if (ARG_PCH)
|
|
|
enable_pch (${ARG_PCH})
|
|
enable_pch (${ARG_PCH})
|
|
|
endif ()
|
|
endif ()
|
|
|
-
|
|
|
|
|
- # Optionally accumulate source files at parent scope
|
|
|
|
|
- if (ARG_PARENT_SCOPE)
|
|
|
|
|
- get_filename_component (NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
|
|
|
|
- set (${NAME}_CPP_FILES ${CPP_FILES} PARENT_SCOPE)
|
|
|
|
|
- set (${NAME}_H_FILES ${H_FILES} PARENT_SCOPE)
|
|
|
|
|
- # Optionally put source files into further sub-group (only works when PARENT_SCOPE option is not in use)
|
|
|
|
|
- elseif (ARG_GROUP)
|
|
|
|
|
- foreach (CPP_FILE ${CPP_FILES})
|
|
|
|
|
- get_filename_component (PATH ${CPP_FILE} PATH)
|
|
|
|
|
- if (PATH)
|
|
|
|
|
- string (REPLACE / \\ PATH ${PATH})
|
|
|
|
|
- source_group ("Source Files\\${PATH}" FILES ${CPP_FILE})
|
|
|
|
|
- endif ()
|
|
|
|
|
- endforeach ()
|
|
|
|
|
- foreach (H_FILE ${H_FILES})
|
|
|
|
|
- get_filename_component (PATH ${H_FILE} PATH)
|
|
|
|
|
- if (PATH)
|
|
|
|
|
- string (REPLACE / \\ PATH ${PATH})
|
|
|
|
|
- source_group ("Header Files\\${PATH}" FILES ${H_FILE})
|
|
|
|
|
- endif ()
|
|
|
|
|
- endforeach ()
|
|
|
|
|
- endif ()
|
|
|
|
|
endmacro ()
|
|
endmacro ()
|
|
|
|
|
|
|
|
# Macro for defining resource directories with optional arguments as follows:
|
|
# Macro for defining resource directories with optional arguments as follows:
|