add basic c++ project setup
This commit is contained in:
33
cmake/add_files.cmake
Normal file
33
cmake/add_files.cmake
Normal file
@@ -0,0 +1,33 @@
|
||||
#
|
||||
# Defines a list of files with a given name, prepends the relative path to the
|
||||
# source dir to each file if available and passes the list to PARENT_SCOPE.
|
||||
#
|
||||
# Usage:
|
||||
# add_files(
|
||||
# NAME_OF_FILES
|
||||
# file1.cpp
|
||||
# file2.cpp
|
||||
# ...
|
||||
# )
|
||||
#
|
||||
macro(add_files var_name)
|
||||
if(DEFINED SRC_DIR)
|
||||
file (RELATIVE_PATH _relPath "${SRC_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
else()
|
||||
file (RELATIVE_PATH _relPath "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
foreach (_src ${ARGN})
|
||||
if (_relPath)
|
||||
list (APPEND ${var_name} "${_relPath}/${_src}")
|
||||
else()
|
||||
list (APPEND ${var_name} "${_src}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if (_relPath)
|
||||
set(${var_name} ${${var_name}} PARENT_SCOPE)
|
||||
else()
|
||||
set(${var_name} ${${var_name}})
|
||||
endif()
|
||||
endmacro()
|
||||
12
cmake/create_source_groups.cmake
Normal file
12
cmake/create_source_groups.cmake
Normal file
@@ -0,0 +1,12 @@
|
||||
macro(create_source_groups)
|
||||
foreach(FILE ${ARGN})
|
||||
get_filename_component(GROUP "${FILE}" PATH)
|
||||
# changes /'s to \\'s
|
||||
string(REPLACE "/" "\\" GROUP "${GROUP}")
|
||||
|
||||
string(LENGTH "${GROUP}" GROUP_NAME_LENGTH)
|
||||
if (${GROUP_NAME_LENGTH} GREATER 0)
|
||||
source_group("${GROUP}" FILES "${FILE}")
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
Reference in New Issue
Block a user