Skip to content

Commit cf6be52

Browse files
committed
cmake includes
1 parent 72f818d commit cf6be52

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Taken from http://stackoverflow.com/questions/7787823/cmake-how-to-get-the-name-of-all-subdirectories-of-a-directory
2+
# Usage: SUBDIRLIST(SUBDIRS ${MY_CURRENT_DIR})
3+
4+
MACRO(SUBDIRLIST result curdir)
5+
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
6+
SET(dirlist "")
7+
FOREACH(child ${children})
8+
IF(IS_DIRECTORY ${curdir}/${child})
9+
LIST(APPEND dirlist ${child})
10+
ENDIF()
11+
ENDFOREACH()
12+
SET(${result} ${dirlist})
13+
ENDMACRO()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Accepts a variable holding the source files
2+
# Then creates source groups (for VS, Xcode etc) that replicate the folder hierarchy on disk
3+
4+
macro( create_source_groups source_files_variable )
5+
6+
foreach( source_file ${${source_files_variable}} )
7+
string( REGEX REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" relative_directory "${source_file}")
8+
string( REGEX REPLACE "[\\\\/][^\\\\/]*$" "" relative_directory "${relative_directory}")
9+
string( REGEX REPLACE "^[\\\\/]" "" relative_directory "${relative_directory}")
10+
string( REGEX REPLACE "\\.\\./" "" relative_directory "${relative_directory}")
11+
12+
if( WIN32 )
13+
string( REGEX REPLACE "/" "\\\\" relative_directory "${relative_directory}" )
14+
endif( WIN32 )
15+
16+
source_group( "${relative_directory}" FILES ${source_file} )
17+
endforeach()
18+
19+
endmacro()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Evaluates condition and sets variable
2+
3+
MACRO(EVAL_CONDITION name)
4+
IF(${ARGN})
5+
SET(${name} 1)
6+
ELSE()
7+
SET(${name} 0)
8+
ENDIF()
9+
ENDMACRO(EVAL_CONDITION)

0 commit comments

Comments
 (0)