OvAddProjects.cmake 2.28 KB
Newer Older
Jozef Legeny's avatar
Jozef Legeny committed
1 2
# Adds the current project to the global properties
FUNCTION(OV_ADD_THIS_TO_PROJECT_LIST)
3
	# MESSAGE(STATUS "ADDING: ${CMAKE_CURRENT_SOURCE_DIR}")
Jozef Legeny's avatar
Jozef Legeny committed
4 5 6 7 8 9 10 11

	# Add the dir to be parsed for documentation later. We need to do this before adding subdir, in case the subdir is the actual docs dir
	GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS)
	SET(OV_TMP "${OV_TMP};${CMAKE_CURRENT_SOURCE_DIR}")
	SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS ${OV_TMP})

ENDFUNCTION(OV_ADD_THIS_TO_PROJECT_LIST)

Jozef Legeny's avatar
Jozef Legeny committed
12 13 14 15 16 17 18 19 20
#
# Adds all directories as subdirectories to the CMake build, using the branch specified (if any) in the root CMakeList.txt or
# trunk otherwise.
#
# The branch variable name that is checked is made up from ${CURRENT_BRANCH_PREFIX}_${DIRNAMEUPPER}. 
#
# The script also adds the directory to the global list of projects.
#

Jozef Legeny's avatar
Jozef Legeny committed
21
FUNCTION(OV_ADD_PROJECTS CURRENT_FOLDER_PREFIX)
Jozef Legeny's avatar
Jozef Legeny committed
22 23 24 25 26 27 28 29

	FILE(GLOB FILENAMES "*") 

	FOREACH(FULLPATH ${FILENAMES})
		IF(IS_DIRECTORY ${FULLPATH} AND NOT ${FULLPATH} MATCHES ".*\\.svn")
			GET_FILENAME_COMPONENT(DIRNAME ${FULLPATH} NAME)

			STRING(TOUPPER ${DIRNAME} DIRNAMEUPPER)
Jussi Lindgren's avatar
Jussi Lindgren committed
30
			SET(SKIP_THIS_FOLDER "SKIP_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER}")	
Jozef Legeny's avatar
Jozef Legeny committed
31
			
Jussi Lindgren's avatar
Jussi Lindgren committed
32
			#MESSAGE(STATUS "Checking SKIP_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER} as branch var ${SKIP_THIS_FOLDER}")
Jozef Legeny's avatar
Jozef Legeny committed
33
			
Jozef Legeny's avatar
Jozef Legeny committed
34
			IF(${SKIP_THIS_FOLDER})
Jussi Lindgren's avatar
Jussi Lindgren committed
35
				MESSAGE(STATUS "Note: ${FULLPATH} has been skipped by setting SKIP_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER}")
Jozef Legeny's avatar
Jozef Legeny committed
36
			ELSE(${SKIP_THIS_FOLDER})
Jussi Lindgren's avatar
Jussi Lindgren committed
37
				# MESSAGE(STATUS "Inserting folder ${FULLPATH}")		
Jozef Legeny's avatar
Jozef Legeny committed
38 39 40
				
				# Add the dir to be parsed for documentation later. We need to do this before adding subdir, in case the subdir is the actual docs dir
				GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS)
Jozef Legeny's avatar
Jozef Legeny committed
41
				SET(OV_TMP "${OV_TMP};${FULLPATH}")
Jozef Legeny's avatar
Jozef Legeny committed
42 43
				SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS ${OV_TMP})

Jozef Legeny's avatar
Jozef Legeny committed
44
				SET(OV_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${DIRNAME}")
Jozef Legeny's avatar
Jozef Legeny committed
45
				GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS_BUILD_DIR)
Jozef Legeny's avatar
Jozef Legeny committed
46
				SET(OV_TMP "${OV_TMP};${OV_CURRENT_BINARY_DIR}")
Jozef Legeny's avatar
Jozef Legeny committed
47 48
				SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS_BUILD_DIR ${OV_TMP})

Jozef Legeny's avatar
Jozef Legeny committed
49
				add_subdirectory(${FULLPATH})
Jozef Legeny's avatar
Jozef Legeny committed
50
				
Jozef Legeny's avatar
Jozef Legeny committed
51
			ENDIF(${SKIP_THIS_FOLDER})
Jozef Legeny's avatar
Jozef Legeny committed
52 53 54 55 56
		ENDIF(IS_DIRECTORY ${FULLPATH} AND NOT ${FULLPATH} MATCHES ".*\\.svn")			
	ENDFOREACH(FULLPATH ${FILENAMES})

ENDFUNCTION(OV_ADD_PROJECTS)