Symaptic: utils.cmake@bde4ae8d615e

Mercurial Symaptic / file revision
summary | shortlog | changelog | graph | tags | bookmarks | branches | files | changeset | file | latest | revisions | annotate | diff | raw | help
utils.cmake
author sl@SLION-WIN7.fritz.box
2012年6月15日 03:10:57 +0200
changeset 0 bde4ae8d615e
child 1 260cb5ec6c19
permissions -rw-r--r--
First public contribution.
 1 # Copyright (c) 2009-2012 St駱hane Lenclud.
 2 # All rights reserved.
 3 # This component and the accompanying materials are made available
 4 # under the terms of the License "Eclipse Public License v1.0"
 5 # which accompanies this distribution, and is available
 6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
 7 #
 8 # Initial Contributors:
 9 # St駱hane Lenclud.
 10 #
 11 
 12 #
 13 # This file contains some generic cmake macros we are using for building Symbian
 14 #
 15 
 16 #-----------------------------------------------------
 17 #Push a target on our target stack
 18 macro(push_target targetName)
 19 	get_property(targetStackValue GLOBAL PROPERTY targetStack)
 20 	list(APPEND targetStackValue ${targetName})
 21 	set_property(GLOBAL PROPERTY targetStack ${targetStackValue})
 22 	#message("Push target: ${targetStackValue}")
 23 endmacro(push_target) 
 24 
 25 #-----------------------------------------------------
 26 #Pop the given target from our target stack
 27 macro(pop_target targetName)
 28 	get_property(targetStackValue GLOBAL PROPERTY targetStack)
 29 	list(LENGTH targetStackValue count)	
 30 	math( EXPR count "${count} - 1")
 31 	list(GET targetStackValue ${count} poppedTargetName)
 32 	if (NOT(${poppedTargetName} STREQUAL ${targetName}))
 33 		message(FATAL_ERROR "pop_target expecting ${poppedTargetName} instead of ${targetName}!")
 34 	endif (NOT(${poppedTargetName} STREQUAL ${targetName}))
 35 	list(REMOVE_AT targetStackValue ${count})
 36 	set_property(GLOBAL PROPERTY targetStack ${targetStackValue})	
 37 	#message("Pop target: ${targetName} :to: ${targetStackValue}")
 38 endmacro(pop_target) 
 39 
 40 #-----------------------------------------------------
 41 #Get the name of the target from the top of our stack
 42 macro(get_target targetName)
 43 	list(LENGTH targetStackValue count)	
 44 	math( EXPR count "${count} - 1")
 45 	set(${targetName} "")
 46 	if (NOT(${count} LESS 0))
 47 		list(GET targetStackValue ${count} ${targetName})
 48 	endif (NOT(${count} LESS 0))
 49 endmacro(get_target) 
 50 
 51 #-----------------------------------------------------
 52 #Add the given source files to our source prepending the sourcepath
 53 macro(add_source)
 54 	get_target(targetName)
 55 	set(sourcesProperty "${targetName}Sources")
 56 	get_property(sourcesPropertyValue GLOBAL PROPERTY ${sourcesProperty})
 57 		
 58 	foreach(mySource ${ARGV})
 59 		string(REGEX REPLACE "(^.+)" "${sourcepath}\1円" newsource ${mySource})		
 60 		set(sourcesPropertyValue ${sourcesPropertyValue} ${newsource})		
 61 	endforeach(mySource) 
 62 	
 63 	set_property(GLOBAL PROPERTY ${sourcesProperty} ${sourcesPropertyValue})
 64 	#message("${targetName} sources: ${sourcesPropertyValue}")
 65 endmacro(add_source)
 66 
 67 #-----------------------------------------------------
 68 #Get the sources for the current target
 69 macro(get_source sourceVar)
 70 	get_target(targetName)
 71 	set(sourcesProperty "${targetName}Sources")
 72 	get_property(sourcesPropertyValue GLOBAL PROPERTY ${sourcesProperty})
 73 	set(${sourceVar} ${sourcesPropertyValue})
 74 	#message("${targetName} sources: ${sourcesPropertyValue}")	
 75 endmacro(get_source)
 76 
 77 #-----------------------------------------------------
 78 #Add current cmake file to our source tree
 79 macro(add_cmake_source)
 80 	get_target(targetName)
 81 	set(sourcesProperty "${targetName}Sources")
 82 	get_property(sourcesPropertyValue GLOBAL PROPERTY ${sourcesProperty})
 83 	set(sourcesPropertyValue ${sourcesPropertyValue} ${CMAKE_CURRENT_LIST_FILE})		
 84 	set_property(GLOBAL PROPERTY ${sourcesProperty} ${sourcesPropertyValue})
 85 	
 86 	source_group(CMake FILES ${CMAKE_CURRENT_LIST_FILE})
 87 endmacro(add_cmake_source)
 88 
 89 #-----------------------------------------------------
 90 #TODO: implement macro to generate _uid file based on a template
 91 #Also add the generated CPP file to our ${source}
 92 macro(uid)
 93 	#set(source ${source} ${CMAKE_CURRENT_LIST_FILE})
 94 	#source_group(CMake FILES ${CMAKE_CURRENT_LIST_FILE})
 95 endmacro(uid)
 96 
 97 #-----------------------------------------------------
 98 #Add a pre-compiler define to the pre set target
 99 macro(add_define define)
 100 	get_target(targetName)
 101 	get_target_property(value ${targetName} COMPILE_DEFINITIONS)	
 102 	#message("Add define: ${define} to target: ${targetName}")
 103 	set(value ${value} ${define})	
 104 	set_target_properties(${targetName} PROPERTIES COMPILE_DEFINITIONS "${value}")
 105 endmacro(add_define)
 106 
 107 
 108 #-----------------------------------------------------
 109 #Perform Symbian bld.inf export
 110 macro(public_export source destination)
 111 	install(FILES 
 112 			${source}
 113 			DESTINATION ${PROJECT_SOURCE_DIR}/epoc32/include${destination} )
 114 endmacro(public_export)
 115 
 116 #-----------------------------------------------------
 117 #Perform Symbian bld.inf export
 118 macro(platform_export source destination)
 119 	install(FILES 
 120 			${source}
 121 			DESTINATION ${PROJECT_SOURCE_DIR}/epoc32/include/platform${destination} )
 122 endmacro(platform_export)
 123 
 124 #-----------------------------------------------------
 125 #Add system include path to our current target
 126 #Use those include path macro instead of cmake built-in include_directories as it allows us to set include directories per target instead of per directory.
 127 macro(system_include path)
 128 	get_target(targetName)
 129 	get_target_property(value ${targetName} COMPILE_FLAGS)
 130 	#MS CL compiler specific. I guess gcc should use -I instead of /I
 131 	if (${value} STREQUAL "value-NOTFOUND")
 132 		set(value "/I ${PROJECT_SOURCE_DIR}${path}")		
 133 	else (${value} STREQUAL "value-NOTFOUND")
 134 		set(value "${value} /I ${PROJECT_SOURCE_DIR}${path}")		
 135 	endif (${value} STREQUAL "value-NOTFOUND")
 136 	#message("Add system include: ${value}")	
 137 	set_target_properties(${targetName} PROPERTIES COMPILE_FLAGS "${value}")	
 138 endmacro(system_include)
 139 
 140 #-----------------------------------------------------
 141 #Add user include path to our current target
 142 #Use those include path macro instead of cmake built-in include_directories as it allows us to set include directories per target instead of per directory.
 143 #TODO: Is this working with releative path?
 144 macro(user_include path)
 145 	get_target(targetName)
 146 	get_target_property(value ${targetName} COMPILE_FLAGS)
 147 	#MS CL compiler specific. I guess gcc should use -I instead of /I
 148 	if (${value} STREQUAL "value-NOTFOUND")
 149 		set(value "/I ${CMAKE_CURRENT_LIST_DIR}/${path}")	
 150 	else (${value} STREQUAL "value-NOTFOUND")
 151 		set(value "${value} /I ${CMAKE_CURRENT_LIST_DIR}/${path}")	
 152 	endif (${value} STREQUAL "value-NOTFOUND")	
 153 	set_target_properties(${targetName} PROPERTIES COMPILE_FLAGS "${value}")
 154 endmacro(user_include)
 155 
 156 
 157 
 158 
 159 #Generate our configuration file
 160 #configure_file( ../../GameEngine/inc/GikConfig.h.cmake ../../GameEngine/inc/GikConfig.h )
 161 #Must make sure we include the generate config from the bynary tree
 162 #include_directories("${CMAKE_BINARY_DIR}/../../GameEngine/inc")
 163 
 164 
Symaptic
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /