cmTarget.cxx 240 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmTarget.h"
  11. #include "cmake.h"
  12. #include "cmMakefile.h"
  13. #include "cmSourceFile.h"
  14. #include "cmLocalGenerator.h"
  15. #include "cmGlobalGenerator.h"
  16. #include "cmComputeLinkInformation.h"
  17. #include "cmDocumentCompileDefinitions.h"
  18. #include "cmDocumentGeneratorExpressions.h"
  19. #include "cmDocumentLocationUndefined.h"
  20. #include "cmListFileCache.h"
  21. #include "cmGeneratorExpression.h"
  22. #include "cmGeneratorExpressionDAGChecker.h"
  23. #include <cmsys/RegularExpression.hxx>
  24. #include <map>
  25. #include <set>
  26. #include <queue>
  27. #include <stdlib.h> // required for atof
  28. #include <assert.h>
  29. const char* cmTarget::GetTargetTypeName(TargetType targetType)
  30. {
  31. switch( targetType )
  32. {
  33. case cmTarget::STATIC_LIBRARY:
  34. return "STATIC_LIBRARY";
  35. case cmTarget::MODULE_LIBRARY:
  36. return "MODULE_LIBRARY";
  37. case cmTarget::SHARED_LIBRARY:
  38. return "SHARED_LIBRARY";
  39. case cmTarget::OBJECT_LIBRARY:
  40. return "OBJECT_LIBRARY";
  41. case cmTarget::EXECUTABLE:
  42. return "EXECUTABLE";
  43. case cmTarget::UTILITY:
  44. return "UTILITY";
  45. case cmTarget::GLOBAL_TARGET:
  46. return "GLOBAL_TARGET";
  47. case cmTarget::UNKNOWN_LIBRARY:
  48. return "UNKNOWN_LIBRARY";
  49. }
  50. assert(0 && "Unexpected target type");
  51. return 0;
  52. }
  53. //----------------------------------------------------------------------------
  54. struct cmTarget::OutputInfo
  55. {
  56. std::string OutDir;
  57. std::string ImpDir;
  58. std::string PdbDir;
  59. };
  60. //----------------------------------------------------------------------------
  61. struct cmTarget::ImportInfo
  62. {
  63. bool NoSOName;
  64. std::string Location;
  65. std::string SOName;
  66. std::string ImportLibrary;
  67. cmTarget::LinkInterface LinkInterface;
  68. };
  69. struct TargetConfigPair : public std::pair<cmTarget*, std::string> {
  70. TargetConfigPair(cmTarget* tgt, const std::string &config)
  71. : std::pair<cmTarget*, std::string>(tgt, config) {}
  72. };
  73. //----------------------------------------------------------------------------
  74. class cmTargetInternals
  75. {
  76. public:
  77. cmTargetInternals()
  78. {
  79. this->SourceFileFlagsConstructed = false;
  80. }
  81. cmTargetInternals(cmTargetInternals const& r)
  82. {
  83. this->SourceFileFlagsConstructed = false;
  84. // Only some of these entries are part of the object state.
  85. // Others not copied here are result caches.
  86. this->SourceEntries = r.SourceEntries;
  87. }
  88. ~cmTargetInternals();
  89. typedef cmTarget::SourceFileFlags SourceFileFlags;
  90. std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap;
  91. bool SourceFileFlagsConstructed;
  92. // The backtrace when the target was created.
  93. cmListFileBacktrace Backtrace;
  94. // Cache link interface computation from each configuration.
  95. struct OptionalLinkInterface: public cmTarget::LinkInterface
  96. {
  97. OptionalLinkInterface(): Exists(false) {}
  98. bool Exists;
  99. };
  100. typedef std::map<TargetConfigPair, OptionalLinkInterface>
  101. LinkInterfaceMapType;
  102. LinkInterfaceMapType LinkInterfaceMap;
  103. typedef std::map<cmStdString, cmTarget::OutputInfo> OutputInfoMapType;
  104. OutputInfoMapType OutputInfoMap;
  105. typedef std::map<TargetConfigPair, cmTarget::ImportInfo>
  106. ImportInfoMapType;
  107. ImportInfoMapType ImportInfoMap;
  108. // Cache link implementation computation from each configuration.
  109. typedef std::map<TargetConfigPair,
  110. cmTarget::LinkImplementation> LinkImplMapType;
  111. LinkImplMapType LinkImplMap;
  112. typedef std::map<TargetConfigPair, cmTarget::LinkClosure>
  113. LinkClosureMapType;
  114. LinkClosureMapType LinkClosureMap;
  115. struct SourceEntry { std::vector<cmSourceFile*> Depends; };
  116. typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType;
  117. SourceEntriesType SourceEntries;
  118. struct TargetPropertyEntry {
  119. TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge,
  120. const std::string &targetName = std::string())
  121. : ge(cge), TargetName(targetName)
  122. {}
  123. const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge;
  124. std::vector<std::string> CachedEntries;
  125. const std::string TargetName;
  126. };
  127. std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
  128. std::vector<TargetPropertyEntry*> CompileOptionsEntries;
  129. std::vector<cmValueWithOrigin> LinkInterfacePropertyEntries;
  130. std::map<std::string, std::vector<TargetPropertyEntry*> >
  131. CachedLinkInterfaceIncludeDirectoriesEntries;
  132. std::map<std::string, std::vector<TargetPropertyEntry*> >
  133. CachedLinkInterfaceCompileOptionsEntries;
  134. std::map<std::string, std::string> CachedLinkInterfaceCompileDefinitions;
  135. std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone;
  136. std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone;
  137. std::map<std::string, bool> CacheLinkInterfaceCompileOptionsDone;
  138. };
  139. //----------------------------------------------------------------------------
  140. void deleteAndClear(
  141. std::vector<cmTargetInternals::TargetPropertyEntry*> &entries)
  142. {
  143. for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
  144. it = entries.begin(),
  145. end = entries.end();
  146. it != end; ++it)
  147. {
  148. delete *it;
  149. }
  150. entries.clear();
  151. }
  152. //----------------------------------------------------------------------------
  153. void deleteAndClear(
  154. std::map<std::string,
  155. std::vector<cmTargetInternals::TargetPropertyEntry*> > &entries)
  156. {
  157. for (std::map<std::string,
  158. std::vector<cmTargetInternals::TargetPropertyEntry*> >::iterator
  159. it = entries.begin(), end = entries.end(); it != end; ++it)
  160. {
  161. deleteAndClear(it->second);
  162. }
  163. }
  164. //----------------------------------------------------------------------------
  165. cmTargetInternals::~cmTargetInternals()
  166. {
  167. deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries);
  168. deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries);
  169. }
  170. //----------------------------------------------------------------------------
  171. cmTarget::cmTarget()
  172. {
  173. this->Makefile = 0;
  174. this->PolicyStatusCMP0003 = cmPolicies::WARN;
  175. this->PolicyStatusCMP0004 = cmPolicies::WARN;
  176. this->PolicyStatusCMP0008 = cmPolicies::WARN;
  177. this->PolicyStatusCMP0020 = cmPolicies::WARN;
  178. this->PolicyStatusCMP0021 = cmPolicies::WARN;
  179. this->PolicyStatusCMP0022 = cmPolicies::WARN;
  180. this->LinkLibrariesAnalyzed = false;
  181. this->HaveInstallRule = false;
  182. this->DLLPlatform = false;
  183. this->IsApple = false;
  184. this->IsImportedTarget = false;
  185. this->BuildInterfaceIncludesAppended = false;
  186. this->DebugIncludesDone = false;
  187. this->DebugCompileOptionsDone = false;
  188. }
  189. //----------------------------------------------------------------------------
  190. void cmTarget::DefineProperties(cmake *cm)
  191. {
  192. cm->DefineProperty
  193. ("AUTOMOC", cmProperty::TARGET,
  194. "Should the target be processed with automoc (for Qt projects).",
  195. "AUTOMOC is a boolean specifying whether CMake will handle "
  196. "the Qt moc preprocessor automatically, i.e. without having to use "
  197. "the QT4_WRAP_CPP() or QT5_WRAP_CPP() macro. Currently Qt4 and Qt5 are "
  198. "supported. "
  199. "When this property is set to TRUE, CMake will scan the source files "
  200. "at build time and invoke moc accordingly. "
  201. "If an #include statement like #include \"moc_foo.cpp\" is found, "
  202. "the Q_OBJECT class declaration is expected in the header, and moc is "
  203. "run on the header file. "
  204. "If an #include statement like #include \"foo.moc\" is found, "
  205. "then a Q_OBJECT is expected in the current source file and moc "
  206. "is run on the file itself. "
  207. "Additionally, all header files are parsed for Q_OBJECT macros, "
  208. "and if found, moc is also executed on those files. The resulting "
  209. "moc files, which are not included as shown above in any of the source "
  210. "files are included in a generated <targetname>_automoc.cpp file, "
  211. "which is compiled as part of the target."
  212. "This property is initialized by the value of the variable "
  213. "CMAKE_AUTOMOC if it is set when a target is created.\n"
  214. "Additional command line options for moc can be set via the "
  215. "AUTOMOC_MOC_OPTIONS property.\n"
  216. "By setting the CMAKE_AUTOMOC_RELAXED_MODE variable to TRUE the rules "
  217. "for searching the files which will be processed by moc can be relaxed. "
  218. "See the documentation for this variable for more details.\n"
  219. "The global property AUTOMOC_TARGETS_FOLDER can be used to group the "
  220. "automoc targets together in an IDE, e.g. in MSVS.");
  221. cm->DefineProperty
  222. ("AUTOMOC_MOC_OPTIONS", cmProperty::TARGET,
  223. "Additional options for moc when using automoc (see the AUTOMOC property)",
  224. "This property is only used if the AUTOMOC property is set to TRUE for "
  225. "this target. In this case, it holds additional command line options "
  226. "which will be used when moc is executed during the build, i.e. it is "
  227. "equivalent to the optional OPTIONS argument of the qt4_wrap_cpp() "
  228. "macro.\n"
  229. "By default it is empty.");
  230. cm->DefineProperty
  231. ("BUILD_WITH_INSTALL_RPATH", cmProperty::TARGET,
  232. "Should build tree targets have install tree rpaths.",
  233. "BUILD_WITH_INSTALL_RPATH is a boolean specifying whether to link "
  234. "the target in the build tree with the INSTALL_RPATH. This takes "
  235. "precedence over SKIP_BUILD_RPATH and avoids the need for relinking "
  236. "before installation. "
  237. "This property is initialized by the value of the variable "
  238. "CMAKE_BUILD_WITH_INSTALL_RPATH if it is set when a target is created.");
  239. cm->DefineProperty
  240. ("COMPILE_FLAGS", cmProperty::TARGET,
  241. "Additional flags to use when compiling this target's sources.",
  242. "The COMPILE_FLAGS property sets additional compiler flags used "
  243. "to build sources within the target. Use COMPILE_DEFINITIONS "
  244. "to pass additional preprocessor definitions.");
  245. cm->DefineProperty
  246. ("COMPILE_DEFINITIONS", cmProperty::TARGET,
  247. "Preprocessor definitions for compiling a target's sources.",
  248. "The COMPILE_DEFINITIONS property may be set to a "
  249. "semicolon-separated list of preprocessor "
  250. "definitions using the syntax VAR or VAR=value. Function-style "
  251. "definitions are not supported. CMake will automatically escape "
  252. "the value correctly for the native build system (note that CMake "
  253. "language syntax may require escapes to specify some values). "
  254. "This property may be set on a per-configuration basis using the name "
  255. "COMPILE_DEFINITIONS_<CONFIG> where <CONFIG> is an upper-case name "
  256. "(ex. \"COMPILE_DEFINITIONS_DEBUG\").\n"
  257. "CMake will automatically drop some definitions that "
  258. "are not supported by the native build tool. "
  259. "The VS6 IDE does not support definition values with spaces "
  260. "(but NMake does).\n"
  261. "Contents of COMPILE_DEFINITIONS may use \"generator expressions\" with "
  262. "the syntax \"$<...>\". "
  263. CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
  264. CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS
  265. CM_DOCUMENT_COMPILE_DEFINITIONS_DISCLAIMER);
  266. cm->DefineProperty
  267. ("COMPILE_DEFINITIONS_<CONFIG>", cmProperty::TARGET,
  268. "Per-configuration preprocessor definitions on a target.",
  269. "This is the configuration-specific version of COMPILE_DEFINITIONS.");
  270. cm->DefineProperty
  271. ("COMPILE_OPTIONS", cmProperty::TARGET,
  272. "List of options to pass to the compiler.",
  273. "This property specifies the list of options specified "
  274. "so far for this property. "
  275. "This property exists on directories and targets. "
  276. "\n"
  277. "The target property values are used by the generators to set "
  278. "the options for the compiler.\n"
  279. "Contents of COMPILE_OPTIONS may use \"generator expressions\" with "
  280. "the syntax \"$<...>\". "
  281. CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
  282. CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
  283. cm->DefineProperty
  284. ("INTERFACE_COMPILE_OPTIONS", cmProperty::TARGET,
  285. "List of interface options to pass to the compiler.",
  286. "Targets may populate this property to publish the compile options "
  287. "required to compile against the headers for the target. Consuming "
  288. "targets can add entries to their own COMPILE_OPTIONS property such "
  289. "as $<TARGET_PROPERTY:foo,INTERFACE_COMPILE_OPTIONS> to use the "
  290. "compile options specified in the interface of 'foo'."
  291. "\n"
  292. CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
  293. CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
  294. cm->DefineProperty
  295. ("DEFINE_SYMBOL", cmProperty::TARGET,
  296. "Define a symbol when compiling this target's sources.",
  297. "DEFINE_SYMBOL sets the name of the preprocessor symbol defined when "
  298. "compiling sources in a shared library. "
  299. "If not set here then it is set to target_EXPORTS by default "
  300. "(with some substitutions if the target is not a valid C "
  301. "identifier). This is useful for headers to know whether they are "
  302. "being included from inside their library or outside to properly "
  303. "setup dllexport/dllimport decorations. ");
  304. cm->DefineProperty
  305. ("DEBUG_POSTFIX", cmProperty::TARGET,
  306. "See target property <CONFIG>_POSTFIX.",
  307. "This property is a special case of the more-general <CONFIG>_POSTFIX "
  308. "property for the DEBUG configuration.");
  309. cm->DefineProperty
  310. ("<CONFIG>_POSTFIX", cmProperty::TARGET,
  311. "Postfix to append to the target file name for configuration <CONFIG>.",
  312. "When building with configuration <CONFIG> the value of this property "
  313. "is appended to the target file name built on disk. "
  314. "For non-executable targets, this property is initialized by the value "
  315. "of the variable CMAKE_<CONFIG>_POSTFIX if it is set when a target is "
  316. "created. "
  317. "This property is ignored on the Mac for Frameworks and App Bundles.");
  318. cm->DefineProperty
  319. ("EchoString", cmProperty::TARGET,
  320. "A message to be displayed when the target is built.",
  321. "A message to display on some generators (such as makefiles) when "
  322. "the target is built.");
  323. cm->DefineProperty
  324. ("BUNDLE", cmProperty::TARGET,
  325. "This target is a CFBundle on the Mac.",
  326. "If a module library target has this property set to true it will "
  327. "be built as a CFBundle when built on the mac. It will have the "
  328. "directory structure required for a CFBundle and will be suitable "
  329. "to be used for creating Browser Plugins or other application "
  330. "resources.");
  331. cm->DefineProperty
  332. ("BUNDLE_EXTENSION", cmProperty::TARGET,
  333. "The file extension used to name a BUNDLE target on the Mac.",
  334. "The default value is \"bundle\" - you can also use \"plugin\" or "
  335. "whatever file extension is required by the host app for your "
  336. "bundle.");
  337. cm->DefineProperty
  338. ("EXCLUDE_FROM_DEFAULT_BUILD", cmProperty::TARGET,
  339. "Exclude target from \"Build Solution\".",
  340. "This property is only used by Visual Studio generators 7 and above. "
  341. "When set to TRUE, the target will not be built when you press "
  342. "\"Build Solution\".");
  343. cm->DefineProperty
  344. ("EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG>", cmProperty::TARGET,
  345. "Per-configuration version of target exclusion from \"Build Solution\". ",
  346. "This is the configuration-specific version of "
  347. "EXCLUDE_FROM_DEFAULT_BUILD. If the generic EXCLUDE_FROM_DEFAULT_BUILD "
  348. "is also set on a target, EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG> takes "
  349. "precedence in configurations for which it has a value.");
  350. cm->DefineProperty
  351. ("FRAMEWORK", cmProperty::TARGET,
  352. "This target is a framework on the Mac.",
  353. "If a shared library target has this property set to true it will "
  354. "be built as a framework when built on the mac. It will have the "
  355. "directory structure required for a framework and will be suitable "
  356. "to be used with the -framework option");
  357. cm->DefineProperty
  358. ("HAS_CXX", cmProperty::TARGET,
  359. "Link the target using the C++ linker tool (obsolete).",
  360. "This is equivalent to setting the LINKER_LANGUAGE property to CXX. "
  361. "See that property's documentation for details.");
  362. cm->DefineProperty
  363. ("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM", cmProperty::TARGET,
  364. "Specify #include line transforms for dependencies in a target.",
  365. "This property specifies rules to transform macro-like #include lines "
  366. "during implicit dependency scanning of C and C++ source files. "
  367. "The list of rules must be semicolon-separated with each entry of "
  368. "the form \"A_MACRO(%)=value-with-%\" (the % must be literal). "
  369. "During dependency scanning occurrences of A_MACRO(...) on #include "
  370. "lines will be replaced by the value given with the macro argument "
  371. "substituted for '%'. For example, the entry\n"
  372. " MYDIR(%)=<mydir/%>\n"
  373. "will convert lines of the form\n"
  374. " #include MYDIR(myheader.h)\n"
  375. "to\n"
  376. " #include <mydir/myheader.h>\n"
  377. "allowing the dependency to be followed.\n"
  378. "This property applies to sources in the target on which it is set.");
  379. cm->DefineProperty
  380. ("IMPORT_PREFIX", cmProperty::TARGET,
  381. "What comes before the import library name.",
  382. "Similar to the target property PREFIX, but used for import libraries "
  383. "(typically corresponding to a DLL) instead of regular libraries. "
  384. "A target property that can be set to override the prefix "
  385. "(such as \"lib\") on an import library name.");
  386. cm->DefineProperty
  387. ("IMPORT_SUFFIX", cmProperty::TARGET,
  388. "What comes after the import library name.",
  389. "Similar to the target property SUFFIX, but used for import libraries "
  390. "(typically corresponding to a DLL) instead of regular libraries. "
  391. "A target property that can be set to override the suffix "
  392. "(such as \".lib\") on an import library name.");
  393. cm->DefineProperty
  394. ("IMPORTED", cmProperty::TARGET,
  395. "Read-only indication of whether a target is IMPORTED.",
  396. "The boolean value of this property is true for targets created with "
  397. "the IMPORTED option to add_executable or add_library. "
  398. "It is false for targets built within the project.");
  399. cm->DefineProperty
  400. ("IMPORTED_CONFIGURATIONS", cmProperty::TARGET,
  401. "Configurations provided for an IMPORTED target.",
  402. "Set this to the list of configuration names available for an "
  403. "IMPORTED target. "
  404. "The names correspond to configurations defined in the project from "
  405. "which the target is imported. "
  406. "If the importing project uses a different set of configurations "
  407. "the names may be mapped using the MAP_IMPORTED_CONFIG_<CONFIG> "
  408. "property. "
  409. "Ignored for non-imported targets.");
  410. cm->DefineProperty
  411. ("IMPORTED_IMPLIB", cmProperty::TARGET,
  412. "Full path to the import library for an IMPORTED target.",
  413. "Set this to the location of the \".lib\" part of a windows DLL. "
  414. "Ignored for non-imported targets.");
  415. cm->DefineProperty
  416. ("IMPORTED_IMPLIB_<CONFIG>", cmProperty::TARGET,
  417. "<CONFIG>-specific version of IMPORTED_IMPLIB property.",
  418. "Configuration names correspond to those provided by the project "
  419. "from which the target is imported.");
  420. cm->DefineProperty
  421. ("IMPORTED_LINK_DEPENDENT_LIBRARIES", cmProperty::TARGET,
  422. "Dependent shared libraries of an imported shared library.",
  423. "Shared libraries may be linked to other shared libraries as part "
  424. "of their implementation. On some platforms the linker searches "
  425. "for the dependent libraries of shared libraries they are including "
  426. "in the link. "
  427. "Set this property to the list of dependent shared libraries of an "
  428. "imported library. "
  429. "The list "
  430. "should be disjoint from the list of interface libraries in the "
  431. "INTERFACE_LINK_LIBRARIES property. On platforms requiring "
  432. "dependent shared libraries to be found at link time CMake uses this "
  433. "list to add appropriate files or paths to the link command line. "
  434. "Ignored for non-imported targets.");
  435. cm->DefineProperty
  436. ("IMPORTED_LINK_DEPENDENT_LIBRARIES_<CONFIG>", cmProperty::TARGET,
  437. "<CONFIG>-specific version of IMPORTED_LINK_DEPENDENT_LIBRARIES.",
  438. "Configuration names correspond to those provided by the project "
  439. "from which the target is imported. "
  440. "If set, this property completely overrides the generic property "
  441. "for the named configuration.");
  442. cm->DefineProperty
  443. ("IMPORTED_LINK_INTERFACE_LIBRARIES", cmProperty::TARGET,
  444. "Transitive link interface of an IMPORTED target.",
  445. "Set this to the list of libraries whose interface is included when "
  446. "an IMPORTED library target is linked to another target. "
  447. "The libraries will be included on the link line for the target. "
  448. "Unlike the LINK_INTERFACE_LIBRARIES property, this property applies "
  449. "to all imported target types, including STATIC libraries. "
  450. "This property is ignored for non-imported targets.\n"
  451. "This property is ignored if the target also has a non-empty "
  452. "INTERFACE_LINK_LIBRARIES property.\n"
  453. "This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead.");
  454. cm->DefineProperty
  455. ("IMPORTED_LINK_INTERFACE_LIBRARIES_<CONFIG>", cmProperty::TARGET,
  456. "<CONFIG>-specific version of IMPORTED_LINK_INTERFACE_LIBRARIES.",
  457. "Configuration names correspond to those provided by the project "
  458. "from which the target is imported. "
  459. "If set, this property completely overrides the generic property "
  460. "for the named configuration.\n"
  461. "This property is ignored if the target also has a non-empty "
  462. "INTERFACE_LINK_LIBRARIES property.\n"
  463. "This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead.");
  464. cm->DefineProperty
  465. ("IMPORTED_LINK_INTERFACE_LANGUAGES", cmProperty::TARGET,
  466. "Languages compiled into an IMPORTED static library.",
  467. "Set this to the list of languages of source files compiled to "
  468. "produce a STATIC IMPORTED library (such as \"C\" or \"CXX\"). "
  469. "CMake accounts for these languages when computing how to link a "
  470. "target to the imported library. "
  471. "For example, when a C executable links to an imported C++ static "
  472. "library CMake chooses the C++ linker to satisfy language runtime "
  473. "dependencies of the static library. "
  474. "\n"
  475. "This property is ignored for targets that are not STATIC libraries. "
  476. "This property is ignored for non-imported targets.");
  477. cm->DefineProperty
  478. ("IMPORTED_LINK_INTERFACE_LANGUAGES_<CONFIG>", cmProperty::TARGET,
  479. "<CONFIG>-specific version of IMPORTED_LINK_INTERFACE_LANGUAGES.",
  480. "Configuration names correspond to those provided by the project "
  481. "from which the target is imported. "
  482. "If set, this property completely overrides the generic property "
  483. "for the named configuration.");
  484. cm->DefineProperty
  485. ("IMPORTED_LINK_INTERFACE_MULTIPLICITY", cmProperty::TARGET,
  486. "Repetition count for cycles of IMPORTED static libraries.",
  487. "This is LINK_INTERFACE_MULTIPLICITY for IMPORTED targets.");
  488. cm->DefineProperty
  489. ("IMPORTED_LINK_INTERFACE_MULTIPLICITY_<CONFIG>", cmProperty::TARGET,
  490. "<CONFIG>-specific version of IMPORTED_LINK_INTERFACE_MULTIPLICITY.",
  491. "If set, this property completely overrides the generic property "
  492. "for the named configuration.");
  493. cm->DefineProperty
  494. ("IMPORTED_LOCATION", cmProperty::TARGET,
  495. "Full path to the main file on disk for an IMPORTED target.",
  496. "Set this to the location of an IMPORTED target file on disk. "
  497. "For executables this is the location of the executable file. "
  498. "For bundles on OS X this is the location of the executable file "
  499. "inside Contents/MacOS under the application bundle folder. "
  500. "For static libraries and modules this is the location of the "
  501. "library or module. "
  502. "For shared libraries on non-DLL platforms this is the location of "
  503. "the shared library. "
  504. "For frameworks on OS X this is the location of the library file "
  505. "symlink just inside the framework folder. "
  506. "For DLLs this is the location of the \".dll\" part of the library. "
  507. "For UNKNOWN libraries this is the location of the file to be linked. "
  508. "Ignored for non-imported targets."
  509. "\n"
  510. "Projects may skip IMPORTED_LOCATION if the configuration-specific "
  511. "property IMPORTED_LOCATION_<CONFIG> is set. "
  512. "To get the location of an imported target read one of the "
  513. "LOCATION or LOCATION_<CONFIG> properties.");
  514. cm->DefineProperty
  515. ("IMPORTED_LOCATION_<CONFIG>", cmProperty::TARGET,
  516. "<CONFIG>-specific version of IMPORTED_LOCATION property.",
  517. "Configuration names correspond to those provided by the project "
  518. "from which the target is imported.");
  519. cm->DefineProperty
  520. ("IMPORTED_SONAME", cmProperty::TARGET,
  521. "The \"soname\" of an IMPORTED target of shared library type.",
  522. "Set this to the \"soname\" embedded in an imported shared library. "
  523. "This is meaningful only on platforms supporting the feature. "
  524. "Ignored for non-imported targets.");
  525. cm->DefineProperty
  526. ("IMPORTED_SONAME_<CONFIG>", cmProperty::TARGET,
  527. "<CONFIG>-specific version of IMPORTED_SONAME property.",
  528. "Configuration names correspond to those provided by the project "
  529. "from which the target is imported.");
  530. cm->DefineProperty
  531. ("IMPORTED_NO_SONAME", cmProperty::TARGET,
  532. "Specifies that an IMPORTED shared library target has no \"soname\". ",
  533. "Set this property to true for an imported shared library file that "
  534. "has no \"soname\" field. "
  535. "CMake may adjust generated link commands for some platforms to prevent "
  536. "the linker from using the path to the library in place of its missing "
  537. "soname. "
  538. "Ignored for non-imported targets.");
  539. cm->DefineProperty
  540. ("IMPORTED_NO_SONAME_<CONFIG>", cmProperty::TARGET,
  541. "<CONFIG>-specific version of IMPORTED_NO_SONAME property.",
  542. "Configuration names correspond to those provided by the project "
  543. "from which the target is imported.");
  544. cm->DefineProperty
  545. ("EXCLUDE_FROM_ALL", cmProperty::TARGET,
  546. "Exclude the target from the all target.",
  547. "A property on a target that indicates if the target is excluded "
  548. "from the default build target. If it is not, then with a Makefile "
  549. "for example typing make will cause this target to be built. "
  550. "The same concept applies to the default build of other generators. "
  551. "Installing a target with EXCLUDE_FROM_ALL set to true has "
  552. "undefined behavior.");
  553. cm->DefineProperty
  554. ("LINK_LIBRARIES", cmProperty::TARGET,
  555. "List of direct link dependencies.",
  556. "This property specifies the list of libraries or targets which will be "
  557. "used for linking. "
  558. "In addition to accepting values from the target_link_libraries "
  559. "command, values may be set directly on any target using the "
  560. "set_property command. "
  561. "\n"
  562. "The target property values are used by the generators to set "
  563. "the link libraries for the compiler. "
  564. "See also the target_link_libraries command.\n"
  565. "Contents of LINK_LIBRARIES may use \"generator expressions\" with "
  566. "the syntax \"$<...>\". "
  567. CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS);
  568. cm->DefineProperty
  569. ("INCLUDE_DIRECTORIES", cmProperty::TARGET,
  570. "List of preprocessor include file search directories.",
  571. "This property specifies the list of directories given "
  572. "so far to the include_directories command. "
  573. "This property exists on directories and targets. "
  574. "In addition to accepting values from the include_directories "
  575. "command, values may be set directly on any directory or any "
  576. "target using the set_property command. "
  577. "A target gets its initial value for this property from the value "
  578. "of the directory property. "
  579. "A directory gets its initial value from its parent directory if "
  580. "it has one. "
  581. "Both directory and target property values are adjusted by calls "
  582. "to the include_directories command."
  583. "\n"
  584. "The target property values are used by the generators to set "
  585. "the include paths for the compiler. "
  586. "See also the include_directories command.\n"
  587. "Contents of INCLUDE_DIRECTORIES may use \"generator expressions\" with "
  588. "the syntax \"$<...>\". "
  589. CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
  590. CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
  591. cm->DefineProperty
  592. ("INSTALL_NAME_DIR", cmProperty::TARGET,
  593. "Mac OSX directory name for installed targets.",
  594. "INSTALL_NAME_DIR is a string specifying the "
  595. "directory portion of the \"install_name\" field of shared libraries "
  596. "on Mac OSX to use in the installed targets. ");
  597. cm->DefineProperty
  598. ("INSTALL_RPATH", cmProperty::TARGET,
  599. "The rpath to use for installed targets.",
  600. "A semicolon-separated list specifying the rpath "
  601. "to use in installed targets (for platforms that support it). "
  602. "This property is initialized by the value of the variable "
  603. "CMAKE_INSTALL_RPATH if it is set when a target is created.");
  604. cm->DefineProperty
  605. ("INSTALL_RPATH_USE_LINK_PATH", cmProperty::TARGET,
  606. "Add paths to linker search and installed rpath.",
  607. "INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to true will "
  608. "append directories in the linker search path and outside the "
  609. "project to the INSTALL_RPATH. "
  610. "This property is initialized by the value of the variable "
  611. "CMAKE_INSTALL_RPATH_USE_LINK_PATH if it is set when a target is "
  612. "created.");
  613. cm->DefineProperty
  614. ("INTERPROCEDURAL_OPTIMIZATION", cmProperty::TARGET,
  615. "Enable interprocedural optimization for a target.",
  616. "If set to true, enables interprocedural optimizations "
  617. "if they are known to be supported by the compiler.");
  618. cm->DefineProperty
  619. ("INTERPROCEDURAL_OPTIMIZATION_<CONFIG>", cmProperty::TARGET,
  620. "Per-configuration interprocedural optimization for a target.",
  621. "This is a per-configuration version of INTERPROCEDURAL_OPTIMIZATION. "
  622. "If set, this property overrides the generic property "
  623. "for the named configuration.");
  624. cm->DefineProperty
  625. ("LABELS", cmProperty::TARGET,
  626. "Specify a list of text labels associated with a target.",
  627. "Target label semantics are currently unspecified.");
  628. cm->DefineProperty
  629. ("LINK_FLAGS", cmProperty::TARGET,
  630. "Additional flags to use when linking this target.",
  631. "The LINK_FLAGS property can be used to add extra flags to the "
  632. "link step of a target. LINK_FLAGS_<CONFIG> will add to the "
  633. "configuration <CONFIG>, "
  634. "for example, DEBUG, RELEASE, MINSIZEREL, RELWITHDEBINFO. ");
  635. cm->DefineProperty
  636. ("LINK_FLAGS_<CONFIG>", cmProperty::TARGET,
  637. "Per-configuration linker flags for a target.",
  638. "This is the configuration-specific version of LINK_FLAGS.");
  639. #define CM_LINK_SEARCH_SUMMARY \
  640. "Some linkers support switches such as -Bstatic and -Bdynamic " \
  641. "to determine whether to use static or shared libraries for -lXXX " \
  642. "options. CMake uses these options to set the link type for " \
  643. "libraries whose full paths are not known or (in some cases) are in " \
  644. "implicit link directories for the platform. "
  645. cm->DefineProperty
  646. ("LINK_SEARCH_START_STATIC", cmProperty::TARGET,
  647. "Assume the linker looks for static libraries by default.",
  648. CM_LINK_SEARCH_SUMMARY
  649. "By default the linker search type is assumed to be -Bdynamic at "
  650. "the beginning of the library list. This property switches the "
  651. "assumption to -Bstatic. It is intended for use when linking an "
  652. "executable statically (e.g. with the GNU -static option). "
  653. "See also LINK_SEARCH_END_STATIC.");
  654. cm->DefineProperty
  655. ("LINK_SEARCH_END_STATIC", cmProperty::TARGET,
  656. "End a link line such that static system libraries are used.",
  657. CM_LINK_SEARCH_SUMMARY
  658. "By default CMake adds an option at the end of the library list (if "
  659. "necessary) to set the linker search type back to its starting type. "
  660. "This property switches the final linker search type to -Bstatic "
  661. "regardless of how it started. "
  662. "See also LINK_SEARCH_START_STATIC.");
  663. cm->DefineProperty
  664. ("LINKER_LANGUAGE", cmProperty::TARGET,
  665. "Specifies language whose compiler will invoke the linker.",
  666. "For executables, shared libraries, and modules, this sets the "
  667. "language whose compiler is used to link the target "
  668. "(such as \"C\" or \"CXX\"). "
  669. "A typical value for an executable is the language of the source "
  670. "file providing the program entry point (main). "
  671. "If not set, the language with the highest linker preference "
  672. "value is the default. "
  673. "See documentation of CMAKE_<LANG>_LINKER_PREFERENCE variables.");
  674. cm->DefineProperty
  675. ("LOCATION", cmProperty::TARGET,
  676. "Read-only location of a target on disk.",
  677. "For an imported target, this read-only property returns the value of "
  678. "the LOCATION_<CONFIG> property for an unspecified configuration "
  679. "<CONFIG> provided by the target.\n"
  680. "For a non-imported target, this property is provided for compatibility "
  681. "with CMake 2.4 and below. "
  682. "It was meant to get the location of an executable target's output file "
  683. "for use in add_custom_command. "
  684. "The path may contain a build-system-specific portion that "
  685. "is replaced at build time with the configuration getting built "
  686. "(such as \"$(ConfigurationName)\" in VS). "
  687. "In CMake 2.6 and above add_custom_command automatically recognizes a "
  688. "target name in its COMMAND and DEPENDS options and computes the "
  689. "target location. "
  690. "In CMake 2.8.4 and above add_custom_command recognizes generator "
  691. "expressions to refer to target locations anywhere in the command. "
  692. "Therefore this property is not needed for creating custom commands."
  693. CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property"));
  694. cm->DefineProperty
  695. ("LOCATION_<CONFIG>", cmProperty::TARGET,
  696. "Read-only property providing a target location on disk.",
  697. "A read-only property that indicates where a target's main file is "
  698. "located on disk for the configuration <CONFIG>. "
  699. "The property is defined only for library and executable targets. "
  700. "An imported target may provide a set of configurations different "
  701. "from that of the importing project. "
  702. "By default CMake looks for an exact-match but otherwise uses an "
  703. "arbitrary available configuration. "
  704. "Use the MAP_IMPORTED_CONFIG_<CONFIG> property to map imported "
  705. "configurations explicitly."
  706. CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property"));
  707. cm->DefineProperty
  708. ("LINK_DEPENDS", cmProperty::TARGET,
  709. "Additional files on which a target binary depends for linking.",
  710. "Specifies a semicolon-separated list of full-paths to files on which "
  711. "the link rule for this target depends. "
  712. "The target binary will be linked if any of the named files is newer "
  713. "than it."
  714. "\n"
  715. "This property is ignored by non-Makefile generators. "
  716. "It is intended to specify dependencies on \"linker scripts\" for "
  717. "custom Makefile link rules.");
  718. cm->DefineProperty
  719. ("LINK_DEPENDS_NO_SHARED", cmProperty::TARGET,
  720. "Do not depend on linked shared library files.",
  721. "Set this property to true to tell CMake generators not to add "
  722. "file-level dependencies on the shared library files linked by "
  723. "this target. "
  724. "Modification to the shared libraries will not be sufficient to "
  725. "re-link this target. "
  726. "Logical target-level dependencies will not be affected so the "
  727. "linked shared libraries will still be brought up to date before "
  728. "this target is built."
  729. "\n"
  730. "This property is initialized by the value of the variable "
  731. "CMAKE_LINK_DEPENDS_NO_SHARED if it is set when a target is "
  732. "created.");
  733. cm->DefineProperty
  734. ("LINK_INTERFACE_LIBRARIES", cmProperty::TARGET,
  735. "List public interface libraries for a shared library or executable.",
  736. "By default linking to a shared library target transitively "
  737. "links to targets with which the library itself was linked. "
  738. "For an executable with exports (see the ENABLE_EXPORTS property) "
  739. "no default transitive link dependencies are used. "
  740. "This property replaces the default transitive link dependencies with "
  741. "an explicit list. "
  742. "When the target is linked into another target the libraries "
  743. "listed (and recursively their link interface libraries) will be "
  744. "provided to the other target also. "
  745. "If the list is empty then no transitive link dependencies will be "
  746. "incorporated when this target is linked into another target even if "
  747. "the default set is non-empty. "
  748. "This property is initialized by the value of the variable "
  749. "CMAKE_LINK_INTERFACE_LIBRARIES if it is set when a target is "
  750. "created. "
  751. "This property is ignored for STATIC libraries.\n"
  752. "This property is overriden by the INTERFACE_LINK_LIBRARIES property if "
  753. "policy CMP0022 is NEW.\n"
  754. "This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead.");
  755. cm->DefineProperty
  756. ("LINK_INTERFACE_LIBRARIES_<CONFIG>", cmProperty::TARGET,
  757. "Per-configuration list of public interface libraries for a target.",
  758. "This is the configuration-specific version of "
  759. "LINK_INTERFACE_LIBRARIES. "
  760. "If set, this property completely overrides the generic property "
  761. "for the named configuration.\n"
  762. "This property is overriden by the INTERFACE_LINK_LIBRARIES property if "
  763. "policy CMP0022 is NEW.\n"
  764. "This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead.");
  765. cm->DefineProperty
  766. ("INTERFACE_LINK_LIBRARIES", cmProperty::TARGET,
  767. "List public interface libraries for a shared library or executable.",
  768. "This property contains the list of transitive link dependencies. "
  769. "When the target is linked into another target the libraries "
  770. "listed (and recursively their link interface libraries) will be "
  771. "provided to the other target also. "
  772. "This property is overriden by the LINK_INTERFACE_LIBRARIES or "
  773. "LINK_INTERFACE_LIBRARIES_<CONFIG> property if "
  774. "policy CMP0022 is OLD or unset.\n"
  775. "\n"
  776. CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS);
  777. cm->DefineProperty
  778. ("INTERFACE_INCLUDE_DIRECTORIES", cmProperty::TARGET,
  779. "List of public include directories for a library.",
  780. "Targets may populate this property to publish the include directories "
  781. "required to compile against the headers for the target. Consuming "
  782. "targets can add entries to their own INCLUDE_DIRECTORIES property such "
  783. "as $<TARGET_PROPERTY:foo,INTERFACE_INCLUDE_DIRECTORIES> to use the "
  784. "include directories specified in the interface of 'foo'."
  785. "\n"
  786. CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
  787. CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
  788. cm->DefineProperty
  789. ("INTERFACE_COMPILE_DEFINITIONS", cmProperty::TARGET,
  790. "List of public compile definitions for a library.",
  791. "Targets may populate this property to publish the compile definitions "
  792. "required to compile against the headers for the target. Consuming "
  793. "targets can add entries to their own COMPILE_DEFINITIONS property such "
  794. "as $<TARGET_PROPERTY:foo,INTERFACE_COMPILE_DEFINITIONS> to use the "
  795. "compile definitions specified in the interface of 'foo'."
  796. "\n"
  797. CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
  798. CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
  799. cm->DefineProperty
  800. ("LINK_INTERFACE_MULTIPLICITY", cmProperty::TARGET,
  801. "Repetition count for STATIC libraries with cyclic dependencies.",
  802. "When linking to a STATIC library target with cyclic dependencies the "
  803. "linker may need to scan more than once through the archives in the "
  804. "strongly connected component of the dependency graph. "
  805. "CMake by default constructs the link line so that the linker will "
  806. "scan through the component at least twice. "
  807. "This property specifies the minimum number of scans if it is larger "
  808. "than the default. "
  809. "CMake uses the largest value specified by any target in a component.");
  810. cm->DefineProperty
  811. ("LINK_INTERFACE_MULTIPLICITY_<CONFIG>", cmProperty::TARGET,
  812. "Per-configuration repetition count for cycles of STATIC libraries.",
  813. "This is the configuration-specific version of "
  814. "LINK_INTERFACE_MULTIPLICITY. "
  815. "If set, this property completely overrides the generic property "
  816. "for the named configuration.");
  817. cm->DefineProperty
  818. ("MAP_IMPORTED_CONFIG_<CONFIG>", cmProperty::TARGET,
  819. "Map from project configuration to IMPORTED target's configuration.",
  820. "Set this to the list of configurations of an imported target that "
  821. "may be used for the current project's <CONFIG> configuration. "
  822. "Targets imported from another project may not provide the same set "
  823. "of configuration names available in the current project. "
  824. "Setting this property tells CMake what imported configurations are "
  825. "suitable for use when building the <CONFIG> configuration. "
  826. "The first configuration in the list found to be provided by the "
  827. "imported target is selected. If this property is set and no matching "
  828. "configurations are available, then the imported target is considered "
  829. "to be not found. This property is ignored for non-imported targets.",
  830. false /* TODO: make this chained */ );
  831. cm->DefineProperty
  832. ("OSX_ARCHITECTURES", cmProperty::TARGET,
  833. "Target specific architectures for OS X.",
  834. "The OSX_ARCHITECTURES property sets the target binary architecture "
  835. "for targets on OS X. "
  836. "This property is initialized by the value of the variable "
  837. "CMAKE_OSX_ARCHITECTURES if it is set when a target is created. "
  838. "Use OSX_ARCHITECTURES_<CONFIG> to set the binary architectures on a "
  839. "per-configuration basis. "
  840. "<CONFIG> is an upper-case name (ex: \"OSX_ARCHITECTURES_DEBUG\").");
  841. cm->DefineProperty
  842. ("OSX_ARCHITECTURES_<CONFIG>", cmProperty::TARGET,
  843. "Per-configuration OS X binary architectures for a target.",
  844. "This property is the configuration-specific version of "
  845. "OSX_ARCHITECTURES.");
  846. cm->DefineProperty
  847. ("EXPORT_NAME", cmProperty::TARGET,
  848. "Exported name for target files.",
  849. "This sets the name for the IMPORTED target generated when it this "
  850. "target is is exported. "
  851. "If not set, the logical target name is used by default.");
  852. cm->DefineProperty
  853. ("OUTPUT_NAME", cmProperty::TARGET,
  854. "Output name for target files.",
  855. "This sets the base name for output files created for an executable or "
  856. "library target. "
  857. "If not set, the logical target name is used by default.");
  858. cm->DefineProperty
  859. ("OUTPUT_NAME_<CONFIG>", cmProperty::TARGET,
  860. "Per-configuration target file base name.",
  861. "This is the configuration-specific version of OUTPUT_NAME.");
  862. cm->DefineProperty
  863. ("<CONFIG>_OUTPUT_NAME", cmProperty::TARGET,
  864. "Old per-configuration target file base name.",
  865. "This is a configuration-specific version of OUTPUT_NAME. "
  866. "Use OUTPUT_NAME_<CONFIG> instead.");
  867. cm->DefineProperty
  868. ("PDB_NAME", cmProperty::TARGET,
  869. "Output name for MS debug symbols .pdb file from linker.",
  870. "Set the base name for debug symbols file created for an "
  871. "executable or shared library target. "
  872. "If not set, the logical target name is used by default. "
  873. "\n"
  874. "This property is not implemented by the Visual Studio 6 generator.");
  875. cm->DefineProperty
  876. ("PDB_NAME_<CONFIG>", cmProperty::TARGET,
  877. "Per-configuration name for MS debug symbols .pdb file. ",
  878. "This is the configuration-specific version of PDB_NAME. "
  879. "\n"
  880. "This property is not implemented by the Visual Studio 6 generator.");
  881. cm->DefineProperty
  882. ("PRE_INSTALL_SCRIPT", cmProperty::TARGET,
  883. "Deprecated install support.",
  884. "The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the "
  885. "old way to specify CMake scripts to run before and after "
  886. "installing a target. They are used only when the old "
  887. "INSTALL_TARGETS command is used to install the target. Use the "
  888. "INSTALL command instead.");
  889. cm->DefineProperty
  890. ("PREFIX", cmProperty::TARGET,
  891. "What comes before the library name.",
  892. "A target property that can be set to override the prefix "
  893. "(such as \"lib\") on a library name.");
  894. cm->DefineProperty
  895. ("C_VISIBILITY_PRESET", cmProperty::TARGET,
  896. "Value for symbol visibility compile flags",
  897. "The C_VISIBILITY_PRESET property determines the value passed used in "
  898. "a visibility related compile option, such as -fvisibility=. This "
  899. "property only has an affect for libraries and executables with "
  900. "exports. This property is initialized by the value of the variable "
  901. "CMAKE_C_VISIBILITY_PRESET if it is set when a target is created.");
  902. cm->DefineProperty
  903. ("CXX_VISIBILITY_PRESET", cmProperty::TARGET,
  904. "Value for symbol visibility compile flags",
  905. "The CXX_VISIBILITY_PRESET property determines the value passed used in "
  906. "a visibility related compile option, such as -fvisibility=. This "
  907. "property only has an affect for libraries and executables with "
  908. "exports. This property is initialized by the value of the variable "
  909. "CMAKE_CXX_VISIBILITY_PRESET if it is set when a target is created.");
  910. cm->DefineProperty
  911. ("VISIBILITY_INLINES_HIDDEN", cmProperty::TARGET,
  912. "Whether to add a compile flag to hide symbols of inline functions",
  913. "The VISIBILITY_INLINES_HIDDEN property determines whether a flag for "
  914. "hiding symbols for inline functions. the value passed used in "
  915. "a visibility related compile option, such as -fvisibility=. This "
  916. "property only has an affect for libraries and executables with "
  917. "exports. This property is initialized by the value of the variable "
  918. "CMAKE_VISIBILITY_INLINES_HIDDEN if it is set when a target is "
  919. "created.");
  920. cm->DefineProperty
  921. ("POSITION_INDEPENDENT_CODE", cmProperty::TARGET,
  922. "Whether to create a position-independent target",
  923. "The POSITION_INDEPENDENT_CODE property determines whether position "
  924. "independent executables or shared libraries will be created. "
  925. "This property is true by default for SHARED and MODULE library "
  926. "targets and false otherwise. "
  927. "This property is initialized by the value of the variable "
  928. "CMAKE_POSITION_INDEPENDENT_CODE if it is set when a target is "
  929. "created.");
  930. cm->DefineProperty
  931. ("INTERFACE_POSITION_INDEPENDENT_CODE", cmProperty::TARGET,
  932. "Whether consumers need to create a position-independent target",
  933. "The INTERFACE_POSITION_INDEPENDENT_CODE property informs consumers of "
  934. "this target whether they must set their POSITION_INDEPENDENT_CODE "
  935. "property to ON. If this property is set to ON, then the "
  936. "POSITION_INDEPENDENT_CODE property on all consumers will be set to "
  937. "ON. Similarly, if this property is set to OFF, then the "
  938. "POSITION_INDEPENDENT_CODE property on all consumers will be set to "
  939. "OFF. If this property is undefined, then consumers will determine "
  940. "their POSITION_INDEPENDENT_CODE property by other means. Consumers "
  941. "must ensure that the targets that they link to have a consistent "
  942. "requirement for their INTERFACE_POSITION_INDEPENDENT_CODE property.");
  943. cm->DefineProperty
  944. ("COMPATIBLE_INTERFACE_BOOL", cmProperty::TARGET,
  945. "Properties which must be compatible with their link interface",
  946. "The COMPATIBLE_INTERFACE_BOOL property may contain a list of properties"
  947. "for this target which must be consistent when evaluated as a boolean "
  948. "in the INTERFACE of all linked dependees. For example, if a "
  949. "property \"FOO\" appears in the list, then for each dependee, the "
  950. "\"INTERFACE_FOO\" property content in all of its dependencies must be "
  951. "consistent with each other, and with the \"FOO\" property in the "
  952. "dependee. Consistency in this sense has the meaning that if the "
  953. "property is set, then it must have the same boolean value as all "
  954. "others, and if the property is not set, then it is ignored. Note that "
  955. "for each dependee, the set of properties from this property must not "
  956. "intersect with the set of properties from the "
  957. "COMPATIBLE_INTERFACE_STRING property.");
  958. cm->DefineProperty
  959. ("COMPATIBLE_INTERFACE_STRING", cmProperty::TARGET,
  960. "Properties which must be string-compatible with their link interface",
  961. "The COMPATIBLE_INTERFACE_STRING property may contain a list of "
  962. "properties for this target which must be the same when evaluated as "
  963. "a string in the INTERFACE of all linked dependees. For example, "
  964. "if a property \"FOO\" appears in the list, then for each dependee, the "
  965. "\"INTERFACE_FOO\" property content in all of its dependencies must be "
  966. "equal with each other, and with the \"FOO\" property in the dependee. "
  967. "If the property is not set, then it is ignored. Note that for each "
  968. "dependee, the set of properties from this property must not intersect "
  969. "with the set of properties from the COMPATIBLE_INTERFACE_BOOL "
  970. "property.");
  971. cm->DefineProperty
  972. ("POST_INSTALL_SCRIPT", cmProperty::TARGET,
  973. "Deprecated install support.",
  974. "The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the "
  975. "old way to specify CMake scripts to run before and after "
  976. "installing a target. They are used only when the old "
  977. "INSTALL_TARGETS command is used to install the target. Use the "
  978. "INSTALL command instead.");
  979. cm->DefineProperty
  980. ("PRIVATE_HEADER", cmProperty::TARGET,
  981. "Specify private header files in a FRAMEWORK shared library target.",
  982. "Shared library targets marked with the FRAMEWORK property generate "
  983. "frameworks on OS X and normal shared libraries on other platforms. "
  984. "This property may be set to a list of header files to be placed "
  985. "in the PrivateHeaders directory inside the framework folder. "
  986. "On non-Apple platforms these headers may be installed using the "
  987. "PRIVATE_HEADER option to the install(TARGETS) command.");
  988. cm->DefineProperty
  989. ("PUBLIC_HEADER", cmProperty::TARGET,
  990. "Specify public header files in a FRAMEWORK shared library target.",
  991. "Shared library targets marked with the FRAMEWORK property generate "
  992. "frameworks on OS X and normal shared libraries on other platforms. "
  993. "This property may be set to a list of header files to be placed "
  994. "in the Headers directory inside the framework folder. "
  995. "On non-Apple platforms these headers may be installed using the "
  996. "PUBLIC_HEADER option to the install(TARGETS) command.");
  997. cm->DefineProperty
  998. ("RESOURCE", cmProperty::TARGET,
  999. "Specify resource files in a FRAMEWORK shared library target.",
  1000. "Shared library targets marked with the FRAMEWORK property generate "
  1001. "frameworks on OS X and normal shared libraries on other platforms. "
  1002. "This property may be set to a list of files to be placed "
  1003. "in the Resources directory inside the framework folder. "
  1004. "On non-Apple platforms these files may be installed using the "
  1005. "RESOURCE option to the install(TARGETS) command.");
  1006. cm->DefineProperty
  1007. ("RULE_LAUNCH_COMPILE", cmProperty::TARGET,
  1008. "Specify a launcher for compile rules.",
  1009. "See the global property of the same name for details. "
  1010. "This overrides the global and directory property for a target.",
  1011. true);
  1012. cm->DefineProperty
  1013. ("RULE_LAUNCH_LINK", cmProperty::TARGET,
  1014. "Specify a launcher for link rules.",
  1015. "See the global property of the same name for details. "
  1016. "This overrides the global and directory property for a target.",
  1017. true);
  1018. cm->DefineProperty
  1019. ("RULE_LAUNCH_CUSTOM", cmProperty::TARGET,
  1020. "Specify a launcher for custom rules.",
  1021. "See the global property of the same name for details. "
  1022. "This overrides the global and directory property for a target.",
  1023. true);
  1024. cm->DefineProperty
  1025. ("SKIP_BUILD_RPATH", cmProperty::TARGET,
  1026. "Should rpaths be used for the build tree.",
  1027. "SKIP_BUILD_RPATH is a boolean specifying whether to skip automatic "
  1028. "generation of an rpath allowing the target to run from the "
  1029. "build tree. "
  1030. "This property is initialized by the value of the variable "
  1031. "CMAKE_SKIP_BUILD_RPATH if it is set when a target is created.");
  1032. cm->DefineProperty
  1033. ("NO_SONAME", cmProperty::TARGET,
  1034. "Whether to set \"soname\" when linking a shared library or module.",
  1035. "Enable this boolean property if a generated shared library or module "
  1036. "should not have \"soname\" set. Default is to set \"soname\" on all "
  1037. "shared libraries and modules as long as the platform supports it. "
  1038. "Generally, use this property only for leaf private libraries or "
  1039. "plugins. If you use it on normal shared libraries which other targets "
  1040. "link against, on some platforms a linker will insert a full path to "
  1041. "the library (as specified at link time) into the dynamic section of "
  1042. "the dependent binary. Therefore, once installed, dynamic loader may "
  1043. "eventually fail to locate the library for the binary.");
  1044. cm->DefineProperty
  1045. ("SOVERSION", cmProperty::TARGET,
  1046. "What version number is this target.",
  1047. "For shared libraries VERSION and SOVERSION can be used to specify "
  1048. "the build version and API version respectively. When building or "
  1049. "installing appropriate symlinks are created if the platform "
  1050. "supports symlinks and the linker supports so-names. "
  1051. "If only one of both is specified the missing is assumed to have "
  1052. "the same version number. "
  1053. "SOVERSION is ignored if NO_SONAME property is set. "
  1054. "For shared libraries and executables on Windows the VERSION "
  1055. "attribute is parsed to extract a \"major.minor\" version number. "
  1056. "These numbers are used as the image version of the binary. ");
  1057. cm->DefineProperty
  1058. ("STATIC_LIBRARY_FLAGS", cmProperty::TARGET,
  1059. "Extra flags to use when linking static libraries.",
  1060. "Extra flags to use when linking a static library.");
  1061. cm->DefineProperty
  1062. ("STATIC_LIBRARY_FLAGS_<CONFIG>", cmProperty::TARGET,
  1063. "Per-configuration flags for creating a static library.",
  1064. "This is the configuration-specific version of STATIC_LIBRARY_FLAGS.");
  1065. cm->DefineProperty
  1066. ("SUFFIX", cmProperty::TARGET,
  1067. "What comes after the target name.",
  1068. "A target property that can be set to override the suffix "
  1069. "(such as \".so\" or \".exe\") on the name of a library, module or "
  1070. "executable.");
  1071. cm->DefineProperty
  1072. ("TYPE", cmProperty::TARGET,
  1073. "The type of the target.",
  1074. "This read-only property can be used to test the type of the given "
  1075. "target. It will be one of STATIC_LIBRARY, MODULE_LIBRARY, "
  1076. "SHARED_LIBRARY, EXECUTABLE or one of the internal target types.");
  1077. cm->DefineProperty
  1078. ("VERSION", cmProperty::TARGET,
  1079. "What version number is this target.",
  1080. "For shared libraries VERSION and SOVERSION can be used to specify "
  1081. "the build version and API version respectively. When building or "
  1082. "installing appropriate symlinks are created if the platform "
  1083. "supports symlinks and the linker supports so-names. "
  1084. "If only one of both is specified the missing is assumed to have "
  1085. "the same version number. "
  1086. "For executables VERSION can be used to specify the build version. "
  1087. "When building or installing appropriate symlinks are created if "
  1088. "the platform supports symlinks. "
  1089. "For shared libraries and executables on Windows the VERSION "
  1090. "attribute is parsed to extract a \"major.minor\" version number. "
  1091. "These numbers are used as the image version of the binary. ");
  1092. cm->DefineProperty
  1093. ("WIN32_EXECUTABLE", cmProperty::TARGET,
  1094. "Build an executable with a WinMain entry point on windows.",
  1095. "When this property is set to true the executable when linked "
  1096. "on Windows will be created with a WinMain() entry point instead "
  1097. "of just main(). "
  1098. "This makes it a GUI executable instead of a console application. "
  1099. "See the CMAKE_MFC_FLAG variable documentation to configure use "
  1100. "of MFC for WinMain executables. "
  1101. "This property is initialized by the value of the variable "
  1102. "CMAKE_WIN32_EXECUTABLE if it is set when a target is created.");
  1103. cm->DefineProperty
  1104. ("MACOSX_BUNDLE", cmProperty::TARGET,
  1105. "Build an executable as an application bundle on Mac OS X.",
  1106. "When this property is set to true the executable when built "
  1107. "on Mac OS X will be created as an application bundle. "
  1108. "This makes it a GUI executable that can be launched from "
  1109. "the Finder. "
  1110. "See the MACOSX_BUNDLE_INFO_PLIST target property for information "
  1111. "about creation of the Info.plist file for the application bundle. "
  1112. "This property is initialized by the value of the variable "
  1113. "CMAKE_MACOSX_BUNDLE if it is set when a target is created.");
  1114. cm->DefineProperty
  1115. ("MACOSX_BUNDLE_INFO_PLIST", cmProperty::TARGET,
  1116. "Specify a custom Info.plist template for a Mac OS X App Bundle.",
  1117. "An executable target with MACOSX_BUNDLE enabled will be built as an "
  1118. "application bundle on Mac OS X. "
  1119. "By default its Info.plist file is created by configuring a template "
  1120. "called MacOSXBundleInfo.plist.in located in the CMAKE_MODULE_PATH. "
  1121. "This property specifies an alternative template file name which "
  1122. "may be a full path.\n"
  1123. "The following target properties may be set to specify content to "
  1124. "be configured into the file:\n"
  1125. " MACOSX_BUNDLE_INFO_STRING\n"
  1126. " MACOSX_BUNDLE_ICON_FILE\n"
  1127. " MACOSX_BUNDLE_GUI_IDENTIFIER\n"
  1128. " MACOSX_BUNDLE_LONG_VERSION_STRING\n"
  1129. " MACOSX_BUNDLE_BUNDLE_NAME\n"
  1130. " MACOSX_BUNDLE_SHORT_VERSION_STRING\n"
  1131. " MACOSX_BUNDLE_BUNDLE_VERSION\n"
  1132. " MACOSX_BUNDLE_COPYRIGHT\n"
  1133. "CMake variables of the same name may be set to affect all targets "
  1134. "in a directory that do not have each specific property set. "
  1135. "If a custom Info.plist is specified by this property it may of course "
  1136. "hard-code all the settings instead of using the target properties.");
  1137. cm->DefineProperty
  1138. ("MACOSX_FRAMEWORK_INFO_PLIST", cmProperty::TARGET,
  1139. "Specify a custom Info.plist template for a Mac OS X Framework.",
  1140. "A library target with FRAMEWORK enabled will be built as a "
  1141. "framework on Mac OS X. "
  1142. "By default its Info.plist file is created by configuring a template "
  1143. "called MacOSXFrameworkInfo.plist.in located in the CMAKE_MODULE_PATH. "
  1144. "This property specifies an alternative template file name which "
  1145. "may be a full path.\n"
  1146. "The following target properties may be set to specify content to "
  1147. "be configured into the file:\n"
  1148. " MACOSX_FRAMEWORK_ICON_FILE\n"
  1149. " MACOSX_FRAMEWORK_IDENTIFIER\n"
  1150. " MACOSX_FRAMEWORK_SHORT_VERSION_STRING\n"
  1151. " MACOSX_FRAMEWORK_BUNDLE_VERSION\n"
  1152. "CMake variables of the same name may be set to affect all targets "
  1153. "in a directory that do not have each specific property set. "
  1154. "If a custom Info.plist is specified by this property it may of course "
  1155. "hard-code all the settings instead of using the target properties.");
  1156. cm->DefineProperty
  1157. ("MACOSX_RPATH", cmProperty::TARGET,
  1158. "Whether to use rpaths on Mac OS X.",
  1159. "When this property is set to true, the directory portion of the"
  1160. "\"install_name\" field of shared libraries will default to \"@rpath\"."
  1161. "Runtime paths will also be embedded in binaries using this target."
  1162. "This property is initialized by the value of the variable "
  1163. "CMAKE_MACOSX_RPATH if it is set when a target is created.");
  1164. cm->DefineProperty
  1165. ("ENABLE_EXPORTS", cmProperty::TARGET,
  1166. "Specify whether an executable exports symbols for loadable modules.",
  1167. "Normally an executable does not export any symbols because it is "
  1168. "the final program. It is possible for an executable to export "
  1169. "symbols to be used by loadable modules. When this property is "
  1170. "set to true CMake will allow other targets to \"link\" to the "
  1171. "executable with the TARGET_LINK_LIBRARIES command. "
  1172. "On all platforms a target-level dependency on the executable is "
  1173. "created for targets that link to it. "
  1174. "For DLL platforms an import library will be created for the "
  1175. "exported symbols and then used for linking. "
  1176. "All Windows-based systems including Cygwin are DLL platforms. "
  1177. "For non-DLL platforms that require all symbols to be resolved at "
  1178. "link time, such as Mac OS X, the module will \"link\" to the "
  1179. "executable using a flag like \"-bundle_loader\". "
  1180. "For other non-DLL platforms the link rule is simply ignored since "
  1181. "the dynamic loader will automatically bind symbols when the "
  1182. "module is loaded. "
  1183. );
  1184. cm->DefineProperty
  1185. ("Fortran_FORMAT", cmProperty::TARGET,
  1186. "Set to FIXED or FREE to indicate the Fortran source layout.",
  1187. "This property tells CMake whether the Fortran source files "
  1188. "in a target use fixed-format or free-format. "
  1189. "CMake will pass the corresponding format flag to the compiler. "
  1190. "Use the source-specific Fortran_FORMAT property to change the "
  1191. "format of a specific source file. "
  1192. "If the variable CMAKE_Fortran_FORMAT is set when a target "
  1193. "is created its value is used to initialize this property.");
  1194. cm->DefineProperty
  1195. ("Fortran_MODULE_DIRECTORY", cmProperty::TARGET,
  1196. "Specify output directory for Fortran modules provided by the target.",
  1197. "If the target contains Fortran source files that provide modules "
  1198. "and the compiler supports a module output directory this specifies "
  1199. "the directory in which the modules will be placed. "
  1200. "When this property is not set the modules will be placed in the "
  1201. "build directory corresponding to the target's source directory. "
  1202. "If the variable CMAKE_Fortran_MODULE_DIRECTORY is set when a target "
  1203. "is created its value is used to initialize this property."
  1204. "\n"
  1205. "Note that some compilers will automatically search the module output "
  1206. "directory for modules USEd during compilation but others will not. "
  1207. "If your sources USE modules their location must be specified by "
  1208. "INCLUDE_DIRECTORIES regardless of this property.");
  1209. cm->DefineProperty
  1210. ("GNUtoMS", cmProperty::TARGET,
  1211. "Convert GNU import library (.dll.a) to MS format (.lib).",
  1212. "When linking a shared library or executable that exports symbols "
  1213. "using GNU tools on Windows (MinGW/MSYS) with Visual Studio installed "
  1214. "convert the import library (.dll.a) from GNU to MS format (.lib). "
  1215. "Both import libraries will be installed by install(TARGETS) and "
  1216. "exported by install(EXPORT) and export() to be linked by applications "
  1217. "with either GNU- or MS-compatible tools."
  1218. "\n"
  1219. "If the variable CMAKE_GNUtoMS is set when a target "
  1220. "is created its value is used to initialize this property. "
  1221. "The variable must be set prior to the first command that enables "
  1222. "a language such as project() or enable_language(). "
  1223. "CMake provides the variable as an option to the user automatically "
  1224. "when configuring on Windows with GNU tools.");
  1225. cm->DefineProperty
  1226. ("XCODE_ATTRIBUTE_<an-attribute>", cmProperty::TARGET,
  1227. "Set Xcode target attributes directly.",
  1228. "Tell the Xcode generator to set '<an-attribute>' to a given value "
  1229. "in the generated Xcode project. Ignored on other generators.");
  1230. cm->DefineProperty
  1231. ("GENERATOR_FILE_NAME", cmProperty::TARGET,
  1232. "Generator's file for this target.",
  1233. "An internal property used by some generators to record the name of the "
  1234. "project or dsp file associated with this target. Note that at configure "
  1235. "time, this property is only set for targets created by "
  1236. "include_external_msproject().");
  1237. cm->DefineProperty
  1238. ("SOURCES", cmProperty::TARGET,
  1239. "Source names specified for a target.",
  1240. "Read-only list of sources specified for a target. "
  1241. "The names returned are suitable for passing to the "
  1242. "set_source_files_properties command.");
  1243. cm->DefineProperty
  1244. ("FOLDER", cmProperty::TARGET,
  1245. "Set the folder name. Use to organize targets in an IDE.",
  1246. "Targets with no FOLDER property will appear as top level "
  1247. "entities in IDEs like Visual Studio. Targets with the same "
  1248. "FOLDER property value will appear next to each other in a "
  1249. "folder of that name. To nest folders, use FOLDER values such "
  1250. "as 'GUI/Dialogs' with '/' characters separating folder levels.");
  1251. cm->DefineProperty
  1252. ("PROJECT_LABEL", cmProperty::TARGET,
  1253. "Change the name of a target in an IDE.",
  1254. "Can be used to change the name of the target in an IDE "
  1255. "like Visual Studio. ");
  1256. cm->DefineProperty
  1257. ("VS_KEYWORD", cmProperty::TARGET,
  1258. "Visual Studio project keyword.",
  1259. "Can be set to change the visual studio keyword, for example "
  1260. "Qt integration works better if this is set to Qt4VSv1.0. ");
  1261. cm->DefineProperty
  1262. ("VS_SCC_PROVIDER", cmProperty::TARGET,
  1263. "Visual Studio Source Code Control Provider.",
  1264. "Can be set to change the visual studio source code control "
  1265. "provider property.");
  1266. cm->DefineProperty
  1267. ("VS_SCC_LOCALPATH", cmProperty::TARGET,
  1268. "Visual Studio Source Code Control Local Path.",
  1269. "Can be set to change the visual studio source code control "
  1270. "local path property.");
  1271. cm->DefineProperty
  1272. ("VS_SCC_PROJECTNAME", cmProperty::TARGET,
  1273. "Visual Studio Source Code Control Project.",
  1274. "Can be set to change the visual studio source code control "
  1275. "project name property.");
  1276. cm->DefineProperty
  1277. ("VS_SCC_AUXPATH", cmProperty::TARGET,
  1278. "Visual Studio Source Code Control Aux Path.",
  1279. "Can be set to change the visual studio source code control "
  1280. "auxpath property.");
  1281. cm->DefineProperty
  1282. ("VS_GLOBAL_PROJECT_TYPES", cmProperty::TARGET,
  1283. "Visual Studio project type(s).",
  1284. "Can be set to one or more UUIDs recognized by Visual Studio "
  1285. "to indicate the type of project. This value is copied "
  1286. "verbatim into the generated project file. Example for a "
  1287. "managed C++ unit testing project:\n"
  1288. " {3AC096D0-A1C2-E12C-1390-A8335801FDAB};"
  1289. "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\n"
  1290. "UUIDs are semicolon-delimited.");
  1291. cm->DefineProperty
  1292. ("VS_GLOBAL_KEYWORD", cmProperty::TARGET,
  1293. "Visual Studio project keyword.",
  1294. "Sets the \"keyword\" attribute for a generated Visual Studio "
  1295. "project. Defaults to \"Win32Proj\". You may wish to override "
  1296. "this value with \"ManagedCProj\", for example, in a Visual "
  1297. "Studio managed C++ unit test project.");
  1298. cm->DefineProperty
  1299. ("VS_GLOBAL_ROOTNAMESPACE", cmProperty::TARGET,
  1300. "Visual Studio project root namespace.",
  1301. "Sets the \"RootNamespace\" attribute for a generated Visual Studio "
  1302. "project. The attribute will be generated only if this is set.");
  1303. cm->DefineProperty
  1304. ("VS_DOTNET_TARGET_FRAMEWORK_VERSION", cmProperty::TARGET,
  1305. "Specify the .NET target framework version.",
  1306. "Used to specify the .NET target framework version for C++/CLI. "
  1307. "For example, \"v4.5\".");
  1308. cm->DefineProperty
  1309. ("VS_DOTNET_REFERENCES", cmProperty::TARGET,
  1310. "Visual Studio managed project .NET references",
  1311. "Adds one or more semicolon-delimited .NET references to a "
  1312. "generated Visual Studio project. For example, \"System;"
  1313. "System.Windows.Forms\".");
  1314. cm->DefineProperty
  1315. ("VS_WINRT_EXTENSIONS", cmProperty::TARGET,
  1316. "Visual Studio project C++/CX language extensions for Windows Runtime",
  1317. "Can be set to enable C++/CX language extensions.");
  1318. cm->DefineProperty
  1319. ("VS_WINRT_REFERENCES", cmProperty::TARGET,
  1320. "Visual Studio project Windows Runtime Metadata references",
  1321. "Adds one or more semicolon-delimited WinRT references to a "
  1322. "generated Visual Studio project. For example, \"Windows;"
  1323. "Windows.UI.Core\".");
  1324. cm->DefineProperty
  1325. ("VS_GLOBAL_<variable>", cmProperty::TARGET,
  1326. "Visual Studio project-specific global variable.",
  1327. "Tell the Visual Studio generator to set the global variable "
  1328. "'<variable>' to a given value in the generated Visual Studio "
  1329. "project. Ignored on other generators. Qt integration works "
  1330. "better if VS_GLOBAL_QtVersion is set to the version "
  1331. "FindQt4.cmake found. For example, \"4.7.3\"");
  1332. #define CM_TARGET_FILE_TYPES_DOC \
  1333. "There are three kinds of target files that may be built: " \
  1334. "archive, library, and runtime. " \
  1335. "Executables are always treated as runtime targets. " \
  1336. "Static libraries are always treated as archive targets. " \
  1337. "Module libraries are always treated as library targets. " \
  1338. "For non-DLL platforms shared libraries are treated as library " \
  1339. "targets. " \
  1340. "For DLL platforms the DLL part of a shared library is treated as " \
  1341. "a runtime target and the corresponding import library is treated as " \
  1342. "an archive target. " \
  1343. "All Windows-based systems including Cygwin are DLL platforms."
  1344. #define CM_TARGET_OUTDIR_DOC(TYPE, type) \
  1345. "This property specifies the directory into which " #type " target " \
  1346. "files should be built. " \
  1347. "Multi-configuration generators (VS, Xcode) append " \
  1348. "a per-configuration subdirectory to the specified directory. " \
  1349. CM_TARGET_FILE_TYPES_DOC " " \
  1350. "This property is initialized by the value of the variable " \
  1351. "CMAKE_" #TYPE "_OUTPUT_DIRECTORY if it is set when a target is created."
  1352. #define CM_TARGET_OUTDIR_CONFIG_DOC(TYPE) \
  1353. "This is a per-configuration version of " #TYPE "_OUTPUT_DIRECTORY, " \
  1354. "but multi-configuration generators (VS, Xcode) do NOT append " \
  1355. "a per-configuration subdirectory to the specified directory. " \
  1356. "This property is initialized by the value of the variable " \
  1357. "CMAKE_" #TYPE "_OUTPUT_DIRECTORY_<CONFIG> " \
  1358. "if it is set when a target is created."
  1359. cm->DefineProperty
  1360. ("ARCHIVE_OUTPUT_DIRECTORY", cmProperty::TARGET,
  1361. "Output directory in which to build ARCHIVE target files.",
  1362. CM_TARGET_OUTDIR_DOC(ARCHIVE, archive));
  1363. cm->DefineProperty
  1364. ("ARCHIVE_OUTPUT_DIRECTORY_<CONFIG>", cmProperty::TARGET,
  1365. "Per-configuration output directory for ARCHIVE target files.",
  1366. CM_TARGET_OUTDIR_CONFIG_DOC(ARCHIVE));
  1367. cm->DefineProperty
  1368. ("LIBRARY_OUTPUT_DIRECTORY", cmProperty::TARGET,
  1369. "Output directory in which to build LIBRARY target files.",
  1370. CM_TARGET_OUTDIR_DOC(LIBRARY, library));
  1371. cm->DefineProperty
  1372. ("LIBRARY_OUTPUT_DIRECTORY_<CONFIG>", cmProperty::TARGET,
  1373. "Per-configuration output directory for LIBRARY target files.",
  1374. CM_TARGET_OUTDIR_CONFIG_DOC(LIBRARY));
  1375. cm->DefineProperty
  1376. ("RUNTIME_OUTPUT_DIRECTORY", cmProperty::TARGET,
  1377. "Output directory in which to build RUNTIME target files.",
  1378. CM_TARGET_OUTDIR_DOC(RUNTIME, runtime));
  1379. cm->DefineProperty
  1380. ("RUNTIME_OUTPUT_DIRECTORY_<CONFIG>", cmProperty::TARGET,
  1381. "Per-configuration output directory for RUNTIME target files.",
  1382. CM_TARGET_OUTDIR_CONFIG_DOC(RUNTIME));
  1383. cm->DefineProperty
  1384. ("PDB_OUTPUT_DIRECTORY", cmProperty::TARGET,
  1385. "Output directory for MS debug symbols .pdb file from linker.",
  1386. "This property specifies the directory into which the MS debug symbols "
  1387. "will be placed by the linker. "
  1388. "This property is initialized by the value of the variable "
  1389. "CMAKE_PDB_OUTPUT_DIRECTORY if it is set when a target is created."
  1390. "\n"
  1391. "This property is not implemented by the Visual Studio 6 generator.");
  1392. cm->DefineProperty
  1393. ("PDB_OUTPUT_DIRECTORY_<CONFIG>", cmProperty::TARGET,
  1394. "Per-configuration output directory for MS debug symbols .pdb files.",
  1395. "This is a per-configuration version of PDB_OUTPUT_DIRECTORY, "
  1396. "but multi-configuration generators (VS, Xcode) do NOT append "
  1397. "a per-configuration subdirectory to the specified directory. "
  1398. "This property is initialized by the value of the variable "
  1399. "CMAKE_PDB_OUTPUT_DIRECTORY_<CONFIG> "
  1400. "if it is set when a target is created."
  1401. "\n"
  1402. "This property is not implemented by the Visual Studio 6 generator.");
  1403. cm->DefineProperty
  1404. ("ARCHIVE_OUTPUT_NAME", cmProperty::TARGET,
  1405. "Output name for ARCHIVE target files.",
  1406. "This property specifies the base name for archive target files. "
  1407. "It overrides OUTPUT_NAME and OUTPUT_NAME_<CONFIG> properties. "
  1408. CM_TARGET_FILE_TYPES_DOC);
  1409. cm->DefineProperty
  1410. ("ARCHIVE_OUTPUT_NAME_<CONFIG>", cmProperty::TARGET,
  1411. "Per-configuration output name for ARCHIVE target files.",
  1412. "This is the configuration-specific version of ARCHIVE_OUTPUT_NAME.");
  1413. cm->DefineProperty
  1414. ("LIBRARY_OUTPUT_NAME", cmProperty::TARGET,
  1415. "Output name for LIBRARY target files.",
  1416. "This property specifies the base name for library target files. "
  1417. "It overrides OUTPUT_NAME and OUTPUT_NAME_<CONFIG> properties. "
  1418. CM_TARGET_FILE_TYPES_DOC);
  1419. cm->DefineProperty
  1420. ("LIBRARY_OUTPUT_NAME_<CONFIG>", cmProperty::TARGET,
  1421. "Per-configuration output name for LIBRARY target files.",
  1422. "This is the configuration-specific version of LIBRARY_OUTPUT_NAME.");
  1423. cm->DefineProperty
  1424. ("RUNTIME_OUTPUT_NAME", cmProperty::TARGET,
  1425. "Output name for RUNTIME target files.",
  1426. "This property specifies the base name for runtime target files. "
  1427. "It overrides OUTPUT_NAME and OUTPUT_NAME_<CONFIG> properties. "
  1428. CM_TARGET_FILE_TYPES_DOC);
  1429. cm->DefineProperty
  1430. ("RUNTIME_OUTPUT_NAME_<CONFIG>", cmProperty::TARGET,
  1431. "Per-configuration output name for RUNTIME target files.",
  1432. "This is the configuration-specific version of RUNTIME_OUTPUT_NAME.");
  1433. }
  1434. void cmTarget::SetType(TargetType type, const char* name)
  1435. {
  1436. this->Name = name;
  1437. // only add dependency information for library targets
  1438. this->TargetTypeValue = type;
  1439. if(this->TargetTypeValue >= STATIC_LIBRARY
  1440. && this->TargetTypeValue <= MODULE_LIBRARY)
  1441. {
  1442. this->RecordDependencies = true;
  1443. }
  1444. else
  1445. {
  1446. this->RecordDependencies = false;
  1447. }
  1448. }
  1449. //----------------------------------------------------------------------------
  1450. void cmTarget::SetMakefile(cmMakefile* mf)
  1451. {
  1452. // Set our makefile.
  1453. this->Makefile = mf;
  1454. // set the cmake instance of the properties
  1455. this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
  1456. // Check whether this is a DLL platform.
  1457. this->DLLPlatform = (this->Makefile->IsOn("WIN32") ||
  1458. this->Makefile->IsOn("CYGWIN") ||
  1459. this->Makefile->IsOn("MINGW"));
  1460. // Check whether we are targeting an Apple platform.
  1461. this->IsApple = this->Makefile->IsOn("APPLE");
  1462. // Setup default property values.
  1463. this->SetPropertyDefault("INSTALL_NAME_DIR", "");
  1464. this->SetPropertyDefault("INSTALL_RPATH", "");
  1465. this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF");
  1466. this->SetPropertyDefault("SKIP_BUILD_RPATH", "OFF");
  1467. this->SetPropertyDefault("BUILD_WITH_INSTALL_RPATH", "OFF");
  1468. this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", 0);
  1469. this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0);
  1470. this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0);
  1471. this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", 0);
  1472. this->SetPropertyDefault("Fortran_FORMAT", 0);
  1473. this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0);
  1474. this->SetPropertyDefault("GNUtoMS", 0);
  1475. this->SetPropertyDefault("OSX_ARCHITECTURES", 0);
  1476. this->SetPropertyDefault("AUTOMOC", 0);
  1477. this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0);
  1478. this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", 0);
  1479. this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0);
  1480. this->SetPropertyDefault("WIN32_EXECUTABLE", 0);
  1481. this->SetPropertyDefault("MACOSX_BUNDLE", 0);
  1482. this->SetPropertyDefault("MACOSX_RPATH", 0);
  1483. // Collect the set of configuration types.
  1484. std::vector<std::string> configNames;
  1485. mf->GetConfigurations(configNames);
  1486. // Setup per-configuration property default values.
  1487. const char* configProps[] = {
  1488. "ARCHIVE_OUTPUT_DIRECTORY_",
  1489. "LIBRARY_OUTPUT_DIRECTORY_",
  1490. "RUNTIME_OUTPUT_DIRECTORY_",
  1491. "PDB_OUTPUT_DIRECTORY_",
  1492. 0};
  1493. for(std::vector<std::string>::iterator ci = configNames.begin();
  1494. ci != configNames.end(); ++ci)
  1495. {
  1496. std::string configUpper = cmSystemTools::UpperCase(*ci);
  1497. for(const char** p = configProps; *p; ++p)
  1498. {
  1499. std::string property = *p;
  1500. property += configUpper;
  1501. this->SetPropertyDefault(property.c_str(), 0);
  1502. }
  1503. // Initialize per-configuration name postfix property from the
  1504. // variable only for non-executable targets. This preserves
  1505. // compatibility with previous CMake versions in which executables
  1506. // did not support this variable. Projects may still specify the
  1507. // property directly. TODO: Make this depend on backwards
  1508. // compatibility setting.
  1509. if(this->TargetTypeValue != cmTarget::EXECUTABLE)
  1510. {
  1511. std::string property = cmSystemTools::UpperCase(*ci);
  1512. property += "_POSTFIX";
  1513. this->SetPropertyDefault(property.c_str(), 0);
  1514. }
  1515. }
  1516. // Save the backtrace of target construction.
  1517. this->Makefile->GetBacktrace(this->Internal->Backtrace);
  1518. // Initialize the INCLUDE_DIRECTORIES property based on the current value
  1519. // of the same directory property:
  1520. const std::vector<cmValueWithOrigin> parentIncludes =
  1521. this->Makefile->GetIncludeDirectoriesEntries();
  1522. for (std::vector<cmValueWithOrigin>::const_iterator it
  1523. = parentIncludes.begin(); it != parentIncludes.end(); ++it)
  1524. {
  1525. this->InsertInclude(*it);
  1526. }
  1527. const std::vector<cmValueWithOrigin> parentOptions =
  1528. this->Makefile->GetCompileOptionsEntries();
  1529. for (std::vector<cmValueWithOrigin>::const_iterator it
  1530. = parentOptions.begin(); it != parentOptions.end(); ++it)
  1531. {
  1532. this->InsertCompileOption(*it);
  1533. }
  1534. this->SetPropertyDefault("C_VISIBILITY_PRESET", 0);
  1535. this->SetPropertyDefault("CXX_VISIBILITY_PRESET", 0);
  1536. this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", 0);
  1537. if(this->TargetTypeValue == cmTarget::SHARED_LIBRARY
  1538. || this->TargetTypeValue == cmTarget::MODULE_LIBRARY)
  1539. {
  1540. this->SetProperty("POSITION_INDEPENDENT_CODE", "True");
  1541. }
  1542. this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", 0);
  1543. // Record current policies for later use.
  1544. this->PolicyStatusCMP0003 =
  1545. this->Makefile->GetPolicyStatus(cmPolicies::CMP0003);
  1546. this->PolicyStatusCMP0004 =
  1547. this->Makefile->GetPolicyStatus(cmPolicies::CMP0004);
  1548. this->PolicyStatusCMP0008 =
  1549. this->Makefile->GetPolicyStatus(cmPolicies::CMP0008);
  1550. this->PolicyStatusCMP0020 =
  1551. this->Makefile->GetPolicyStatus(cmPolicies::CMP0020);
  1552. this->PolicyStatusCMP0021 =
  1553. this->Makefile->GetPolicyStatus(cmPolicies::CMP0021);
  1554. this->PolicyStatusCMP0022 =
  1555. this->Makefile->GetPolicyStatus(cmPolicies::CMP0022);
  1556. }
  1557. //----------------------------------------------------------------------------
  1558. void cmTarget::FinishConfigure()
  1559. {
  1560. // Erase any cached link information that might have been comptued
  1561. // on-demand during the configuration. This ensures that build
  1562. // system generation uses up-to-date information even if other cache
  1563. // invalidation code in this source file is buggy.
  1564. this->ClearLinkMaps();
  1565. // Do old-style link dependency analysis.
  1566. this->AnalyzeLibDependencies(*this->Makefile);
  1567. }
  1568. //----------------------------------------------------------------------------
  1569. void cmTarget::ClearLinkMaps()
  1570. {
  1571. this->Internal->LinkImplMap.clear();
  1572. this->Internal->LinkInterfaceMap.clear();
  1573. this->Internal->LinkClosureMap.clear();
  1574. for (cmTargetLinkInformationMap::const_iterator it
  1575. = this->LinkInformation.begin();
  1576. it != this->LinkInformation.end(); ++it)
  1577. {
  1578. delete it->second;
  1579. }
  1580. this->LinkInformation.clear();
  1581. }
  1582. //----------------------------------------------------------------------------
  1583. cmListFileBacktrace const& cmTarget::GetBacktrace() const
  1584. {
  1585. return this->Internal->Backtrace;
  1586. }
  1587. //----------------------------------------------------------------------------
  1588. std::string cmTarget::GetSupportDirectory() const
  1589. {
  1590. std::string dir = this->Makefile->GetCurrentOutputDirectory();
  1591. dir += cmake::GetCMakeFilesDirectory();
  1592. dir += "/";
  1593. dir += this->Name;
  1594. #if defined(__VMS)
  1595. dir += "_dir";
  1596. #else
  1597. dir += ".dir";
  1598. #endif
  1599. return dir;
  1600. }
  1601. //----------------------------------------------------------------------------
  1602. bool cmTarget::IsExecutableWithExports()
  1603. {
  1604. return (this->GetType() == cmTarget::EXECUTABLE &&
  1605. this->GetPropertyAsBool("ENABLE_EXPORTS"));
  1606. }
  1607. //----------------------------------------------------------------------------
  1608. bool cmTarget::IsLinkable()
  1609. {
  1610. return (this->GetType() == cmTarget::STATIC_LIBRARY ||
  1611. this->GetType() == cmTarget::SHARED_LIBRARY ||
  1612. this->GetType() == cmTarget::MODULE_LIBRARY ||
  1613. this->GetType() == cmTarget::UNKNOWN_LIBRARY ||
  1614. this->IsExecutableWithExports());
  1615. }
  1616. //----------------------------------------------------------------------------
  1617. bool cmTarget::HasImportLibrary()
  1618. {
  1619. return (this->DLLPlatform &&
  1620. (this->GetType() == cmTarget::SHARED_LIBRARY ||
  1621. this->IsExecutableWithExports()));
  1622. }
  1623. //----------------------------------------------------------------------------
  1624. bool cmTarget::IsFrameworkOnApple()
  1625. {
  1626. return (this->GetType() == cmTarget::SHARED_LIBRARY &&
  1627. this->Makefile->IsOn("APPLE") &&
  1628. this->GetPropertyAsBool("FRAMEWORK"));
  1629. }
  1630. //----------------------------------------------------------------------------
  1631. bool cmTarget::IsAppBundleOnApple()
  1632. {
  1633. return (this->GetType() == cmTarget::EXECUTABLE &&
  1634. this->Makefile->IsOn("APPLE") &&
  1635. this->GetPropertyAsBool("MACOSX_BUNDLE"));
  1636. }
  1637. //----------------------------------------------------------------------------
  1638. bool cmTarget::IsCFBundleOnApple()
  1639. {
  1640. return (this->GetType() == cmTarget::MODULE_LIBRARY &&
  1641. this->Makefile->IsOn("APPLE") &&
  1642. this->GetPropertyAsBool("BUNDLE"));
  1643. }
  1644. //----------------------------------------------------------------------------
  1645. bool cmTarget::IsBundleOnApple()
  1646. {
  1647. return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() ||
  1648. this->IsCFBundleOnApple();
  1649. }
  1650. //----------------------------------------------------------------------------
  1651. class cmTargetTraceDependencies
  1652. {
  1653. public:
  1654. cmTargetTraceDependencies(cmTarget* target, cmTargetInternals* internal,
  1655. const char* vsProjectFile);
  1656. void Trace();
  1657. private:
  1658. cmTarget* Target;
  1659. cmTargetInternals* Internal;
  1660. cmMakefile* Makefile;
  1661. cmGlobalGenerator* GlobalGenerator;
  1662. typedef cmTargetInternals::SourceEntry SourceEntry;
  1663. SourceEntry* CurrentEntry;
  1664. std::queue<cmSourceFile*> SourceQueue;
  1665. std::set<cmSourceFile*> SourcesQueued;
  1666. typedef std::map<cmStdString, cmSourceFile*> NameMapType;
  1667. NameMapType NameMap;
  1668. void QueueSource(cmSourceFile* sf);
  1669. void FollowName(std::string const& name);
  1670. void FollowNames(std::vector<std::string> const& names);
  1671. bool IsUtility(std::string const& dep);
  1672. void CheckCustomCommand(cmCustomCommand const& cc);
  1673. void CheckCustomCommands(const std::vector<cmCustomCommand>& commands);
  1674. };
  1675. //----------------------------------------------------------------------------
  1676. cmTargetTraceDependencies
  1677. ::cmTargetTraceDependencies(cmTarget* target, cmTargetInternals* internal,
  1678. const char* vsProjectFile):
  1679. Target(target), Internal(internal)
  1680. {
  1681. // Convenience.
  1682. this->Makefile = this->Target->GetMakefile();
  1683. this->GlobalGenerator =
  1684. this->Makefile->GetLocalGenerator()->GetGlobalGenerator();
  1685. this->CurrentEntry = 0;
  1686. // Queue all the source files already specified for the target.
  1687. std::vector<cmSourceFile*> const& sources = this->Target->GetSourceFiles();
  1688. for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
  1689. si != sources.end(); ++si)
  1690. {
  1691. this->QueueSource(*si);
  1692. }
  1693. // Queue the VS project file to check dependencies on the rule to
  1694. // generate it.
  1695. if(vsProjectFile)
  1696. {
  1697. this->FollowName(vsProjectFile);
  1698. }
  1699. // Queue pre-build, pre-link, and post-build rule dependencies.
  1700. this->CheckCustomCommands(this->Target->GetPreBuildCommands());
  1701. this->CheckCustomCommands(this->Target->GetPreLinkCommands());
  1702. this->CheckCustomCommands(this->Target->GetPostBuildCommands());
  1703. }
  1704. //----------------------------------------------------------------------------
  1705. void cmTargetTraceDependencies::Trace()
  1706. {
  1707. // Process one dependency at a time until the queue is empty.
  1708. while(!this->SourceQueue.empty())
  1709. {
  1710. // Get the next source from the queue.
  1711. cmSourceFile* sf = this->SourceQueue.front();
  1712. this->SourceQueue.pop();
  1713. this->CurrentEntry = &this->Internal->SourceEntries[sf];
  1714. // Queue dependencies added explicitly by the user.
  1715. if(const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS"))
  1716. {
  1717. std::vector<std::string> objDeps;
  1718. cmSystemTools::ExpandListArgument(additionalDeps, objDeps);
  1719. this->FollowNames(objDeps);
  1720. }
  1721. // Queue the source needed to generate this file, if any.
  1722. this->FollowName(sf->GetFullPath());
  1723. // Queue dependencies added programatically by commands.
  1724. this->FollowNames(sf->GetDepends());
  1725. // Queue custom command dependencies.
  1726. if(cmCustomCommand const* cc = sf->GetCustomCommand())
  1727. {
  1728. this->CheckCustomCommand(*cc);
  1729. }
  1730. }
  1731. this->CurrentEntry = 0;
  1732. }
  1733. //----------------------------------------------------------------------------
  1734. void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf)
  1735. {
  1736. if(this->SourcesQueued.insert(sf).second)
  1737. {
  1738. this->SourceQueue.push(sf);
  1739. // Make sure this file is in the target.
  1740. this->Target->AddSourceFile(sf);
  1741. }
  1742. }
  1743. //----------------------------------------------------------------------------
  1744. void cmTargetTraceDependencies::FollowName(std::string const& name)
  1745. {
  1746. NameMapType::iterator i = this->NameMap.find(name);
  1747. if(i == this->NameMap.end())
  1748. {
  1749. // Check if we know how to generate this file.
  1750. cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name.c_str());
  1751. NameMapType::value_type entry(name, sf);
  1752. i = this->NameMap.insert(entry).first;
  1753. }
  1754. if(cmSourceFile* sf = i->second)
  1755. {
  1756. // Record the dependency we just followed.
  1757. if(this->CurrentEntry)
  1758. {
  1759. this->CurrentEntry->Depends.push_back(sf);
  1760. }
  1761. this->QueueSource(sf);
  1762. }
  1763. }
  1764. //----------------------------------------------------------------------------
  1765. void
  1766. cmTargetTraceDependencies::FollowNames(std::vector<std::string> const& names)
  1767. {
  1768. for(std::vector<std::string>::const_iterator i = names.begin();
  1769. i != names.end(); ++i)
  1770. {
  1771. this->FollowName(*i);
  1772. }
  1773. }
  1774. //----------------------------------------------------------------------------
  1775. bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
  1776. {
  1777. // Dependencies on targets (utilities) are supposed to be named by
  1778. // just the target name. However for compatibility we support
  1779. // naming the output file generated by the target (assuming there is
  1780. // no output-name property which old code would not have set). In
  1781. // that case the target name will be the file basename of the
  1782. // dependency.
  1783. std::string util = cmSystemTools::GetFilenameName(dep);
  1784. if(cmSystemTools::GetFilenameLastExtension(util) == ".exe")
  1785. {
  1786. util = cmSystemTools::GetFilenameWithoutLastExtension(util);
  1787. }
  1788. // Check for a target with this name.
  1789. if(cmTarget* t = this->Makefile->FindTargetToUse(util.c_str()))
  1790. {
  1791. // If we find the target and the dep was given as a full path,
  1792. // then make sure it was not a full path to something else, and
  1793. // the fact that the name matched a target was just a coincidence.
  1794. if(cmSystemTools::FileIsFullPath(dep.c_str()))
  1795. {
  1796. if(t->GetType() >= cmTarget::EXECUTABLE &&
  1797. t->GetType() <= cmTarget::MODULE_LIBRARY)
  1798. {
  1799. // This is really only for compatibility so we do not need to
  1800. // worry about configuration names and output names.
  1801. std::string tLocation = t->GetLocation(0);
  1802. tLocation = cmSystemTools::GetFilenamePath(tLocation);
  1803. std::string depLocation = cmSystemTools::GetFilenamePath(dep);
  1804. depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str());
  1805. tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str());
  1806. if(depLocation == tLocation)
  1807. {
  1808. this->Target->AddUtility(util.c_str());
  1809. return true;
  1810. }
  1811. }
  1812. }
  1813. else
  1814. {
  1815. // The original name of the dependency was not a full path. It
  1816. // must name a target, so add the target-level dependency.
  1817. this->Target->AddUtility(util.c_str());
  1818. return true;
  1819. }
  1820. }
  1821. // The dependency does not name a target built in this project.
  1822. return false;
  1823. }
  1824. //----------------------------------------------------------------------------
  1825. void
  1826. cmTargetTraceDependencies
  1827. ::CheckCustomCommand(cmCustomCommand const& cc)
  1828. {
  1829. // Transform command names that reference targets built in this
  1830. // project to corresponding target-level dependencies.
  1831. cmGeneratorExpression ge(cc.GetBacktrace());
  1832. // Add target-level dependencies referenced by generator expressions.
  1833. std::set<cmTarget*> targets;
  1834. for(cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin();
  1835. cit != cc.GetCommandLines().end(); ++cit)
  1836. {
  1837. std::string const& command = *cit->begin();
  1838. // Check for a target with this name.
  1839. if(cmTarget* t = this->Makefile->FindTargetToUse(command.c_str()))
  1840. {
  1841. if(t->GetType() == cmTarget::EXECUTABLE)
  1842. {
  1843. // The command refers to an executable target built in
  1844. // this project. Add the target-level dependency to make
  1845. // sure the executable is up to date before this custom
  1846. // command possibly runs.
  1847. this->Target->AddUtility(command.c_str());
  1848. }
  1849. }
  1850. // Check for target references in generator expressions.
  1851. for(cmCustomCommandLine::const_iterator cli = cit->begin();
  1852. cli != cit->end(); ++cli)
  1853. {
  1854. const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge
  1855. = ge.Parse(*cli);
  1856. cge->Evaluate(this->Makefile, 0, true);
  1857. std::set<cmTarget*> geTargets = cge->GetTargets();
  1858. for(std::set<cmTarget*>::const_iterator it = geTargets.begin();
  1859. it != geTargets.end(); ++it)
  1860. {
  1861. targets.insert(*it);
  1862. }
  1863. }
  1864. }
  1865. for(std::set<cmTarget*>::iterator ti = targets.begin();
  1866. ti != targets.end(); ++ti)
  1867. {
  1868. this->Target->AddUtility((*ti)->GetName());
  1869. }
  1870. // Queue the custom command dependencies.
  1871. std::vector<std::string> const& depends = cc.GetDepends();
  1872. for(std::vector<std::string>::const_iterator di = depends.begin();
  1873. di != depends.end(); ++di)
  1874. {
  1875. std::string const& dep = *di;
  1876. if(!this->IsUtility(dep))
  1877. {
  1878. // The dependency does not name a target and may be a file we
  1879. // know how to generate. Queue it.
  1880. this->FollowName(dep);
  1881. }
  1882. }
  1883. }
  1884. //----------------------------------------------------------------------------
  1885. void
  1886. cmTargetTraceDependencies
  1887. ::CheckCustomCommands(const std::vector<cmCustomCommand>& commands)
  1888. {
  1889. for(std::vector<cmCustomCommand>::const_iterator cli = commands.begin();
  1890. cli != commands.end(); ++cli)
  1891. {
  1892. this->CheckCustomCommand(*cli);
  1893. }
  1894. }
  1895. //----------------------------------------------------------------------------
  1896. void cmTarget::TraceDependencies(const char* vsProjectFile)
  1897. {
  1898. // CMake-generated targets have no dependencies to trace. Normally tracing
  1899. // would find nothing anyway, but when building CMake itself the "install"
  1900. // target command ends up referencing the "cmake" target but we do not
  1901. // really want the dependency because "install" depend on "all" anyway.
  1902. if(this->GetType() == cmTarget::GLOBAL_TARGET)
  1903. {
  1904. return;
  1905. }
  1906. // Use a helper object to trace the dependencies.
  1907. cmTargetTraceDependencies tracer(this, this->Internal.Get(), vsProjectFile);
  1908. tracer.Trace();
  1909. }
  1910. //----------------------------------------------------------------------------
  1911. bool cmTarget::FindSourceFiles()
  1912. {
  1913. for(std::vector<cmSourceFile*>::const_iterator
  1914. si = this->SourceFiles.begin();
  1915. si != this->SourceFiles.end(); ++si)
  1916. {
  1917. std::string e;
  1918. if((*si)->GetFullPath(&e).empty())
  1919. {
  1920. if(!e.empty())
  1921. {
  1922. cmake* cm = this->Makefile->GetCMakeInstance();
  1923. cm->IssueMessage(cmake::FATAL_ERROR, e,
  1924. this->GetBacktrace());
  1925. }
  1926. return false;
  1927. }
  1928. }
  1929. return true;
  1930. }
  1931. //----------------------------------------------------------------------------
  1932. std::vector<cmSourceFile*> const& cmTarget::GetSourceFiles()
  1933. {
  1934. return this->SourceFiles;
  1935. }
  1936. //----------------------------------------------------------------------------
  1937. void cmTarget::AddSourceFile(cmSourceFile* sf)
  1938. {
  1939. typedef cmTargetInternals::SourceEntriesType SourceEntriesType;
  1940. SourceEntriesType::iterator i = this->Internal->SourceEntries.find(sf);
  1941. if(i == this->Internal->SourceEntries.end())
  1942. {
  1943. typedef cmTargetInternals::SourceEntry SourceEntry;
  1944. SourceEntriesType::value_type entry(sf, SourceEntry());
  1945. i = this->Internal->SourceEntries.insert(entry).first;
  1946. this->SourceFiles.push_back(sf);
  1947. }
  1948. }
  1949. //----------------------------------------------------------------------------
  1950. std::vector<cmSourceFile*> const*
  1951. cmTarget::GetSourceDepends(cmSourceFile* sf)
  1952. {
  1953. typedef cmTargetInternals::SourceEntriesType SourceEntriesType;
  1954. SourceEntriesType::iterator i = this->Internal->SourceEntries.find(sf);
  1955. if(i != this->Internal->SourceEntries.end())
  1956. {
  1957. return &i->second.Depends;
  1958. }
  1959. return 0;
  1960. }
  1961. //----------------------------------------------------------------------------
  1962. void cmTarget::AddSources(std::vector<std::string> const& srcs)
  1963. {
  1964. for(std::vector<std::string>::const_iterator i = srcs.begin();
  1965. i != srcs.end(); ++i)
  1966. {
  1967. const char* src = i->c_str();
  1968. if(src[0] == '$' && src[1] == '<')
  1969. {
  1970. this->ProcessSourceExpression(*i);
  1971. }
  1972. else
  1973. {
  1974. this->AddSource(src);
  1975. }
  1976. }
  1977. }
  1978. //----------------------------------------------------------------------------
  1979. cmSourceFile* cmTarget::AddSource(const char* s)
  1980. {
  1981. std::string src = s;
  1982. // For backwards compatibility replace varibles in source names.
  1983. // This should eventually be removed.
  1984. this->Makefile->ExpandVariablesInString(src);
  1985. cmSourceFile* sf = this->Makefile->GetOrCreateSource(src.c_str());
  1986. this->AddSourceFile(sf);
  1987. return sf;
  1988. }
  1989. //----------------------------------------------------------------------------
  1990. void cmTarget::ProcessSourceExpression(std::string const& expr)
  1991. {
  1992. if(strncmp(expr.c_str(), "$<TARGET_OBJECTS:", 17) == 0 &&
  1993. expr[expr.size()-1] == '>')
  1994. {
  1995. std::string objLibName = expr.substr(17, expr.size()-18);
  1996. this->ObjectLibraries.push_back(objLibName);
  1997. }
  1998. else
  1999. {
  2000. cmOStringStream e;
  2001. e << "Unrecognized generator expression:\n"
  2002. << " " << expr;
  2003. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  2004. }
  2005. }
  2006. //----------------------------------------------------------------------------
  2007. struct cmTarget::SourceFileFlags
  2008. cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf)
  2009. {
  2010. struct SourceFileFlags flags;
  2011. this->ConstructSourceFileFlags();
  2012. std::map<cmSourceFile const*, SourceFileFlags>::iterator si =
  2013. this->Internal->SourceFlagsMap.find(sf);
  2014. if(si != this->Internal->SourceFlagsMap.end())
  2015. {
  2016. flags = si->second;
  2017. }
  2018. return flags;
  2019. }
  2020. //----------------------------------------------------------------------------
  2021. void cmTarget::ConstructSourceFileFlags()
  2022. {
  2023. if(this->Internal->SourceFileFlagsConstructed)
  2024. {
  2025. return;
  2026. }
  2027. this->Internal->SourceFileFlagsConstructed = true;
  2028. // Process public headers to mark the source files.
  2029. if(const char* files = this->GetProperty("PUBLIC_HEADER"))
  2030. {
  2031. std::vector<std::string> relFiles;
  2032. cmSystemTools::ExpandListArgument(files, relFiles);
  2033. for(std::vector<std::string>::iterator it = relFiles.begin();
  2034. it != relFiles.end(); ++it)
  2035. {
  2036. if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
  2037. {
  2038. SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
  2039. flags.MacFolder = "Headers";
  2040. flags.Type = cmTarget::SourceFileTypePublicHeader;
  2041. }
  2042. }
  2043. }
  2044. // Process private headers after public headers so that they take
  2045. // precedence if a file is listed in both.
  2046. if(const char* files = this->GetProperty("PRIVATE_HEADER"))
  2047. {
  2048. std::vector<std::string> relFiles;
  2049. cmSystemTools::ExpandListArgument(files, relFiles);
  2050. for(std::vector<std::string>::iterator it = relFiles.begin();
  2051. it != relFiles.end(); ++it)
  2052. {
  2053. if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
  2054. {
  2055. SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
  2056. flags.MacFolder = "PrivateHeaders";
  2057. flags.Type = cmTarget::SourceFileTypePrivateHeader;
  2058. }
  2059. }
  2060. }
  2061. // Mark sources listed as resources.
  2062. if(const char* files = this->GetProperty("RESOURCE"))
  2063. {
  2064. std::vector<std::string> relFiles;
  2065. cmSystemTools::ExpandListArgument(files, relFiles);
  2066. for(std::vector<std::string>::iterator it = relFiles.begin();
  2067. it != relFiles.end(); ++it)
  2068. {
  2069. if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
  2070. {
  2071. SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
  2072. flags.MacFolder = "Resources";
  2073. flags.Type = cmTarget::SourceFileTypeResource;
  2074. }
  2075. }
  2076. }
  2077. // Handle the MACOSX_PACKAGE_LOCATION property on source files that
  2078. // were not listed in one of the other lists.
  2079. std::vector<cmSourceFile*> const& sources = this->GetSourceFiles();
  2080. for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
  2081. si != sources.end(); ++si)
  2082. {
  2083. cmSourceFile* sf = *si;
  2084. if(const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION"))
  2085. {
  2086. SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
  2087. if(flags.Type == cmTarget::SourceFileTypeNormal)
  2088. {
  2089. flags.MacFolder = location;
  2090. if(strcmp(location, "Resources") == 0)
  2091. {
  2092. flags.Type = cmTarget::SourceFileTypeResource;
  2093. }
  2094. else
  2095. {
  2096. flags.Type = cmTarget::SourceFileTypeMacContent;
  2097. }
  2098. }
  2099. }
  2100. }
  2101. }
  2102. //----------------------------------------------------------------------------
  2103. void cmTarget::MergeLinkLibraries( cmMakefile& mf,
  2104. const char *selfname,
  2105. const LinkLibraryVectorType& libs )
  2106. {
  2107. // Only add on libraries we haven't added on before.
  2108. // Assumption: the global link libraries could only grow, never shrink
  2109. LinkLibraryVectorType::const_iterator i = libs.begin();
  2110. i += this->PrevLinkedLibraries.size();
  2111. for( ; i != libs.end(); ++i )
  2112. {
  2113. // We call this so that the dependencies get written to the cache
  2114. this->AddLinkLibrary( mf, selfname, i->first.c_str(), i->second );
  2115. if (this->GetType() == cmTarget::STATIC_LIBRARY)
  2116. {
  2117. this->AppendProperty("INTERFACE_LINK_LIBRARIES",
  2118. ("$<LINK_ONLY:" +
  2119. this->GetDebugGeneratorExpressions(i->first.c_str(), i->second) +
  2120. ">").c_str());
  2121. }
  2122. }
  2123. this->PrevLinkedLibraries = libs;
  2124. }
  2125. //----------------------------------------------------------------------------
  2126. void cmTarget::AddLinkDirectory(const char* d)
  2127. {
  2128. // Make sure we don't add unnecessary search directories.
  2129. if(this->LinkDirectoriesEmmitted.insert(d).second)
  2130. {
  2131. this->LinkDirectories.push_back(d);
  2132. }
  2133. }
  2134. //----------------------------------------------------------------------------
  2135. const std::vector<std::string>& cmTarget::GetLinkDirectories()
  2136. {
  2137. return this->LinkDirectories;
  2138. }
  2139. //----------------------------------------------------------------------------
  2140. cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config)
  2141. {
  2142. // No configuration is always optimized.
  2143. if(!(config && *config))
  2144. {
  2145. return cmTarget::OPTIMIZED;
  2146. }
  2147. // Get the list of configurations considered to be DEBUG.
  2148. std::vector<std::string> const& debugConfigs =
  2149. this->Makefile->GetCMakeInstance()->GetDebugConfigs();
  2150. // Check if any entry in the list matches this configuration.
  2151. std::string configUpper = cmSystemTools::UpperCase(config);
  2152. for(std::vector<std::string>::const_iterator i = debugConfigs.begin();
  2153. i != debugConfigs.end(); ++i)
  2154. {
  2155. if(*i == configUpper)
  2156. {
  2157. return cmTarget::DEBUG;
  2158. }
  2159. }
  2160. // The current configuration is not a debug configuration.
  2161. return cmTarget::OPTIMIZED;
  2162. }
  2163. //----------------------------------------------------------------------------
  2164. void cmTarget::ClearDependencyInformation( cmMakefile& mf,
  2165. const char* target )
  2166. {
  2167. // Clear the dependencies. The cache variable must exist iff we are
  2168. // recording dependency information for this target.
  2169. std::string depname = target;
  2170. depname += "_LIB_DEPENDS";
  2171. if (this->RecordDependencies)
  2172. {
  2173. mf.AddCacheDefinition(depname.c_str(), "",
  2174. "Dependencies for target", cmCacheManager::STATIC);
  2175. }
  2176. else
  2177. {
  2178. if (mf.GetDefinition( depname.c_str() ))
  2179. {
  2180. std::string message = "Target ";
  2181. message += target;
  2182. message += " has dependency information when it shouldn't.\n";
  2183. message += "Your cache is probably stale. Please remove the entry\n ";
  2184. message += depname;
  2185. message += "\nfrom the cache.";
  2186. cmSystemTools::Error( message.c_str() );
  2187. }
  2188. }
  2189. }
  2190. //----------------------------------------------------------------------------
  2191. bool cmTarget::NameResolvesToFramework(const std::string& libname)
  2192. {
  2193. return this->GetMakefile()->GetLocalGenerator()->GetGlobalGenerator()->
  2194. NameResolvesToFramework(libname);
  2195. }
  2196. //----------------------------------------------------------------------------
  2197. void cmTarget::GetDirectLinkLibraries(const char *config,
  2198. std::vector<std::string> &libs, cmTarget *head)
  2199. {
  2200. const char *prop = this->GetProperty("LINK_LIBRARIES");
  2201. if (prop)
  2202. {
  2203. cmListFileBacktrace lfbt;
  2204. cmGeneratorExpression ge(lfbt);
  2205. const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
  2206. cmGeneratorExpressionDAGChecker dagChecker(lfbt,
  2207. this->GetName(),
  2208. "LINK_LIBRARIES", 0, 0);
  2209. cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile,
  2210. config,
  2211. false,
  2212. head,
  2213. &dagChecker),
  2214. libs);
  2215. std::set<cmStdString> seenProps = cge->GetSeenTargetProperties();
  2216. for (std::set<cmStdString>::const_iterator it = seenProps.begin();
  2217. it != seenProps.end(); ++it)
  2218. {
  2219. if (!this->GetProperty(it->c_str()))
  2220. {
  2221. this->LinkImplicitNullProperties.insert(*it);
  2222. }
  2223. }
  2224. }
  2225. }
  2226. //----------------------------------------------------------------------------
  2227. std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value,
  2228. cmTarget::LinkLibraryType llt)
  2229. {
  2230. if (llt == GENERAL)
  2231. {
  2232. return value;
  2233. }
  2234. // Get the list of configurations considered to be DEBUG.
  2235. std::vector<std::string> const& debugConfigs =
  2236. this->Makefile->GetCMakeInstance()->GetDebugConfigs();
  2237. std::string configString = "$<CONFIG:" + debugConfigs[0] + ">";
  2238. if (debugConfigs.size() > 1)
  2239. {
  2240. for(std::vector<std::string>::const_iterator
  2241. li = debugConfigs.begin() + 1; li != debugConfigs.end(); ++li)
  2242. {
  2243. configString += ",$<CONFIG:" + *li + ">";
  2244. }
  2245. configString = "$<OR:" + configString + ">";
  2246. }
  2247. if (llt == OPTIMIZED)
  2248. {
  2249. configString = "$<NOT:" + configString + ">";
  2250. }
  2251. return "$<" + configString + ":" + value + ">";
  2252. }
  2253. //----------------------------------------------------------------------------
  2254. static std::string targetNameGenex(const char *lib)
  2255. {
  2256. return std::string("$<TARGET_NAME:") + lib + ">";
  2257. }
  2258. //----------------------------------------------------------------------------
  2259. void cmTarget::AddLinkLibrary(cmMakefile& mf,
  2260. const char *target, const char* lib,
  2261. LinkLibraryType llt)
  2262. {
  2263. // Never add a self dependency, even if the user asks for it.
  2264. if(strcmp( target, lib ) == 0)
  2265. {
  2266. return;
  2267. }
  2268. {
  2269. cmTarget *tgt = this->Makefile->FindTargetToUse(lib);
  2270. const bool isNonImportedTarget = tgt && !tgt->IsImported();
  2271. const std::string libName = (isNonImportedTarget && llt != GENERAL)
  2272. ? targetNameGenex(lib)
  2273. : std::string(lib);
  2274. this->AppendProperty("LINK_LIBRARIES",
  2275. this->GetDebugGeneratorExpressions(libName,
  2276. llt).c_str());
  2277. }
  2278. if (cmGeneratorExpression::Find(lib) != std::string::npos)
  2279. {
  2280. return;
  2281. }
  2282. cmTarget::LibraryID tmp;
  2283. tmp.first = lib;
  2284. tmp.second = llt;
  2285. this->LinkLibraries.push_back( tmp );
  2286. this->OriginalLinkLibraries.push_back(tmp);
  2287. this->ClearLinkMaps();
  2288. // Add the explicit dependency information for this target. This is
  2289. // simply a set of libraries separated by ";". There should always
  2290. // be a trailing ";". These library names are not canonical, in that
  2291. // they may be "-framework x", "-ly", "/path/libz.a", etc.
  2292. // We shouldn't remove duplicates here because external libraries
  2293. // may be purposefully duplicated to handle recursive dependencies,
  2294. // and we removing one instance will break the link line. Duplicates
  2295. // will be appropriately eliminated at emit time.
  2296. if(this->RecordDependencies)
  2297. {
  2298. std::string targetEntry = target;
  2299. targetEntry += "_LIB_DEPENDS";
  2300. std::string dependencies;
  2301. const char* old_val = mf.GetDefinition( targetEntry.c_str() );
  2302. if( old_val )
  2303. {
  2304. dependencies += old_val;
  2305. }
  2306. switch (llt)
  2307. {
  2308. case cmTarget::GENERAL:
  2309. dependencies += "general";
  2310. break;
  2311. case cmTarget::DEBUG:
  2312. dependencies += "debug";
  2313. break;
  2314. case cmTarget::OPTIMIZED:
  2315. dependencies += "optimized";
  2316. break;
  2317. }
  2318. dependencies += ";";
  2319. dependencies += lib;
  2320. dependencies += ";";
  2321. mf.AddCacheDefinition( targetEntry.c_str(), dependencies.c_str(),
  2322. "Dependencies for the target",
  2323. cmCacheManager::STATIC );
  2324. }
  2325. }
  2326. //----------------------------------------------------------------------------
  2327. void
  2328. cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
  2329. {
  2330. // There are two key parts of the dependency analysis: (1)
  2331. // determining the libraries in the link line, and (2) constructing
  2332. // the dependency graph for those libraries.
  2333. //
  2334. // The latter is done using the cache entries that record the
  2335. // dependencies of each library.
  2336. //
  2337. // The former is a more thorny issue, since it is not clear how to
  2338. // determine if two libraries listed on the link line refer to the a
  2339. // single library or not. For example, consider the link "libraries"
  2340. // /usr/lib/libtiff.so -ltiff
  2341. // Is this one library or two? The solution implemented here is the
  2342. // simplest (and probably the only practical) one: two libraries are
  2343. // the same if their "link strings" are identical. Thus, the two
  2344. // libraries above are considered distinct. This also means that for
  2345. // dependency analysis to be effective, the CMake user must specify
  2346. // libraries build by his project without using any linker flags or
  2347. // file extensions. That is,
  2348. // LINK_LIBRARIES( One Two )
  2349. // instead of
  2350. // LINK_LIBRARIES( -lOne ${binarypath}/libTwo.a )
  2351. // The former is probably what most users would do, but it never
  2352. // hurts to document the assumptions. :-) Therefore, in the analysis
  2353. // code, the "canonical name" of a library is simply its name as
  2354. // given to a LINK_LIBRARIES command.
  2355. //
  2356. // Also, we will leave the original link line intact; we will just add any
  2357. // dependencies that were missing.
  2358. //
  2359. // There is a problem with recursive external libraries
  2360. // (i.e. libraries with no dependency information that are
  2361. // recursively dependent). We must make sure that the we emit one of
  2362. // the libraries twice to satisfy the recursion, but we shouldn't
  2363. // emit it more times than necessary. In particular, we must make
  2364. // sure that handling this improbable case doesn't cost us when
  2365. // dealing with the common case of non-recursive libraries. The
  2366. // solution is to assume that the recursion is satisfied at one node
  2367. // of the dependency tree. To illustrate, assume libA and libB are
  2368. // extrenal and mutually dependent. Suppose libX depends on
  2369. // libA, and libY on libA and libX. Then
  2370. // TARGET_LINK_LIBRARIES( Y X A B A )
  2371. // TARGET_LINK_LIBRARIES( X A B A )
  2372. // TARGET_LINK_LIBRARIES( Exec Y )
  2373. // would result in "-lY -lX -lA -lB -lA". This is the correct way to
  2374. // specify the dependencies, since the mutual dependency of A and B
  2375. // is resolved *every time libA is specified*.
  2376. //
  2377. // Something like
  2378. // TARGET_LINK_LIBRARIES( Y X A B A )
  2379. // TARGET_LINK_LIBRARIES( X A B )
  2380. // TARGET_LINK_LIBRARIES( Exec Y )
  2381. // would result in "-lY -lX -lA -lB", and the mutual dependency
  2382. // information is lost. This is because in some case (Y), the mutual
  2383. // dependency of A and B is listed, while in another other case (X),
  2384. // it is not. Depending on which line actually emits A, the mutual
  2385. // dependency may or may not be on the final link line. We can't
  2386. // handle this pathalogical case cleanly without emitting extra
  2387. // libraries for the normal cases. Besides, the dependency
  2388. // information for X is wrong anyway: if we build an executable
  2389. // depending on X alone, we would not have the mutual dependency on
  2390. // A and B resolved.
  2391. //
  2392. // IMPROVEMENTS:
  2393. // -- The current algorithm will not always pick the "optimal" link line
  2394. // when recursive dependencies are present. It will instead break the
  2395. // cycles at an aribtrary point. The majority of projects won't have
  2396. // cyclic dependencies, so this is probably not a big deal. Note that
  2397. // the link line is always correct, just not necessary optimal.
  2398. {
  2399. // Expand variables in link library names. This is for backwards
  2400. // compatibility with very early CMake versions and should
  2401. // eventually be removed. This code was moved here from the end of
  2402. // old source list processing code which was called just before this
  2403. // method.
  2404. for(LinkLibraryVectorType::iterator p = this->LinkLibraries.begin();
  2405. p != this->LinkLibraries.end(); ++p)
  2406. {
  2407. this->Makefile->ExpandVariablesInString(p->first, true, true);
  2408. }
  2409. }
  2410. // The dependency map.
  2411. DependencyMap dep_map;
  2412. // 1. Build the dependency graph
  2413. //
  2414. for(LinkLibraryVectorType::reverse_iterator lib
  2415. = this->LinkLibraries.rbegin();
  2416. lib != this->LinkLibraries.rend(); ++lib)
  2417. {
  2418. this->GatherDependencies( mf, *lib, dep_map);
  2419. }
  2420. // 2. Remove any dependencies that are already satisfied in the original
  2421. // link line.
  2422. //
  2423. for(LinkLibraryVectorType::iterator lib = this->LinkLibraries.begin();
  2424. lib != this->LinkLibraries.end(); ++lib)
  2425. {
  2426. for( LinkLibraryVectorType::iterator lib2 = lib;
  2427. lib2 != this->LinkLibraries.end(); ++lib2)
  2428. {
  2429. this->DeleteDependency( dep_map, *lib, *lib2);
  2430. }
  2431. }
  2432. // 3. Create the new link line by simply emitting any dependencies that are
  2433. // missing. Start from the back and keep adding.
  2434. //
  2435. std::set<DependencyMap::key_type> done, visited;
  2436. std::vector<DependencyMap::key_type> newLinkLibraries;
  2437. for(LinkLibraryVectorType::reverse_iterator lib =
  2438. this->LinkLibraries.rbegin();
  2439. lib != this->LinkLibraries.rend(); ++lib)
  2440. {
  2441. // skip zero size library entries, this may happen
  2442. // if a variable expands to nothing.
  2443. if (lib->first.size() != 0)
  2444. {
  2445. this->Emit( *lib, dep_map, done, visited, newLinkLibraries );
  2446. }
  2447. }
  2448. // 4. Add the new libraries to the link line.
  2449. //
  2450. for( std::vector<DependencyMap::key_type>::reverse_iterator k =
  2451. newLinkLibraries.rbegin();
  2452. k != newLinkLibraries.rend(); ++k )
  2453. {
  2454. // get the llt from the dep_map
  2455. this->LinkLibraries.push_back( std::make_pair(k->first,k->second) );
  2456. }
  2457. this->LinkLibrariesAnalyzed = true;
  2458. }
  2459. //----------------------------------------------------------------------------
  2460. void cmTarget::InsertDependency( DependencyMap& depMap,
  2461. const LibraryID& lib,
  2462. const LibraryID& dep)
  2463. {
  2464. depMap[lib].push_back(dep);
  2465. }
  2466. //----------------------------------------------------------------------------
  2467. void cmTarget::DeleteDependency( DependencyMap& depMap,
  2468. const LibraryID& lib,
  2469. const LibraryID& dep)
  2470. {
  2471. // Make sure there is an entry in the map for lib. If so, delete all
  2472. // dependencies to dep. There may be repeated entries because of
  2473. // external libraries that are specified multiple times.
  2474. DependencyMap::iterator map_itr = depMap.find( lib );
  2475. if( map_itr != depMap.end() )
  2476. {
  2477. DependencyList& depList = map_itr->second;
  2478. DependencyList::iterator itr;
  2479. while( (itr = std::find(depList.begin(), depList.end(), dep)) !=
  2480. depList.end() )
  2481. {
  2482. depList.erase( itr );
  2483. }
  2484. }
  2485. }
  2486. //----------------------------------------------------------------------------
  2487. void cmTarget::Emit(const LibraryID lib,
  2488. const DependencyMap& dep_map,
  2489. std::set<LibraryID>& emitted,
  2490. std::set<LibraryID>& visited,
  2491. DependencyList& link_line )
  2492. {
  2493. // It's already been emitted
  2494. if( emitted.find(lib) != emitted.end() )
  2495. {
  2496. return;
  2497. }
  2498. // Emit the dependencies only if this library node hasn't been
  2499. // visited before. If it has, then we have a cycle. The recursion
  2500. // that got us here should take care of everything.
  2501. if( visited.insert(lib).second )
  2502. {
  2503. if( dep_map.find(lib) != dep_map.end() ) // does it have dependencies?
  2504. {
  2505. const DependencyList& dep_on = dep_map.find( lib )->second;
  2506. DependencyList::const_reverse_iterator i;
  2507. // To cater for recursive external libraries, we must emit
  2508. // duplicates on this link line *unless* they were emitted by
  2509. // some other node, in which case we assume that the recursion
  2510. // was resolved then. We making the simplifying assumption that
  2511. // any duplicates on a single link line are on purpose, and must
  2512. // be preserved.
  2513. // This variable will keep track of the libraries that were
  2514. // emitted directly from the current node, and not from a
  2515. // recursive call. This way, if we come across a library that
  2516. // has already been emitted, we repeat it iff it has been
  2517. // emitted here.
  2518. std::set<DependencyMap::key_type> emitted_here;
  2519. for( i = dep_on.rbegin(); i != dep_on.rend(); ++i )
  2520. {
  2521. if( emitted_here.find(*i) != emitted_here.end() )
  2522. {
  2523. // a repeat. Must emit.
  2524. emitted.insert(*i);
  2525. link_line.push_back( *i );
  2526. }
  2527. else
  2528. {
  2529. // Emit only if no-one else has
  2530. if( emitted.find(*i) == emitted.end() )
  2531. {
  2532. // emit dependencies
  2533. Emit( *i, dep_map, emitted, visited, link_line );
  2534. // emit self
  2535. emitted.insert(*i);
  2536. emitted_here.insert(*i);
  2537. link_line.push_back( *i );
  2538. }
  2539. }
  2540. }
  2541. }
  2542. }
  2543. }
  2544. //----------------------------------------------------------------------------
  2545. void cmTarget::GatherDependencies( const cmMakefile& mf,
  2546. const LibraryID& lib,
  2547. DependencyMap& dep_map)
  2548. {
  2549. // If the library is already in the dependency map, then it has
  2550. // already been fully processed.
  2551. if( dep_map.find(lib) != dep_map.end() )
  2552. {
  2553. return;
  2554. }
  2555. const char* deps = mf.GetDefinition( (lib.first+"_LIB_DEPENDS").c_str() );
  2556. if( deps && strcmp(deps,"") != 0 )
  2557. {
  2558. // Make sure this library is in the map, even if it has an empty
  2559. // set of dependencies. This distinguishes the case of explicitly
  2560. // no dependencies with that of unspecified dependencies.
  2561. dep_map[lib];
  2562. // Parse the dependency information, which is a set of
  2563. // type, library pairs separated by ";". There is always a trailing ";".
  2564. cmTarget::LinkLibraryType llt = cmTarget::GENERAL;
  2565. std::string depline = deps;
  2566. std::string::size_type start = 0;
  2567. std::string::size_type end;
  2568. end = depline.find( ";", start );
  2569. while( end != std::string::npos )
  2570. {
  2571. std::string l = depline.substr( start, end-start );
  2572. if( l.size() != 0 )
  2573. {
  2574. if (l == "debug")
  2575. {
  2576. llt = cmTarget::DEBUG;
  2577. }
  2578. else if (l == "optimized")
  2579. {
  2580. llt = cmTarget::OPTIMIZED;
  2581. }
  2582. else if (l == "general")
  2583. {
  2584. llt = cmTarget::GENERAL;
  2585. }
  2586. else
  2587. {
  2588. LibraryID lib2(l,llt);
  2589. this->InsertDependency( dep_map, lib, lib2);
  2590. this->GatherDependencies( mf, lib2, dep_map);
  2591. llt = cmTarget::GENERAL;
  2592. }
  2593. }
  2594. start = end+1; // skip the ;
  2595. end = depline.find( ";", start );
  2596. }
  2597. // cannot depend on itself
  2598. this->DeleteDependency( dep_map, lib, lib);
  2599. }
  2600. }
  2601. //----------------------------------------------------------------------------
  2602. void cmTarget::SetProperty(const char* prop, const char* value)
  2603. {
  2604. if (!prop)
  2605. {
  2606. return;
  2607. }
  2608. if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
  2609. {
  2610. cmListFileBacktrace lfbt;
  2611. this->Makefile->GetBacktrace(lfbt);
  2612. cmGeneratorExpression ge(lfbt);
  2613. deleteAndClear(this->Internal->IncludeDirectoriesEntries);
  2614. cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
  2615. this->Internal->IncludeDirectoriesEntries.push_back(
  2616. new cmTargetInternals::TargetPropertyEntry(cge));
  2617. return;
  2618. }
  2619. if(strcmp(prop,"COMPILE_OPTIONS") == 0)
  2620. {
  2621. cmListFileBacktrace lfbt;
  2622. this->Makefile->GetBacktrace(lfbt);
  2623. cmGeneratorExpression ge(lfbt);
  2624. deleteAndClear(this->Internal->CompileOptionsEntries);
  2625. cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
  2626. this->Internal->CompileOptionsEntries.push_back(
  2627. new cmTargetInternals::TargetPropertyEntry(cge));
  2628. return;
  2629. }
  2630. if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
  2631. {
  2632. cmOStringStream e;
  2633. e << "EXPORT_NAME property can't be set on imported targets (\""
  2634. << this->Name << "\")\n";
  2635. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
  2636. return;
  2637. }
  2638. if (strcmp(prop, "LINK_LIBRARIES") == 0)
  2639. {
  2640. this->Internal->LinkInterfacePropertyEntries.clear();
  2641. if (cmGeneratorExpression::IsValidTargetName(value)
  2642. || cmGeneratorExpression::Find(value) != std::string::npos)
  2643. {
  2644. cmListFileBacktrace lfbt;
  2645. this->Makefile->GetBacktrace(lfbt);
  2646. cmValueWithOrigin entry(value, lfbt);
  2647. this->Internal->LinkInterfacePropertyEntries.push_back(entry);
  2648. }
  2649. // Fall through
  2650. }
  2651. this->Properties.SetProperty(prop, value, cmProperty::TARGET);
  2652. this->MaybeInvalidatePropertyCache(prop);
  2653. }
  2654. //----------------------------------------------------------------------------
  2655. void cmTarget::AppendProperty(const char* prop, const char* value,
  2656. bool asString)
  2657. {
  2658. if (!prop)
  2659. {
  2660. return;
  2661. }
  2662. if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
  2663. {
  2664. cmListFileBacktrace lfbt;
  2665. this->Makefile->GetBacktrace(lfbt);
  2666. cmGeneratorExpression ge(lfbt);
  2667. this->Internal->IncludeDirectoriesEntries.push_back(
  2668. new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
  2669. return;
  2670. }
  2671. if(strcmp(prop,"COMPILE_OPTIONS") == 0)
  2672. {
  2673. cmListFileBacktrace lfbt;
  2674. this->Makefile->GetBacktrace(lfbt);
  2675. cmGeneratorExpression ge(lfbt);
  2676. this->Internal->CompileOptionsEntries.push_back(
  2677. new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
  2678. return;
  2679. }
  2680. if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
  2681. {
  2682. cmOStringStream e;
  2683. e << "EXPORT_NAME property can't be set on imported targets (\""
  2684. << this->Name << "\")\n";
  2685. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
  2686. return;
  2687. }
  2688. if (strcmp(prop, "LINK_LIBRARIES") == 0)
  2689. {
  2690. if (cmGeneratorExpression::IsValidTargetName(value)
  2691. || cmGeneratorExpression::Find(value) != std::string::npos)
  2692. {
  2693. cmListFileBacktrace lfbt;
  2694. this->Makefile->GetBacktrace(lfbt);
  2695. cmValueWithOrigin entry(value, lfbt);
  2696. this->Internal->LinkInterfacePropertyEntries.push_back(entry);
  2697. }
  2698. // Fall through
  2699. }
  2700. this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString);
  2701. this->MaybeInvalidatePropertyCache(prop);
  2702. }
  2703. //----------------------------------------------------------------------------
  2704. const char* cmTarget::GetExportName()
  2705. {
  2706. const char *exportName = this->GetProperty("EXPORT_NAME");
  2707. if (exportName && *exportName)
  2708. {
  2709. if (!cmGeneratorExpression::IsValidTargetName(exportName))
  2710. {
  2711. cmOStringStream e;
  2712. e << "EXPORT_NAME property \"" << exportName << "\" for \""
  2713. << this->GetName() << "\": is not valid.";
  2714. cmSystemTools::Error(e.str().c_str());
  2715. return "";
  2716. }
  2717. return exportName;
  2718. }
  2719. return this->GetName();
  2720. }
  2721. //----------------------------------------------------------------------------
  2722. void cmTarget::AppendBuildInterfaceIncludes()
  2723. {
  2724. if(this->GetType() != cmTarget::SHARED_LIBRARY &&
  2725. this->GetType() != cmTarget::STATIC_LIBRARY &&
  2726. this->GetType() != cmTarget::MODULE_LIBRARY &&
  2727. !this->IsExecutableWithExports())
  2728. {
  2729. return;
  2730. }
  2731. if (this->BuildInterfaceIncludesAppended)
  2732. {
  2733. return;
  2734. }
  2735. this->BuildInterfaceIncludesAppended = true;
  2736. if (this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE"))
  2737. {
  2738. const char *binDir = this->Makefile->GetStartOutputDirectory();
  2739. const char *srcDir = this->Makefile->GetStartDirectory();
  2740. const std::string dirs = std::string(binDir ? binDir : "")
  2741. + std::string(binDir ? ";" : "")
  2742. + std::string(srcDir ? srcDir : "");
  2743. if (!dirs.empty())
  2744. {
  2745. this->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES",
  2746. ("$<BUILD_INTERFACE:" + dirs + ">").c_str());
  2747. }
  2748. }
  2749. }
  2750. //----------------------------------------------------------------------------
  2751. void cmTarget::InsertInclude(const cmValueWithOrigin &entry,
  2752. bool before)
  2753. {
  2754. cmGeneratorExpression ge(entry.Backtrace);
  2755. std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position
  2756. = before ? this->Internal->IncludeDirectoriesEntries.begin()
  2757. : this->Internal->IncludeDirectoriesEntries.end();
  2758. this->Internal->IncludeDirectoriesEntries.insert(position,
  2759. new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value)));
  2760. }
  2761. //----------------------------------------------------------------------------
  2762. void cmTarget::InsertCompileOption(const cmValueWithOrigin &entry,
  2763. bool before)
  2764. {
  2765. cmGeneratorExpression ge(entry.Backtrace);
  2766. std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position
  2767. = before ? this->Internal->CompileOptionsEntries.begin()
  2768. : this->Internal->CompileOptionsEntries.end();
  2769. this->Internal->CompileOptionsEntries.insert(position,
  2770. new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value)));
  2771. }
  2772. //----------------------------------------------------------------------------
  2773. static void processIncludeDirectories(cmTarget *tgt,
  2774. const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
  2775. std::vector<std::string> &includes,
  2776. std::set<std::string> &uniqueIncludes,
  2777. cmGeneratorExpressionDAGChecker *dagChecker,
  2778. const char *config, bool debugIncludes)
  2779. {
  2780. cmMakefile *mf = tgt->GetMakefile();
  2781. for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
  2782. it = entries.begin(), end = entries.end(); it != end; ++it)
  2783. {
  2784. bool testIsOff = true;
  2785. bool cacheIncludes = false;
  2786. std::vector<std::string> entryIncludes = (*it)->CachedEntries;
  2787. if(!entryIncludes.empty())
  2788. {
  2789. testIsOff = false;
  2790. }
  2791. else
  2792. {
  2793. cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
  2794. config,
  2795. false,
  2796. tgt,
  2797. dagChecker),
  2798. entryIncludes);
  2799. if (mf->IsGeneratingBuildSystem()
  2800. && !(*it)->ge->GetHadContextSensitiveCondition())
  2801. {
  2802. cacheIncludes = true;
  2803. }
  2804. }
  2805. std::string usedIncludes;
  2806. for(std::vector<std::string>::iterator
  2807. li = entryIncludes.begin(); li != entryIncludes.end(); ++li)
  2808. {
  2809. cmTarget *dependentTarget =
  2810. mf->FindTargetToUse((*it)->TargetName.c_str());
  2811. const bool fromImported = dependentTarget
  2812. && dependentTarget->IsImported();
  2813. if (fromImported && !cmSystemTools::FileExists(li->c_str()))
  2814. {
  2815. cmOStringStream e;
  2816. e << "Imported target \"" << (*it)->TargetName << "\" includes "
  2817. "non-existent path\n \"" << *li << "\"\nin its "
  2818. "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n"
  2819. "* The path was deleted, renamed, or moved to another "
  2820. "location.\n"
  2821. "* An install or uninstall procedure did not complete "
  2822. "successfully.\n"
  2823. "* The installation package was faulty and references files it "
  2824. "does not provide.\n";
  2825. tgt->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
  2826. return;
  2827. }
  2828. if (!cmSystemTools::FileIsFullPath(li->c_str()))
  2829. {
  2830. cmOStringStream e;
  2831. bool noMessage = false;
  2832. cmake::MessageType messageType = cmake::FATAL_ERROR;
  2833. if (!(*it)->TargetName.empty())
  2834. {
  2835. e << "Target \"" << (*it)->TargetName << "\" contains relative "
  2836. "path in its INTERFACE_INCLUDE_DIRECTORIES:\n"
  2837. " \"" << *li << "\" ";
  2838. }
  2839. else
  2840. {
  2841. switch(tgt->GetPolicyStatusCMP0021())
  2842. {
  2843. case cmPolicies::WARN:
  2844. {
  2845. cmOStringStream w;
  2846. e << (mf->GetPolicies()
  2847. ->GetPolicyWarning(cmPolicies::CMP0021)) << "\n";
  2848. messageType = cmake::AUTHOR_WARNING;
  2849. }
  2850. break;
  2851. case cmPolicies::OLD:
  2852. noMessage = true;
  2853. case cmPolicies::REQUIRED_IF_USED:
  2854. case cmPolicies::REQUIRED_ALWAYS:
  2855. case cmPolicies::NEW:
  2856. // Issue the fatal message.
  2857. break;
  2858. }
  2859. e << "Found relative path while evaluating include directories of "
  2860. "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n";
  2861. }
  2862. if (!noMessage)
  2863. {
  2864. tgt->GetMakefile()->IssueMessage(messageType, e.str().c_str());
  2865. return;
  2866. }
  2867. }
  2868. if (testIsOff && !cmSystemTools::IsOff(li->c_str()))
  2869. {
  2870. cmSystemTools::ConvertToUnixSlashes(*li);
  2871. }
  2872. std::string inc = *li;
  2873. if(uniqueIncludes.insert(inc).second)
  2874. {
  2875. includes.push_back(inc);
  2876. if (debugIncludes)
  2877. {
  2878. usedIncludes += " * " + inc + "\n";
  2879. }
  2880. }
  2881. }
  2882. if (cacheIncludes)
  2883. {
  2884. (*it)->CachedEntries = entryIncludes;
  2885. }
  2886. if (!usedIncludes.empty())
  2887. {
  2888. mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
  2889. std::string("Used includes for target ")
  2890. + tgt->GetName() + ":\n"
  2891. + usedIncludes, (*it)->ge->GetBacktrace());
  2892. }
  2893. }
  2894. }
  2895. //----------------------------------------------------------------------------
  2896. std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config)
  2897. {
  2898. std::vector<std::string> includes;
  2899. std::set<std::string> uniqueIncludes;
  2900. cmListFileBacktrace lfbt;
  2901. cmGeneratorExpressionDAGChecker dagChecker(lfbt,
  2902. this->GetName(),
  2903. "INCLUDE_DIRECTORIES", 0, 0);
  2904. this->AppendBuildInterfaceIncludes();
  2905. std::vector<std::string> debugProperties;
  2906. const char *debugProp =
  2907. this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
  2908. if (debugProp)
  2909. {
  2910. cmSystemTools::ExpandListArgument(debugProp, debugProperties);
  2911. }
  2912. bool debugIncludes = !this->DebugIncludesDone
  2913. && std::find(debugProperties.begin(),
  2914. debugProperties.end(),
  2915. "INCLUDE_DIRECTORIES")
  2916. != debugProperties.end();
  2917. if (this->Makefile->IsGeneratingBuildSystem())
  2918. {
  2919. this->DebugIncludesDone = true;
  2920. }
  2921. processIncludeDirectories(this,
  2922. this->Internal->IncludeDirectoriesEntries,
  2923. includes,
  2924. uniqueIncludes,
  2925. &dagChecker,
  2926. config,
  2927. debugIncludes);
  2928. std::string configString = config ? config : "";
  2929. if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString])
  2930. {
  2931. for (std::vector<cmValueWithOrigin>::const_iterator
  2932. it = this->Internal->LinkInterfacePropertyEntries.begin(),
  2933. end = this->Internal->LinkInterfacePropertyEntries.end();
  2934. it != end; ++it)
  2935. {
  2936. {
  2937. cmGeneratorExpression ge(lfbt);
  2938. cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
  2939. ge.Parse(it->Value);
  2940. std::string result = cge->Evaluate(this->Makefile, config,
  2941. false, this, 0, 0);
  2942. if (!this->Makefile->FindTargetToUse(result.c_str()))
  2943. {
  2944. continue;
  2945. }
  2946. }
  2947. std::string includeGenex = "$<TARGET_PROPERTY:" +
  2948. it->Value + ",INTERFACE_INCLUDE_DIRECTORIES>";
  2949. if (cmGeneratorExpression::Find(it->Value) != std::string::npos)
  2950. {
  2951. // Because it->Value is a generator expression, ensure that it
  2952. // evaluates to the non-empty string before being used in the
  2953. // TARGET_PROPERTY expression.
  2954. includeGenex = "$<$<BOOL:" + it->Value + ">:" + includeGenex + ">";
  2955. }
  2956. cmGeneratorExpression ge(it->Backtrace);
  2957. cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
  2958. includeGenex);
  2959. this->Internal
  2960. ->CachedLinkInterfaceIncludeDirectoriesEntries[configString].push_back(
  2961. new cmTargetInternals::TargetPropertyEntry(cge,
  2962. it->Value));
  2963. }
  2964. }
  2965. processIncludeDirectories(this,
  2966. this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[configString],
  2967. includes,
  2968. uniqueIncludes,
  2969. &dagChecker,
  2970. config,
  2971. debugIncludes);
  2972. if (!this->Makefile->IsGeneratingBuildSystem())
  2973. {
  2974. deleteAndClear(
  2975. this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries);
  2976. }
  2977. else
  2978. {
  2979. this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString]
  2980. = true;
  2981. }
  2982. return includes;
  2983. }
  2984. //----------------------------------------------------------------------------
  2985. static void processCompileOptions(cmTarget *tgt,
  2986. const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
  2987. std::vector<std::string> &options,
  2988. std::set<std::string> &uniqueOptions,
  2989. cmGeneratorExpressionDAGChecker *dagChecker,
  2990. const char *config, bool debugOptions)
  2991. {
  2992. cmMakefile *mf = tgt->GetMakefile();
  2993. for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
  2994. it = entries.begin(), end = entries.end(); it != end; ++it)
  2995. {
  2996. bool cacheOptions = false;
  2997. std::vector<std::string> entryOptions = (*it)->CachedEntries;
  2998. if(entryOptions.empty())
  2999. {
  3000. cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
  3001. config,
  3002. false,
  3003. tgt,
  3004. dagChecker),
  3005. entryOptions);
  3006. if (mf->IsGeneratingBuildSystem()
  3007. && !(*it)->ge->GetHadContextSensitiveCondition())
  3008. {
  3009. cacheOptions = true;
  3010. }
  3011. }
  3012. std::string usedOptions;
  3013. for(std::vector<std::string>::iterator
  3014. li = entryOptions.begin(); li != entryOptions.end(); ++li)
  3015. {
  3016. std::string opt = *li;
  3017. if(uniqueOptions.insert(opt).second)
  3018. {
  3019. options.push_back(opt);
  3020. if (debugOptions)
  3021. {
  3022. usedOptions += " * " + opt + "\n";
  3023. }
  3024. }
  3025. }
  3026. if (cacheOptions)
  3027. {
  3028. (*it)->CachedEntries = entryOptions;
  3029. }
  3030. if (!usedOptions.empty())
  3031. {
  3032. mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
  3033. std::string("Used compile options for target ")
  3034. + tgt->GetName() + ":\n"
  3035. + usedOptions, (*it)->ge->GetBacktrace());
  3036. }
  3037. }
  3038. }
  3039. //----------------------------------------------------------------------------
  3040. void cmTarget::GetCompileOptions(std::vector<std::string> &result,
  3041. const char *config)
  3042. {
  3043. std::set<std::string> uniqueOptions;
  3044. cmListFileBacktrace lfbt;
  3045. cmGeneratorExpressionDAGChecker dagChecker(lfbt,
  3046. this->GetName(),
  3047. "COMPILE_OPTIONS", 0, 0);
  3048. std::vector<std::string> debugProperties;
  3049. const char *debugProp =
  3050. this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
  3051. if (debugProp)
  3052. {
  3053. cmSystemTools::ExpandListArgument(debugProp, debugProperties);
  3054. }
  3055. bool debugOptions = !this->DebugCompileOptionsDone
  3056. && std::find(debugProperties.begin(),
  3057. debugProperties.end(),
  3058. "COMPILE_OPTIONS")
  3059. != debugProperties.end();
  3060. if (this->Makefile->IsGeneratingBuildSystem())
  3061. {
  3062. this->DebugCompileOptionsDone = true;
  3063. }
  3064. processCompileOptions(this,
  3065. this->Internal->CompileOptionsEntries,
  3066. result,
  3067. uniqueOptions,
  3068. &dagChecker,
  3069. config,
  3070. debugOptions);
  3071. std::string configString = config ? config : "";
  3072. if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[configString])
  3073. {
  3074. for (std::vector<cmValueWithOrigin>::const_iterator
  3075. it = this->Internal->LinkInterfacePropertyEntries.begin(),
  3076. end = this->Internal->LinkInterfacePropertyEntries.end();
  3077. it != end; ++it)
  3078. {
  3079. {
  3080. cmGeneratorExpression ge(lfbt);
  3081. cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
  3082. ge.Parse(it->Value);
  3083. std::string targetResult = cge->Evaluate(this->Makefile, config,
  3084. false, this, 0, 0);
  3085. if (!this->Makefile->FindTargetToUse(targetResult.c_str()))
  3086. {
  3087. continue;
  3088. }
  3089. }
  3090. std::string optionGenex = "$<TARGET_PROPERTY:" +
  3091. it->Value + ",INTERFACE_COMPILE_OPTIONS>";
  3092. if (cmGeneratorExpression::Find(it->Value) != std::string::npos)
  3093. {
  3094. // Because it->Value is a generator expression, ensure that it
  3095. // evaluates to the non-empty string before being used in the
  3096. // TARGET_PROPERTY expression.
  3097. optionGenex = "$<$<BOOL:" + it->Value + ">:" + optionGenex + ">";
  3098. }
  3099. cmGeneratorExpression ge(it->Backtrace);
  3100. cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
  3101. optionGenex);
  3102. this->Internal
  3103. ->CachedLinkInterfaceCompileOptionsEntries[configString].push_back(
  3104. new cmTargetInternals::TargetPropertyEntry(cge,
  3105. it->Value));
  3106. }
  3107. }
  3108. processCompileOptions(this,
  3109. this->Internal->CachedLinkInterfaceCompileOptionsEntries[configString],
  3110. result,
  3111. uniqueOptions,
  3112. &dagChecker,
  3113. config,
  3114. debugOptions);
  3115. if (!this->Makefile->IsGeneratingBuildSystem())
  3116. {
  3117. deleteAndClear(this->Internal->CachedLinkInterfaceCompileOptionsEntries);
  3118. }
  3119. else
  3120. {
  3121. this->Internal->CacheLinkInterfaceCompileOptionsDone[configString] = true;
  3122. }
  3123. }
  3124. //----------------------------------------------------------------------------
  3125. std::string cmTarget::GetCompileDefinitions(const char *config)
  3126. {
  3127. const char *configProp = 0;
  3128. if (config)
  3129. {
  3130. std::string configPropName;
  3131. configPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config);
  3132. configProp = this->GetProperty(configPropName.c_str());
  3133. }
  3134. const char *noconfigProp = this->GetProperty("COMPILE_DEFINITIONS");
  3135. cmListFileBacktrace lfbt;
  3136. cmGeneratorExpressionDAGChecker dagChecker(lfbt,
  3137. this->GetName(),
  3138. "COMPILE_DEFINITIONS", 0, 0);
  3139. std::string defsString = (noconfigProp ? noconfigProp : "");
  3140. if (configProp && noconfigProp)
  3141. {
  3142. defsString += ";";
  3143. }
  3144. defsString += (configProp ? configProp : "");
  3145. cmGeneratorExpression ge(lfbt);
  3146. std::string result = ge.Parse(defsString.c_str())->Evaluate(this->Makefile,
  3147. config,
  3148. false,
  3149. this,
  3150. &dagChecker);
  3151. std::vector<std::string> libs;
  3152. this->GetDirectLinkLibraries(config, libs, this);
  3153. if (libs.empty())
  3154. {
  3155. return result;
  3156. }
  3157. std::string sep;
  3158. std::string depString;
  3159. for (std::vector<std::string>::const_iterator it = libs.begin();
  3160. it != libs.end(); ++it)
  3161. {
  3162. if ((cmGeneratorExpression::IsValidTargetName(it->c_str())
  3163. || cmGeneratorExpression::Find(it->c_str()) != std::string::npos)
  3164. && this->Makefile->FindTargetToUse(it->c_str()))
  3165. {
  3166. depString += sep + "$<TARGET_PROPERTY:"
  3167. + *it + ",INTERFACE_COMPILE_DEFINITIONS>";
  3168. sep = ";";
  3169. }
  3170. }
  3171. std::string configString = config ? config : "";
  3172. if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString])
  3173. {
  3174. cmGeneratorExpression ge2(lfbt);
  3175. cmsys::auto_ptr<cmCompiledGeneratorExpression> cge2 =
  3176. ge2.Parse(depString);
  3177. this->Internal->CachedLinkInterfaceCompileDefinitions[configString] =
  3178. cge2->Evaluate(this->Makefile,
  3179. config,
  3180. false,
  3181. this,
  3182. &dagChecker);
  3183. }
  3184. if (!this->Internal->CachedLinkInterfaceCompileDefinitions[configString]
  3185. .empty())
  3186. {
  3187. result += (result.empty() ? "" : ";")
  3188. + this->Internal->CachedLinkInterfaceCompileDefinitions[configString];
  3189. }
  3190. if (!this->Makefile->IsGeneratingBuildSystem())
  3191. {
  3192. this->Internal->CachedLinkInterfaceCompileDefinitions[configString] = "";
  3193. }
  3194. else
  3195. {
  3196. this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString]
  3197. = true;
  3198. }
  3199. return result;
  3200. }
  3201. //----------------------------------------------------------------------------
  3202. void cmTarget::MaybeInvalidatePropertyCache(const char* prop)
  3203. {
  3204. // Wipe out maps caching information affected by this property.
  3205. if(this->IsImported() && strncmp(prop, "IMPORTED", 8) == 0)
  3206. {
  3207. this->Internal->ImportInfoMap.clear();
  3208. }
  3209. if(!this->IsImported() && strncmp(prop, "LINK_INTERFACE_", 15) == 0)
  3210. {
  3211. this->ClearLinkMaps();
  3212. }
  3213. }
  3214. //----------------------------------------------------------------------------
  3215. static void cmTargetCheckLINK_INTERFACE_LIBRARIES(
  3216. const char* prop, const char* value, cmMakefile* context, bool imported
  3217. )
  3218. {
  3219. // Look for link-type keywords in the value.
  3220. static cmsys::RegularExpression
  3221. keys("(^|;)(debug|optimized|general)(;|$)");
  3222. if(!keys.find(value))
  3223. {
  3224. return;
  3225. }
  3226. // Support imported and non-imported versions of the property.
  3227. const char* base = (imported?
  3228. "IMPORTED_LINK_INTERFACE_LIBRARIES" :
  3229. "LINK_INTERFACE_LIBRARIES");
  3230. // Report an error.
  3231. cmOStringStream e;
  3232. e << "Property " << prop << " may not contain link-type keyword \""
  3233. << keys.match(2) << "\". "
  3234. << "The " << base << " property has a per-configuration "
  3235. << "version called " << base << "_<CONFIG> which may be "
  3236. << "used to specify per-configuration rules.";
  3237. if(!imported)
  3238. {
  3239. e << " "
  3240. << "Alternatively, an IMPORTED library may be created, configured "
  3241. << "with a per-configuration location, and then named in the "
  3242. << "property value. "
  3243. << "See the add_library command's IMPORTED mode for details."
  3244. << "\n"
  3245. << "If you have a list of libraries that already contains the "
  3246. << "keyword, use the target_link_libraries command with its "
  3247. << "LINK_INTERFACE_LIBRARIES mode to set the property. "
  3248. << "The command automatically recognizes link-type keywords and sets "
  3249. << "the LINK_INTERFACE_LIBRARIES and LINK_INTERFACE_LIBRARIES_DEBUG "
  3250. << "properties accordingly.";
  3251. }
  3252. context->IssueMessage(cmake::FATAL_ERROR, e.str());
  3253. }
  3254. //----------------------------------------------------------------------------
  3255. static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value,
  3256. cmMakefile* context)
  3257. {
  3258. // Look for link-type keywords in the value.
  3259. static cmsys::RegularExpression
  3260. keys("(^|;)(debug|optimized|general)(;|$)");
  3261. if(!keys.find(value))
  3262. {
  3263. return;
  3264. }
  3265. // Report an error.
  3266. cmOStringStream e;
  3267. e << "Property INTERFACE_LINK_LIBRARIES may not contain link-type "
  3268. "keyword \"" << keys.match(2) << "\". The INTERFACE_LINK_LIBRARIES "
  3269. "property may contain configuration-sensitive generator-expressions "
  3270. "which may be used to specify per-configuration rules.";
  3271. context->IssueMessage(cmake::FATAL_ERROR, e.str());
  3272. }
  3273. //----------------------------------------------------------------------------
  3274. void cmTarget::CheckProperty(const char* prop, cmMakefile* context)
  3275. {
  3276. // Certain properties need checking.
  3277. if(strncmp(prop, "LINK_INTERFACE_LIBRARIES", 24) == 0)
  3278. {
  3279. if(const char* value = this->GetProperty(prop))
  3280. {
  3281. cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, false);
  3282. }
  3283. }
  3284. if(strncmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES", 33) == 0)
  3285. {
  3286. if(const char* value = this->GetProperty(prop))
  3287. {
  3288. cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, true);
  3289. }
  3290. }
  3291. if(strncmp(prop, "INTERFACE_LINK_LIBRARIES", 24) == 0)
  3292. {
  3293. if(const char* value = this->GetProperty(prop))
  3294. {
  3295. cmTargetCheckINTERFACE_LINK_LIBRARIES(value, context);
  3296. }
  3297. }
  3298. }
  3299. //----------------------------------------------------------------------------
  3300. void cmTarget::MarkAsImported()
  3301. {
  3302. this->IsImportedTarget = true;
  3303. }
  3304. //----------------------------------------------------------------------------
  3305. bool cmTarget::HaveWellDefinedOutputFiles()
  3306. {
  3307. return
  3308. this->GetType() == cmTarget::STATIC_LIBRARY ||
  3309. this->GetType() == cmTarget::SHARED_LIBRARY ||
  3310. this->GetType() == cmTarget::MODULE_LIBRARY ||
  3311. this->GetType() == cmTarget::EXECUTABLE;
  3312. }
  3313. //----------------------------------------------------------------------------
  3314. cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config)
  3315. {
  3316. // There is no output information for imported targets.
  3317. if(this->IsImported())
  3318. {
  3319. return 0;
  3320. }
  3321. // Only libraries and executables have well-defined output files.
  3322. if(!this->HaveWellDefinedOutputFiles())
  3323. {
  3324. std::string msg = "cmTarget::GetOutputInfo called for ";
  3325. msg += this->GetName();
  3326. msg += " which has type ";
  3327. msg += cmTarget::GetTargetTypeName(this->GetType());
  3328. this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg);
  3329. abort();
  3330. return 0;
  3331. }
  3332. // Lookup/compute/cache the output information for this configuration.
  3333. std::string config_upper;
  3334. if(config && *config)
  3335. {
  3336. config_upper = cmSystemTools::UpperCase(config);
  3337. }
  3338. typedef cmTargetInternals::OutputInfoMapType OutputInfoMapType;
  3339. OutputInfoMapType::const_iterator i =
  3340. this->Internal->OutputInfoMap.find(config_upper);
  3341. if(i == this->Internal->OutputInfoMap.end())
  3342. {
  3343. OutputInfo info;
  3344. this->ComputeOutputDir(config, false, info.OutDir);
  3345. this->ComputeOutputDir(config, true, info.ImpDir);
  3346. if(!this->ComputePDBOutputDir(config, info.PdbDir))
  3347. {
  3348. info.PdbDir = info.OutDir;
  3349. }
  3350. OutputInfoMapType::value_type entry(config_upper, info);
  3351. i = this->Internal->OutputInfoMap.insert(entry).first;
  3352. }
  3353. return &i->second;
  3354. }
  3355. //----------------------------------------------------------------------------
  3356. std::string cmTarget::GetDirectory(const char* config, bool implib)
  3357. {
  3358. if (this->IsImported())
  3359. {
  3360. // Return the directory from which the target is imported.
  3361. return
  3362. cmSystemTools::GetFilenamePath(
  3363. this->ImportedGetFullPath(config, implib));
  3364. }
  3365. else if(OutputInfo const* info = this->GetOutputInfo(config))
  3366. {
  3367. // Return the directory in which the target will be built.
  3368. return implib? info->ImpDir : info->OutDir;
  3369. }
  3370. return "";
  3371. }
  3372. //----------------------------------------------------------------------------
  3373. std::string cmTarget::GetPDBDirectory(const char* config)
  3374. {
  3375. if(OutputInfo const* info = this->GetOutputInfo(config))
  3376. {
  3377. // Return the directory in which the target will be built.
  3378. return info->PdbDir;
  3379. }
  3380. return "";
  3381. }
  3382. //----------------------------------------------------------------------------
  3383. const char* cmTarget::GetLocation(const char* config)
  3384. {
  3385. if (this->IsImported())
  3386. {
  3387. return this->ImportedGetLocation(config);
  3388. }
  3389. else
  3390. {
  3391. return this->NormalGetLocation(config);
  3392. }
  3393. }
  3394. //----------------------------------------------------------------------------
  3395. const char* cmTarget::ImportedGetLocation(const char* config)
  3396. {
  3397. this->Location = this->ImportedGetFullPath(config, false);
  3398. return this->Location.c_str();
  3399. }
  3400. //----------------------------------------------------------------------------
  3401. const char* cmTarget::NormalGetLocation(const char* config)
  3402. {
  3403. // Handle the configuration-specific case first.
  3404. if(config)
  3405. {
  3406. this->Location = this->GetFullPath(config, false);
  3407. return this->Location.c_str();
  3408. }
  3409. // Now handle the deprecated build-time configuration location.
  3410. this->Location = this->GetDirectory();
  3411. const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR");
  3412. if(cfgid && strcmp(cfgid, ".") != 0)
  3413. {
  3414. this->Location += "/";
  3415. this->Location += cfgid;
  3416. }
  3417. if(this->IsAppBundleOnApple())
  3418. {
  3419. std::string macdir = this->BuildMacContentDirectory("", config, false);
  3420. if(!macdir.empty())
  3421. {
  3422. this->Location += "/";
  3423. this->Location += macdir;
  3424. }
  3425. }
  3426. this->Location += "/";
  3427. this->Location += this->GetFullName(config, false);
  3428. return this->Location.c_str();
  3429. }
  3430. //----------------------------------------------------------------------------
  3431. void cmTarget::GetTargetVersion(int& major, int& minor)
  3432. {
  3433. int patch;
  3434. this->GetTargetVersion(false, major, minor, patch);
  3435. }
  3436. //----------------------------------------------------------------------------
  3437. void cmTarget::GetTargetVersion(bool soversion,
  3438. int& major, int& minor, int& patch)
  3439. {
  3440. // Set the default values.
  3441. major = 0;
  3442. minor = 0;
  3443. patch = 0;
  3444. // Look for a VERSION or SOVERSION property.
  3445. const char* prop = soversion? "SOVERSION" : "VERSION";
  3446. if(const char* version = this->GetProperty(prop))
  3447. {
  3448. // Try to parse the version number and store the results that were
  3449. // successfully parsed.
  3450. int parsed_major;
  3451. int parsed_minor;
  3452. int parsed_patch;
  3453. switch(sscanf(version, "%d.%d.%d",
  3454. &parsed_major, &parsed_minor, &parsed_patch))
  3455. {
  3456. case 3: patch = parsed_patch; // no break!
  3457. case 2: minor = parsed_minor; // no break!
  3458. case 1: major = parsed_major; // no break!
  3459. default: break;
  3460. }
  3461. }
  3462. }
  3463. //----------------------------------------------------------------------------
  3464. const char* cmTarget::GetFeature(const char* feature, const char* config)
  3465. {
  3466. if(config && *config)
  3467. {
  3468. std::string featureConfig = feature;
  3469. featureConfig += "_";
  3470. featureConfig += cmSystemTools::UpperCase(config);
  3471. if(const char* value = this->GetProperty(featureConfig.c_str()))
  3472. {
  3473. return value;
  3474. }
  3475. }
  3476. if(const char* value = this->GetProperty(feature))
  3477. {
  3478. return value;
  3479. }
  3480. return this->Makefile->GetFeature(feature, config);
  3481. }
  3482. //----------------------------------------------------------------------------
  3483. const char *cmTarget::GetProperty(const char* prop)
  3484. {
  3485. return this->GetProperty(prop, cmProperty::TARGET);
  3486. }
  3487. //----------------------------------------------------------------------------
  3488. const char *cmTarget::GetProperty(const char* prop,
  3489. cmProperty::ScopeType scope)
  3490. {
  3491. if(!prop)
  3492. {
  3493. return 0;
  3494. }
  3495. // Watch for special "computed" properties that are dependent on
  3496. // other properties or variables. Always recompute them.
  3497. if(this->GetType() == cmTarget::EXECUTABLE ||
  3498. this->GetType() == cmTarget::STATIC_LIBRARY ||
  3499. this->GetType() == cmTarget::SHARED_LIBRARY ||
  3500. this->GetType() == cmTarget::MODULE_LIBRARY ||
  3501. this->GetType() == cmTarget::UNKNOWN_LIBRARY)
  3502. {
  3503. if(strcmp(prop,"LOCATION") == 0)
  3504. {
  3505. // Set the LOCATION property of the target.
  3506. //
  3507. // For an imported target this is the location of an arbitrary
  3508. // available configuration.
  3509. //
  3510. // For a non-imported target this is deprecated because it
  3511. // cannot take into account the per-configuration name of the
  3512. // target because the configuration type may not be known at
  3513. // CMake time.
  3514. this->SetProperty("LOCATION", this->GetLocation(0));
  3515. }
  3516. // Support "LOCATION_<CONFIG>".
  3517. if(strncmp(prop, "LOCATION_", 9) == 0)
  3518. {
  3519. std::string configName = prop+9;
  3520. this->SetProperty(prop, this->GetLocation(configName.c_str()));
  3521. }
  3522. else
  3523. {
  3524. // Support "<CONFIG>_LOCATION" for compatiblity.
  3525. int len = static_cast<int>(strlen(prop));
  3526. if(len > 9 && strcmp(prop+len-9, "_LOCATION") == 0)
  3527. {
  3528. std::string configName(prop, len-9);
  3529. if(configName != "IMPORTED")
  3530. {
  3531. this->SetProperty(prop, this->GetLocation(configName.c_str()));
  3532. }
  3533. }
  3534. }
  3535. }
  3536. if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
  3537. {
  3538. static std::string output;
  3539. output = "";
  3540. std::string sep;
  3541. typedef cmTargetInternals::TargetPropertyEntry
  3542. TargetPropertyEntry;
  3543. for (std::vector<TargetPropertyEntry*>::const_iterator
  3544. it = this->Internal->IncludeDirectoriesEntries.begin(),
  3545. end = this->Internal->IncludeDirectoriesEntries.end();
  3546. it != end; ++it)
  3547. {
  3548. output += sep;
  3549. output += (*it)->ge->GetInput();
  3550. sep = ";";
  3551. }
  3552. return output.c_str();
  3553. }
  3554. if(strcmp(prop,"COMPILE_OPTIONS") == 0)
  3555. {
  3556. static std::string output;
  3557. output = "";
  3558. std::string sep;
  3559. typedef cmTargetInternals::TargetPropertyEntry
  3560. TargetPropertyEntry;
  3561. for (std::vector<TargetPropertyEntry*>::const_iterator
  3562. it = this->Internal->CompileOptionsEntries.begin(),
  3563. end = this->Internal->CompileOptionsEntries.end();
  3564. it != end; ++it)
  3565. {
  3566. output += sep;
  3567. output += (*it)->ge->GetInput();
  3568. sep = ";";
  3569. }
  3570. return output.c_str();
  3571. }
  3572. if (strcmp(prop,"IMPORTED") == 0)
  3573. {
  3574. return this->IsImported()?"TRUE":"FALSE";
  3575. }
  3576. if(!strcmp(prop,"SOURCES"))
  3577. {
  3578. cmOStringStream ss;
  3579. const char* sep = "";
  3580. for(std::vector<cmSourceFile*>::const_iterator
  3581. i = this->SourceFiles.begin();
  3582. i != this->SourceFiles.end(); ++i)
  3583. {
  3584. // Separate from the previous list entries.
  3585. ss << sep;
  3586. sep = ";";
  3587. // Construct what is known about this source file location.
  3588. cmSourceFileLocation const& location = (*i)->GetLocation();
  3589. std::string sname = location.GetDirectory();
  3590. if(!sname.empty())
  3591. {
  3592. sname += "/";
  3593. }
  3594. sname += location.GetName();
  3595. // Append this list entry.
  3596. ss << sname;
  3597. }
  3598. this->SetProperty("SOURCES", ss.str().c_str());
  3599. }
  3600. // the type property returns what type the target is
  3601. if (!strcmp(prop,"TYPE"))
  3602. {
  3603. return cmTarget::GetTargetTypeName(this->GetType());
  3604. }
  3605. bool chain = false;
  3606. const char *retVal =
  3607. this->Properties.GetPropertyValue(prop, scope, chain);
  3608. if (chain)
  3609. {
  3610. return this->Makefile->GetProperty(prop,scope);
  3611. }
  3612. return retVal;
  3613. }
  3614. //----------------------------------------------------------------------------
  3615. bool cmTarget::GetPropertyAsBool(const char* prop)
  3616. {
  3617. return cmSystemTools::IsOn(this->GetProperty(prop));
  3618. }
  3619. //----------------------------------------------------------------------------
  3620. class cmTargetCollectLinkLanguages
  3621. {
  3622. public:
  3623. cmTargetCollectLinkLanguages(cmTarget* target, const char* config,
  3624. std::set<cmStdString>& languages,
  3625. cmTarget* head):
  3626. Config(config), Languages(languages), HeadTarget(head)
  3627. { this->Visited.insert(target); }
  3628. void Visit(cmTarget* target)
  3629. {
  3630. if(!target || !this->Visited.insert(target).second)
  3631. {
  3632. return;
  3633. }
  3634. cmTarget::LinkInterface const* iface =
  3635. target->GetLinkInterface(this->Config, this->HeadTarget);
  3636. if(!iface) { return; }
  3637. for(std::vector<std::string>::const_iterator
  3638. li = iface->Languages.begin(); li != iface->Languages.end(); ++li)
  3639. {
  3640. this->Languages.insert(*li);
  3641. }
  3642. cmMakefile* mf = target->GetMakefile();
  3643. for(std::vector<std::string>::const_iterator
  3644. li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li)
  3645. {
  3646. this->Visit(mf->FindTargetToUse(li->c_str()));
  3647. }
  3648. }
  3649. private:
  3650. const char* Config;
  3651. std::set<cmStdString>& Languages;
  3652. cmTarget* HeadTarget;
  3653. std::set<cmTarget*> Visited;
  3654. };
  3655. //----------------------------------------------------------------------------
  3656. const char* cmTarget::GetLinkerLanguage(const char* config, cmTarget *head)
  3657. {
  3658. cmTarget *headTarget = head ? head : this;
  3659. const char* lang = this->GetLinkClosure(config, headTarget)
  3660. ->LinkerLanguage.c_str();
  3661. return *lang? lang : 0;
  3662. }
  3663. //----------------------------------------------------------------------------
  3664. cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const char* config,
  3665. cmTarget *head)
  3666. {
  3667. TargetConfigPair key(head, cmSystemTools::UpperCase(config ? config : ""));
  3668. cmTargetInternals::LinkClosureMapType::iterator
  3669. i = this->Internal->LinkClosureMap.find(key);
  3670. if(i == this->Internal->LinkClosureMap.end())
  3671. {
  3672. LinkClosure lc;
  3673. this->ComputeLinkClosure(config, lc, head);
  3674. cmTargetInternals::LinkClosureMapType::value_type entry(key, lc);
  3675. i = this->Internal->LinkClosureMap.insert(entry).first;
  3676. }
  3677. return &i->second;
  3678. }
  3679. //----------------------------------------------------------------------------
  3680. class cmTargetSelectLinker
  3681. {
  3682. int Preference;
  3683. cmTarget* Target;
  3684. cmMakefile* Makefile;
  3685. cmGlobalGenerator* GG;
  3686. std::set<cmStdString> Preferred;
  3687. public:
  3688. cmTargetSelectLinker(cmTarget* target): Preference(0), Target(target)
  3689. {
  3690. this->Makefile = this->Target->GetMakefile();
  3691. this->GG = this->Makefile->GetLocalGenerator()->GetGlobalGenerator();
  3692. }
  3693. void Consider(const char* lang)
  3694. {
  3695. int preference = this->GG->GetLinkerPreference(lang);
  3696. if(preference > this->Preference)
  3697. {
  3698. this->Preference = preference;
  3699. this->Preferred.clear();
  3700. }
  3701. if(preference == this->Preference)
  3702. {
  3703. this->Preferred.insert(lang);
  3704. }
  3705. }
  3706. std::string Choose()
  3707. {
  3708. if(this->Preferred.empty())
  3709. {
  3710. return "";
  3711. }
  3712. else if(this->Preferred.size() > 1)
  3713. {
  3714. cmOStringStream e;
  3715. e << "Target " << this->Target->GetName()
  3716. << " contains multiple languages with the highest linker preference"
  3717. << " (" << this->Preference << "):\n";
  3718. for(std::set<cmStdString>::const_iterator
  3719. li = this->Preferred.begin(); li != this->Preferred.end(); ++li)
  3720. {
  3721. e << " " << *li << "\n";
  3722. }
  3723. e << "Set the LINKER_LANGUAGE property for this target.";
  3724. cmake* cm = this->Makefile->GetCMakeInstance();
  3725. cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
  3726. this->Target->GetBacktrace());
  3727. }
  3728. return *this->Preferred.begin();
  3729. }
  3730. };
  3731. //----------------------------------------------------------------------------
  3732. void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc,
  3733. cmTarget *head)
  3734. {
  3735. // Get languages built in this target.
  3736. std::set<cmStdString> languages;
  3737. LinkImplementation const* impl = this->GetLinkImplementation(config, head);
  3738. for(std::vector<std::string>::const_iterator li = impl->Languages.begin();
  3739. li != impl->Languages.end(); ++li)
  3740. {
  3741. languages.insert(*li);
  3742. }
  3743. // Add interface languages from linked targets.
  3744. cmTargetCollectLinkLanguages cll(this, config, languages, head);
  3745. for(std::vector<std::string>::const_iterator li = impl->Libraries.begin();
  3746. li != impl->Libraries.end(); ++li)
  3747. {
  3748. cll.Visit(this->Makefile->FindTargetToUse(li->c_str()));
  3749. }
  3750. // Store the transitive closure of languages.
  3751. for(std::set<cmStdString>::const_iterator li = languages.begin();
  3752. li != languages.end(); ++li)
  3753. {
  3754. lc.Languages.push_back(*li);
  3755. }
  3756. // Choose the language whose linker should be used.
  3757. if(this->GetProperty("HAS_CXX"))
  3758. {
  3759. lc.LinkerLanguage = "CXX";
  3760. }
  3761. else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE"))
  3762. {
  3763. lc.LinkerLanguage = linkerLang;
  3764. }
  3765. else
  3766. {
  3767. // Find the language with the highest preference value.
  3768. cmTargetSelectLinker tsl(this);
  3769. // First select from the languages compiled directly in this target.
  3770. for(std::vector<std::string>::const_iterator li = impl->Languages.begin();
  3771. li != impl->Languages.end(); ++li)
  3772. {
  3773. tsl.Consider(li->c_str());
  3774. }
  3775. // Now consider languages that propagate from linked targets.
  3776. for(std::set<cmStdString>::const_iterator sit = languages.begin();
  3777. sit != languages.end(); ++sit)
  3778. {
  3779. std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES";
  3780. if(this->Makefile->IsOn(propagates.c_str()))
  3781. {
  3782. tsl.Consider(sit->c_str());
  3783. }
  3784. }
  3785. lc.LinkerLanguage = tsl.Choose();
  3786. }
  3787. }
  3788. //----------------------------------------------------------------------------
  3789. const char* cmTarget::GetSuffixVariableInternal(bool implib)
  3790. {
  3791. switch(this->GetType())
  3792. {
  3793. case cmTarget::STATIC_LIBRARY:
  3794. return "CMAKE_STATIC_LIBRARY_SUFFIX";
  3795. case cmTarget::SHARED_LIBRARY:
  3796. return (implib
  3797. ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
  3798. : "CMAKE_SHARED_LIBRARY_SUFFIX");
  3799. case cmTarget::MODULE_LIBRARY:
  3800. return (implib
  3801. ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
  3802. : "CMAKE_SHARED_MODULE_SUFFIX");
  3803. case cmTarget::EXECUTABLE:
  3804. return (implib
  3805. ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
  3806. : "CMAKE_EXECUTABLE_SUFFIX");
  3807. default:
  3808. break;
  3809. }
  3810. return "";
  3811. }
  3812. //----------------------------------------------------------------------------
  3813. const char* cmTarget::GetPrefixVariableInternal(bool implib)
  3814. {
  3815. switch(this->GetType())
  3816. {
  3817. case cmTarget::STATIC_LIBRARY:
  3818. return "CMAKE_STATIC_LIBRARY_PREFIX";
  3819. case cmTarget::SHARED_LIBRARY:
  3820. return (implib
  3821. ? "CMAKE_IMPORT_LIBRARY_PREFIX"
  3822. : "CMAKE_SHARED_LIBRARY_PREFIX");
  3823. case cmTarget::MODULE_LIBRARY:
  3824. return (implib
  3825. ? "CMAKE_IMPORT_LIBRARY_PREFIX"
  3826. : "CMAKE_SHARED_MODULE_PREFIX");
  3827. case cmTarget::EXECUTABLE:
  3828. return (implib? "CMAKE_IMPORT_LIBRARY_PREFIX" : "");
  3829. default:
  3830. break;
  3831. }
  3832. return "";
  3833. }
  3834. //----------------------------------------------------------------------------
  3835. std::string cmTarget::GetPDBName(const char* config)
  3836. {
  3837. std::string prefix;
  3838. std::string base;
  3839. std::string suffix;
  3840. this->GetFullNameInternal(config, false, prefix, base, suffix);
  3841. std::vector<std::string> props;
  3842. std::string configUpper =
  3843. cmSystemTools::UpperCase(config? config : "");
  3844. if(!configUpper.empty())
  3845. {
  3846. // PDB_NAME_<CONFIG>
  3847. props.push_back("PDB_NAME_" + configUpper);
  3848. }
  3849. // PDB_NAME
  3850. props.push_back("PDB_NAME");
  3851. for(std::vector<std::string>::const_iterator i = props.begin();
  3852. i != props.end(); ++i)
  3853. {
  3854. if(const char* outName = this->GetProperty(i->c_str()))
  3855. {
  3856. base = outName;
  3857. break;
  3858. }
  3859. }
  3860. return prefix+base+".pdb";
  3861. }
  3862. //----------------------------------------------------------------------------
  3863. bool cmTarget::HasSOName(const char* config)
  3864. {
  3865. // soname is supported only for shared libraries and modules,
  3866. // and then only when the platform supports an soname flag.
  3867. return ((this->GetType() == cmTarget::SHARED_LIBRARY ||
  3868. this->GetType() == cmTarget::MODULE_LIBRARY) &&
  3869. !this->GetPropertyAsBool("NO_SONAME") &&
  3870. this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config,
  3871. this)));
  3872. }
  3873. //----------------------------------------------------------------------------
  3874. std::string cmTarget::GetSOName(const char* config)
  3875. {
  3876. if(this->IsImported())
  3877. {
  3878. // Lookup the imported soname.
  3879. if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, this))
  3880. {
  3881. if(info->NoSOName)
  3882. {
  3883. // The imported library has no builtin soname so the name
  3884. // searched at runtime will be just the filename.
  3885. return cmSystemTools::GetFilenameName(info->Location);
  3886. }
  3887. else
  3888. {
  3889. // Use the soname given if any.
  3890. if(info->SOName.find("@rpath/") == 0)
  3891. {
  3892. return info->SOName.substr(6);
  3893. }
  3894. return info->SOName;
  3895. }
  3896. }
  3897. else
  3898. {
  3899. return "";
  3900. }
  3901. }
  3902. else
  3903. {
  3904. // Compute the soname that will be built.
  3905. std::string name;
  3906. std::string soName;
  3907. std::string realName;
  3908. std::string impName;
  3909. std::string pdbName;
  3910. this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
  3911. return soName;
  3912. }
  3913. }
  3914. //----------------------------------------------------------------------------
  3915. bool cmTarget::HasMacOSXRpath(const char* config)
  3916. {
  3917. bool install_name_is_rpath = false;
  3918. bool macosx_rpath = this->GetPropertyAsBool("MACOSX_RPATH");
  3919. if(!this->IsImportedTarget)
  3920. {
  3921. const char* install_name = this->GetProperty("INSTALL_NAME_DIR");
  3922. bool use_install_name =
  3923. this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH");
  3924. if(install_name && use_install_name &&
  3925. std::string(install_name) == "@rpath")
  3926. {
  3927. install_name_is_rpath = true;
  3928. }
  3929. }
  3930. else
  3931. {
  3932. // Lookup the imported soname.
  3933. if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, this))
  3934. {
  3935. if(!info->NoSOName && !info->SOName.empty())
  3936. {
  3937. if(info->SOName.find("@rpath/") == 0)
  3938. {
  3939. install_name_is_rpath = true;
  3940. }
  3941. }
  3942. else
  3943. {
  3944. std::string install_name;
  3945. cmSystemTools::GuessLibraryInstallName(info->Location, install_name);
  3946. if(install_name.find("@rpath") != std::string::npos)
  3947. {
  3948. install_name_is_rpath = true;
  3949. }
  3950. }
  3951. }
  3952. }
  3953. if(!install_name_is_rpath && !macosx_rpath)
  3954. {
  3955. return false;
  3956. }
  3957. if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG"))
  3958. {
  3959. cmOStringStream w;
  3960. w << "Attempting to use";
  3961. if(macosx_rpath)
  3962. {
  3963. w << " MACOSX_RPATH";
  3964. }
  3965. else
  3966. {
  3967. w << " @rpath";
  3968. }
  3969. w << " without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being set.";
  3970. w << " This could be because you are using a Mac OS X version";
  3971. w << " less than 10.5 or because CMake's platform configuration is";
  3972. w << " corrupt.";
  3973. cmake* cm = this->Makefile->GetCMakeInstance();
  3974. cm->IssueMessage(cmake::FATAL_ERROR, w.str(), this->GetBacktrace());
  3975. }
  3976. return true;
  3977. }
  3978. //----------------------------------------------------------------------------
  3979. bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config)
  3980. {
  3981. if(this->IsImported() && this->GetType() == cmTarget::SHARED_LIBRARY)
  3982. {
  3983. if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, this))
  3984. {
  3985. return info->NoSOName;
  3986. }
  3987. }
  3988. return false;
  3989. }
  3990. //----------------------------------------------------------------------------
  3991. std::string cmTarget::NormalGetRealName(const char* config)
  3992. {
  3993. // This should not be called for imported targets.
  3994. // TODO: Split cmTarget into a class hierarchy to get compile-time
  3995. // enforcement of the limited imported target API.
  3996. if(this->IsImported())
  3997. {
  3998. std::string msg = "NormalGetRealName called on imported target: ";
  3999. msg += this->GetName();
  4000. this->GetMakefile()->
  4001. IssueMessage(cmake::INTERNAL_ERROR,
  4002. msg.c_str());
  4003. }
  4004. if(this->GetType() == cmTarget::EXECUTABLE)
  4005. {
  4006. // Compute the real name that will be built.
  4007. std::string name;
  4008. std::string realName;
  4009. std::string impName;
  4010. std::string pdbName;
  4011. this->GetExecutableNames(name, realName, impName, pdbName, config);
  4012. return realName;
  4013. }
  4014. else
  4015. {
  4016. // Compute the real name that will be built.
  4017. std::string name;
  4018. std::string soName;
  4019. std::string realName;
  4020. std::string impName;
  4021. std::string pdbName;
  4022. this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
  4023. return realName;
  4024. }
  4025. }
  4026. //----------------------------------------------------------------------------
  4027. std::string cmTarget::GetFullName(const char* config, bool implib)
  4028. {
  4029. if(this->IsImported())
  4030. {
  4031. return this->GetFullNameImported(config, implib);
  4032. }
  4033. else
  4034. {
  4035. return this->GetFullNameInternal(config, implib);
  4036. }
  4037. }
  4038. //----------------------------------------------------------------------------
  4039. std::string cmTarget::GetFullNameImported(const char* config, bool implib)
  4040. {
  4041. return cmSystemTools::GetFilenameName(
  4042. this->ImportedGetFullPath(config, implib));
  4043. }
  4044. //----------------------------------------------------------------------------
  4045. void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base,
  4046. std::string& suffix, const char* config,
  4047. bool implib)
  4048. {
  4049. this->GetFullNameInternal(config, implib, prefix, base, suffix);
  4050. }
  4051. //----------------------------------------------------------------------------
  4052. std::string cmTarget::GetFullPath(const char* config, bool implib,
  4053. bool realname)
  4054. {
  4055. if(this->IsImported())
  4056. {
  4057. return this->ImportedGetFullPath(config, implib);
  4058. }
  4059. else
  4060. {
  4061. return this->NormalGetFullPath(config, implib, realname);
  4062. }
  4063. }
  4064. //----------------------------------------------------------------------------
  4065. std::string cmTarget::NormalGetFullPath(const char* config, bool implib,
  4066. bool realname)
  4067. {
  4068. std::string fpath = this->GetDirectory(config, implib);
  4069. fpath += "/";
  4070. if(this->IsAppBundleOnApple())
  4071. {
  4072. fpath = this->BuildMacContentDirectory(fpath, config, false);
  4073. fpath += "/";
  4074. }
  4075. // Add the full name of the target.
  4076. if(implib)
  4077. {
  4078. fpath += this->GetFullName(config, true);
  4079. }
  4080. else if(realname)
  4081. {
  4082. fpath += this->NormalGetRealName(config);
  4083. }
  4084. else
  4085. {
  4086. fpath += this->GetFullName(config, false);
  4087. }
  4088. return fpath;
  4089. }
  4090. //----------------------------------------------------------------------------
  4091. std::string cmTarget::ImportedGetFullPath(const char* config, bool implib)
  4092. {
  4093. std::string result;
  4094. if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, this))
  4095. {
  4096. result = implib? info->ImportLibrary : info->Location;
  4097. }
  4098. if(result.empty())
  4099. {
  4100. result = this->GetName();
  4101. result += "-NOTFOUND";
  4102. }
  4103. return result;
  4104. }
  4105. //----------------------------------------------------------------------------
  4106. std::string cmTarget::GetFullNameInternal(const char* config, bool implib)
  4107. {
  4108. std::string prefix;
  4109. std::string base;
  4110. std::string suffix;
  4111. this->GetFullNameInternal(config, implib, prefix, base, suffix);
  4112. return prefix+base+suffix;
  4113. }
  4114. //----------------------------------------------------------------------------
  4115. void cmTarget::GetFullNameInternal(const char* config,
  4116. bool implib,
  4117. std::string& outPrefix,
  4118. std::string& outBase,
  4119. std::string& outSuffix)
  4120. {
  4121. // Use just the target name for non-main target types.
  4122. if(this->GetType() != cmTarget::STATIC_LIBRARY &&
  4123. this->GetType() != cmTarget::SHARED_LIBRARY &&
  4124. this->GetType() != cmTarget::MODULE_LIBRARY &&
  4125. this->GetType() != cmTarget::EXECUTABLE)
  4126. {
  4127. outPrefix = "";
  4128. outBase = this->GetName();
  4129. outSuffix = "";
  4130. return;
  4131. }
  4132. // Return an empty name for the import library if this platform
  4133. // does not support import libraries.
  4134. if(implib &&
  4135. !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
  4136. {
  4137. outPrefix = "";
  4138. outBase = "";
  4139. outSuffix = "";
  4140. return;
  4141. }
  4142. // The implib option is only allowed for shared libraries, module
  4143. // libraries, and executables.
  4144. if(this->GetType() != cmTarget::SHARED_LIBRARY &&
  4145. this->GetType() != cmTarget::MODULE_LIBRARY &&
  4146. this->GetType() != cmTarget::EXECUTABLE)
  4147. {
  4148. implib = false;
  4149. }
  4150. // Compute the full name for main target types.
  4151. const char* targetPrefix = (implib
  4152. ? this->GetProperty("IMPORT_PREFIX")
  4153. : this->GetProperty("PREFIX"));
  4154. const char* targetSuffix = (implib
  4155. ? this->GetProperty("IMPORT_SUFFIX")
  4156. : this->GetProperty("SUFFIX"));
  4157. const char* configPostfix = 0;
  4158. if(config && *config)
  4159. {
  4160. std::string configProp = cmSystemTools::UpperCase(config);
  4161. configProp += "_POSTFIX";
  4162. configPostfix = this->GetProperty(configProp.c_str());
  4163. // Mac application bundles and frameworks have no postfix.
  4164. if(configPostfix &&
  4165. (this->IsAppBundleOnApple() || this->IsFrameworkOnApple()))
  4166. {
  4167. configPostfix = 0;
  4168. }
  4169. }
  4170. const char* prefixVar = this->GetPrefixVariableInternal(implib);
  4171. const char* suffixVar = this->GetSuffixVariableInternal(implib);
  4172. // Check for language-specific default prefix and suffix.
  4173. if(const char* ll = this->GetLinkerLanguage(config, this))
  4174. {
  4175. if(!targetSuffix && suffixVar && *suffixVar)
  4176. {
  4177. std::string langSuff = suffixVar + std::string("_") + ll;
  4178. targetSuffix = this->Makefile->GetDefinition(langSuff.c_str());
  4179. }
  4180. if(!targetPrefix && prefixVar && *prefixVar)
  4181. {
  4182. std::string langPrefix = prefixVar + std::string("_") + ll;
  4183. targetPrefix = this->Makefile->GetDefinition(langPrefix.c_str());
  4184. }
  4185. }
  4186. // if there is no prefix on the target use the cmake definition
  4187. if(!targetPrefix && prefixVar)
  4188. {
  4189. targetPrefix = this->Makefile->GetSafeDefinition(prefixVar);
  4190. }
  4191. // if there is no suffix on the target use the cmake definition
  4192. if(!targetSuffix && suffixVar)
  4193. {
  4194. targetSuffix = this->Makefile->GetSafeDefinition(suffixVar);
  4195. }
  4196. // frameworks have directory prefix but no suffix
  4197. std::string fw_prefix;
  4198. if(this->IsFrameworkOnApple())
  4199. {
  4200. fw_prefix = this->GetOutputName(config, false);
  4201. fw_prefix += ".framework/";
  4202. targetPrefix = fw_prefix.c_str();
  4203. targetSuffix = 0;
  4204. }
  4205. if(this->IsCFBundleOnApple())
  4206. {
  4207. fw_prefix = this->GetOutputName(config, false);
  4208. fw_prefix += ".";
  4209. const char *ext = this->GetProperty("BUNDLE_EXTENSION");
  4210. if (!ext)
  4211. {
  4212. ext = "bundle";
  4213. }
  4214. fw_prefix += ext;
  4215. fw_prefix += "/Contents/MacOS/";
  4216. targetPrefix = fw_prefix.c_str();
  4217. targetSuffix = 0;
  4218. }
  4219. // Begin the final name with the prefix.
  4220. outPrefix = targetPrefix?targetPrefix:"";
  4221. // Append the target name or property-specified name.
  4222. outBase += this->GetOutputName(config, implib);
  4223. // Append the per-configuration postfix.
  4224. outBase += configPostfix?configPostfix:"";
  4225. // Name shared libraries with their version number on some platforms.
  4226. if(const char* soversion = this->GetProperty("SOVERSION"))
  4227. {
  4228. if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib &&
  4229. this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION"))
  4230. {
  4231. outBase += "-";
  4232. outBase += soversion;
  4233. }
  4234. }
  4235. // Append the suffix.
  4236. outSuffix = targetSuffix?targetSuffix:"";
  4237. }
  4238. //----------------------------------------------------------------------------
  4239. void cmTarget::GetLibraryNames(std::string& name,
  4240. std::string& soName,
  4241. std::string& realName,
  4242. std::string& impName,
  4243. std::string& pdbName,
  4244. const char* config)
  4245. {
  4246. // This should not be called for imported targets.
  4247. // TODO: Split cmTarget into a class hierarchy to get compile-time
  4248. // enforcement of the limited imported target API.
  4249. if(this->IsImported())
  4250. {
  4251. std::string msg = "GetLibraryNames called on imported target: ";
  4252. msg += this->GetName();
  4253. this->Makefile->IssueMessage(cmake::INTERNAL_ERROR,
  4254. msg.c_str());
  4255. return;
  4256. }
  4257. // Check for library version properties.
  4258. const char* version = this->GetProperty("VERSION");
  4259. const char* soversion = this->GetProperty("SOVERSION");
  4260. if(!this->HasSOName(config) ||
  4261. this->IsFrameworkOnApple())
  4262. {
  4263. // Versioning is supported only for shared libraries and modules,
  4264. // and then only when the platform supports an soname flag.
  4265. version = 0;
  4266. soversion = 0;
  4267. }
  4268. if(version && !soversion)
  4269. {
  4270. // The soversion must be set if the library version is set. Use
  4271. // the library version as the soversion.
  4272. soversion = version;
  4273. }
  4274. if(!version && soversion)
  4275. {
  4276. // Use the soversion as the library version.
  4277. version = soversion;
  4278. }
  4279. // Get the components of the library name.
  4280. std::string prefix;
  4281. std::string base;
  4282. std::string suffix;
  4283. this->GetFullNameInternal(config, false, prefix, base, suffix);
  4284. // The library name.
  4285. name = prefix+base+suffix;
  4286. if(this->IsFrameworkOnApple())
  4287. {
  4288. realName = prefix;
  4289. realName += "Versions/";
  4290. realName += this->GetFrameworkVersion();
  4291. realName += "/";
  4292. realName += base;
  4293. soName = realName;
  4294. }
  4295. else
  4296. {
  4297. // The library's soname.
  4298. this->ComputeVersionedName(soName, prefix, base, suffix,
  4299. name, soversion);
  4300. // The library's real name on disk.
  4301. this->ComputeVersionedName(realName, prefix, base, suffix,
  4302. name, version);
  4303. }
  4304. // The import library name.
  4305. if(this->GetType() == cmTarget::SHARED_LIBRARY ||
  4306. this->GetType() == cmTarget::MODULE_LIBRARY)
  4307. {
  4308. impName = this->GetFullNameInternal(config, true);
  4309. }
  4310. else
  4311. {
  4312. impName = "";
  4313. }
  4314. // The program database file name.
  4315. pdbName = this->GetPDBName(config);
  4316. }
  4317. //----------------------------------------------------------------------------
  4318. void cmTarget::ComputeVersionedName(std::string& vName,
  4319. std::string const& prefix,
  4320. std::string const& base,
  4321. std::string const& suffix,
  4322. std::string const& name,
  4323. const char* version)
  4324. {
  4325. vName = this->IsApple? (prefix+base) : name;
  4326. if(version)
  4327. {
  4328. vName += ".";
  4329. vName += version;
  4330. }
  4331. vName += this->IsApple? suffix : std::string();
  4332. }
  4333. //----------------------------------------------------------------------------
  4334. void cmTarget::GetExecutableNames(std::string& name,
  4335. std::string& realName,
  4336. std::string& impName,
  4337. std::string& pdbName,
  4338. const char* config)
  4339. {
  4340. // This should not be called for imported targets.
  4341. // TODO: Split cmTarget into a class hierarchy to get compile-time
  4342. // enforcement of the limited imported target API.
  4343. if(this->IsImported())
  4344. {
  4345. std::string msg =
  4346. "GetExecutableNames called on imported target: ";
  4347. msg += this->GetName();
  4348. this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg.c_str());
  4349. }
  4350. // This versioning is supported only for executables and then only
  4351. // when the platform supports symbolic links.
  4352. #if defined(_WIN32) && !defined(__CYGWIN__)
  4353. const char* version = 0;
  4354. #else
  4355. // Check for executable version properties.
  4356. const char* version = this->GetProperty("VERSION");
  4357. if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE"))
  4358. {
  4359. version = 0;
  4360. }
  4361. #endif
  4362. // Get the components of the executable name.
  4363. std::string prefix;
  4364. std::string base;
  4365. std::string suffix;
  4366. this->GetFullNameInternal(config, false, prefix, base, suffix);
  4367. // The executable name.
  4368. name = prefix+base+suffix;
  4369. // The executable's real name on disk.
  4370. #if defined(__CYGWIN__)
  4371. realName = prefix+base;
  4372. #else
  4373. realName = name;
  4374. #endif
  4375. if(version)
  4376. {
  4377. realName += "-";
  4378. realName += version;
  4379. }
  4380. #if defined(__CYGWIN__)
  4381. realName += suffix;
  4382. #endif
  4383. // The import library name.
  4384. impName = this->GetFullNameInternal(config, true);
  4385. // The program database file name.
  4386. pdbName = this->GetPDBName(config);
  4387. }
  4388. //----------------------------------------------------------------------------
  4389. bool cmTarget::HasImplibGNUtoMS()
  4390. {
  4391. return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS");
  4392. }
  4393. //----------------------------------------------------------------------------
  4394. bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName,
  4395. std::string& out, const char* newExt)
  4396. {
  4397. if(this->HasImplibGNUtoMS() &&
  4398. gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a")
  4399. {
  4400. out = gnuName.substr(0, gnuName.size()-6);
  4401. out += newExt? newExt : ".lib";
  4402. return true;
  4403. }
  4404. return false;
  4405. }
  4406. //----------------------------------------------------------------------------
  4407. void cmTarget::GenerateTargetManifest(const char* config)
  4408. {
  4409. cmMakefile* mf = this->Makefile;
  4410. cmLocalGenerator* lg = mf->GetLocalGenerator();
  4411. cmGlobalGenerator* gg = lg->GetGlobalGenerator();
  4412. // Get the names.
  4413. std::string name;
  4414. std::string soName;
  4415. std::string realName;
  4416. std::string impName;
  4417. std::string pdbName;
  4418. if(this->GetType() == cmTarget::EXECUTABLE)
  4419. {
  4420. this->GetExecutableNames(name, realName, impName, pdbName, config);
  4421. }
  4422. else if(this->GetType() == cmTarget::STATIC_LIBRARY ||
  4423. this->GetType() == cmTarget::SHARED_LIBRARY ||
  4424. this->GetType() == cmTarget::MODULE_LIBRARY)
  4425. {
  4426. this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
  4427. }
  4428. else
  4429. {
  4430. return;
  4431. }
  4432. // Get the directory.
  4433. std::string dir = this->GetDirectory(config, false);
  4434. // Add each name.
  4435. std::string f;
  4436. if(!name.empty())
  4437. {
  4438. f = dir;
  4439. f += "/";
  4440. f += name;
  4441. gg->AddToManifest(config? config:"", f);
  4442. }
  4443. if(!soName.empty())
  4444. {
  4445. f = dir;
  4446. f += "/";
  4447. f += soName;
  4448. gg->AddToManifest(config? config:"", f);
  4449. }
  4450. if(!realName.empty())
  4451. {
  4452. f = dir;
  4453. f += "/";
  4454. f += realName;
  4455. gg->AddToManifest(config? config:"", f);
  4456. }
  4457. if(!pdbName.empty())
  4458. {
  4459. f = this->GetPDBDirectory(config);
  4460. f += "/";
  4461. f += pdbName;
  4462. gg->AddToManifest(config? config:"", f);
  4463. }
  4464. if(!impName.empty())
  4465. {
  4466. f = this->GetDirectory(config, true);
  4467. f += "/";
  4468. f += impName;
  4469. gg->AddToManifest(config? config:"", f);
  4470. }
  4471. }
  4472. //----------------------------------------------------------------------------
  4473. void cmTarget::SetPropertyDefault(const char* property,
  4474. const char* default_value)
  4475. {
  4476. // Compute the name of the variable holding the default value.
  4477. std::string var = "CMAKE_";
  4478. var += property;
  4479. if(const char* value = this->Makefile->GetDefinition(var.c_str()))
  4480. {
  4481. this->SetProperty(property, value);
  4482. }
  4483. else if(default_value)
  4484. {
  4485. this->SetProperty(property, default_value);
  4486. }
  4487. }
  4488. //----------------------------------------------------------------------------
  4489. bool cmTarget::HaveBuildTreeRPATH(const char *config)
  4490. {
  4491. if (this->GetPropertyAsBool("SKIP_BUILD_RPATH"))
  4492. {
  4493. return false;
  4494. }
  4495. std::vector<std::string> libs;
  4496. this->GetDirectLinkLibraries(config, libs, this);
  4497. return !libs.empty();
  4498. }
  4499. //----------------------------------------------------------------------------
  4500. bool cmTarget::HaveInstallTreeRPATH()
  4501. {
  4502. const char* install_rpath = this->GetProperty("INSTALL_RPATH");
  4503. return (install_rpath && *install_rpath) &&
  4504. !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH");
  4505. }
  4506. //----------------------------------------------------------------------------
  4507. bool cmTarget::NeedRelinkBeforeInstall(const char* config)
  4508. {
  4509. // Only executables and shared libraries can have an rpath and may
  4510. // need relinking.
  4511. if(this->TargetTypeValue != cmTarget::EXECUTABLE &&
  4512. this->TargetTypeValue != cmTarget::SHARED_LIBRARY &&
  4513. this->TargetTypeValue != cmTarget::MODULE_LIBRARY)
  4514. {
  4515. return false;
  4516. }
  4517. // If there is no install location this target will not be installed
  4518. // and therefore does not need relinking.
  4519. if(!this->GetHaveInstallRule())
  4520. {
  4521. return false;
  4522. }
  4523. // If skipping all rpaths completely then no relinking is needed.
  4524. if(this->Makefile->IsOn("CMAKE_SKIP_RPATH"))
  4525. {
  4526. return false;
  4527. }
  4528. // If building with the install-tree rpath no relinking is needed.
  4529. if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"))
  4530. {
  4531. return false;
  4532. }
  4533. // If chrpath is going to be used no relinking is needed.
  4534. if(this->IsChrpathUsed(config))
  4535. {
  4536. return false;
  4537. }
  4538. // Check for rpath support on this platform.
  4539. if(const char* ll = this->GetLinkerLanguage(config, this))
  4540. {
  4541. std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
  4542. flagVar += ll;
  4543. flagVar += "_FLAG";
  4544. if(!this->Makefile->IsSet(flagVar.c_str()))
  4545. {
  4546. // There is no rpath support on this platform so nothing needs
  4547. // relinking.
  4548. return false;
  4549. }
  4550. }
  4551. else
  4552. {
  4553. // No linker language is known. This error will be reported by
  4554. // other code.
  4555. return false;
  4556. }
  4557. // If either a build or install tree rpath is set then the rpath
  4558. // will likely change between the build tree and install tree and
  4559. // this target must be relinked.
  4560. return this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH();
  4561. }
  4562. //----------------------------------------------------------------------------
  4563. std::string cmTarget::GetInstallNameDirForBuildTree(const char* config)
  4564. {
  4565. // If building directly for installation then the build tree install_name
  4566. // is the same as the install tree.
  4567. if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"))
  4568. {
  4569. return GetInstallNameDirForInstallTree();
  4570. }
  4571. // Use the build tree directory for the target.
  4572. if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") &&
  4573. !this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
  4574. !this->GetPropertyAsBool("SKIP_BUILD_RPATH"))
  4575. {
  4576. std::string dir;
  4577. if(this->GetPropertyAsBool("MACOSX_RPATH"))
  4578. {
  4579. dir = "@rpath";
  4580. }
  4581. else
  4582. {
  4583. dir = this->GetDirectory(config);
  4584. }
  4585. dir += "/";
  4586. return dir;
  4587. }
  4588. else
  4589. {
  4590. return "";
  4591. }
  4592. }
  4593. //----------------------------------------------------------------------------
  4594. std::string cmTarget::GetInstallNameDirForInstallTree()
  4595. {
  4596. if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
  4597. {
  4598. std::string dir;
  4599. if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
  4600. !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH"))
  4601. {
  4602. const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR");
  4603. if(install_name_dir && *install_name_dir)
  4604. {
  4605. dir = install_name_dir;
  4606. dir += "/";
  4607. }
  4608. }
  4609. if(dir.empty() && this->GetPropertyAsBool("MACOSX_RPATH"))
  4610. {
  4611. dir = "@rpath/";
  4612. }
  4613. return dir;
  4614. }
  4615. else
  4616. {
  4617. return "";
  4618. }
  4619. }
  4620. //----------------------------------------------------------------------------
  4621. const char* cmTarget::GetOutputTargetType(bool implib)
  4622. {
  4623. switch(this->GetType())
  4624. {
  4625. case cmTarget::SHARED_LIBRARY:
  4626. if(this->DLLPlatform)
  4627. {
  4628. if(implib)
  4629. {
  4630. // A DLL import library is treated as an archive target.
  4631. return "ARCHIVE";
  4632. }
  4633. else
  4634. {
  4635. // A DLL shared library is treated as a runtime target.
  4636. return "RUNTIME";
  4637. }
  4638. }
  4639. else
  4640. {
  4641. // For non-DLL platforms shared libraries are treated as
  4642. // library targets.
  4643. return "LIBRARY";
  4644. }
  4645. case cmTarget::STATIC_LIBRARY:
  4646. // Static libraries are always treated as archive targets.
  4647. return "ARCHIVE";
  4648. case cmTarget::MODULE_LIBRARY:
  4649. if(implib)
  4650. {
  4651. // Module libraries are always treated as library targets.
  4652. return "ARCHIVE";
  4653. }
  4654. else
  4655. {
  4656. // Module import libraries are treated as archive targets.
  4657. return "LIBRARY";
  4658. }
  4659. case cmTarget::EXECUTABLE:
  4660. if(implib)
  4661. {
  4662. // Executable import libraries are treated as archive targets.
  4663. return "ARCHIVE";
  4664. }
  4665. else
  4666. {
  4667. // Executables are always treated as runtime targets.
  4668. return "RUNTIME";
  4669. }
  4670. default:
  4671. break;
  4672. }
  4673. return "";
  4674. }
  4675. //----------------------------------------------------------------------------
  4676. bool cmTarget::ComputeOutputDir(const char* config,
  4677. bool implib, std::string& out)
  4678. {
  4679. bool usesDefaultOutputDir = false;
  4680. // Look for a target property defining the target output directory
  4681. // based on the target type.
  4682. std::string targetTypeName = this->GetOutputTargetType(implib);
  4683. const char* propertyName = 0;
  4684. std::string propertyNameStr = targetTypeName;
  4685. if(!propertyNameStr.empty())
  4686. {
  4687. propertyNameStr += "_OUTPUT_DIRECTORY";
  4688. propertyName = propertyNameStr.c_str();
  4689. }
  4690. // Check for a per-configuration output directory target property.
  4691. std::string configUpper = cmSystemTools::UpperCase(config? config : "");
  4692. const char* configProp = 0;
  4693. std::string configPropStr = targetTypeName;
  4694. if(!configPropStr.empty())
  4695. {
  4696. configPropStr += "_OUTPUT_DIRECTORY_";
  4697. configPropStr += configUpper;
  4698. configProp = configPropStr.c_str();
  4699. }
  4700. // Select an output directory.
  4701. if(const char* config_outdir = this->GetProperty(configProp))
  4702. {
  4703. // Use the user-specified per-configuration output directory.
  4704. out = config_outdir;
  4705. // Skip per-configuration subdirectory.
  4706. config = 0;
  4707. }
  4708. else if(const char* outdir = this->GetProperty(propertyName))
  4709. {
  4710. // Use the user-specified output directory.
  4711. out = outdir;
  4712. }
  4713. else if(this->GetType() == cmTarget::EXECUTABLE)
  4714. {
  4715. // Lookup the output path for executables.
  4716. out = this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
  4717. }
  4718. else if(this->GetType() == cmTarget::STATIC_LIBRARY ||
  4719. this->GetType() == cmTarget::SHARED_LIBRARY ||
  4720. this->GetType() == cmTarget::MODULE_LIBRARY)
  4721. {
  4722. // Lookup the output path for libraries.
  4723. out = this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
  4724. }
  4725. if(out.empty())
  4726. {
  4727. // Default to the current output directory.
  4728. usesDefaultOutputDir = true;
  4729. out = ".";
  4730. }
  4731. // Convert the output path to a full path in case it is
  4732. // specified as a relative path. Treat a relative path as
  4733. // relative to the current output directory for this makefile.
  4734. out = (cmSystemTools::CollapseFullPath
  4735. (out.c_str(), this->Makefile->GetStartOutputDirectory()));
  4736. // The generator may add the configuration's subdirectory.
  4737. if(config && *config)
  4738. {
  4739. const char *platforms = this->Makefile->GetDefinition(
  4740. "CMAKE_XCODE_EFFECTIVE_PLATFORMS");
  4741. std::string suffix =
  4742. usesDefaultOutputDir && platforms ? "$(EFFECTIVE_PLATFORM_NAME)" : "";
  4743. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
  4744. AppendDirectoryForConfig("/", config, suffix.c_str(), out);
  4745. }
  4746. return usesDefaultOutputDir;
  4747. }
  4748. //----------------------------------------------------------------------------
  4749. bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out)
  4750. {
  4751. // Look for a target property defining the target output directory
  4752. // based on the target type.
  4753. std::string targetTypeName = "PDB";
  4754. const char* propertyName = 0;
  4755. std::string propertyNameStr = targetTypeName;
  4756. if(!propertyNameStr.empty())
  4757. {
  4758. propertyNameStr += "_OUTPUT_DIRECTORY";
  4759. propertyName = propertyNameStr.c_str();
  4760. }
  4761. // Check for a per-configuration output directory target property.
  4762. std::string configUpper = cmSystemTools::UpperCase(config? config : "");
  4763. const char* configProp = 0;
  4764. std::string configPropStr = targetTypeName;
  4765. if(!configPropStr.empty())
  4766. {
  4767. configPropStr += "_OUTPUT_DIRECTORY_";
  4768. configPropStr += configUpper;
  4769. configProp = configPropStr.c_str();
  4770. }
  4771. // Select an output directory.
  4772. if(const char* config_outdir = this->GetProperty(configProp))
  4773. {
  4774. // Use the user-specified per-configuration output directory.
  4775. out = config_outdir;
  4776. // Skip per-configuration subdirectory.
  4777. config = 0;
  4778. }
  4779. else if(const char* outdir = this->GetProperty(propertyName))
  4780. {
  4781. // Use the user-specified output directory.
  4782. out = outdir;
  4783. }
  4784. if(out.empty())
  4785. {
  4786. return false;
  4787. }
  4788. // Convert the output path to a full path in case it is
  4789. // specified as a relative path. Treat a relative path as
  4790. // relative to the current output directory for this makefile.
  4791. out = (cmSystemTools::CollapseFullPath
  4792. (out.c_str(), this->Makefile->GetStartOutputDirectory()));
  4793. // The generator may add the configuration's subdirectory.
  4794. if(config && *config)
  4795. {
  4796. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
  4797. AppendDirectoryForConfig("/", config, "", out);
  4798. }
  4799. return true;
  4800. }
  4801. //----------------------------------------------------------------------------
  4802. bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib)
  4803. {
  4804. std::string dir;
  4805. return this->ComputeOutputDir(config, implib, dir);
  4806. }
  4807. //----------------------------------------------------------------------------
  4808. std::string cmTarget::GetOutputName(const char* config, bool implib)
  4809. {
  4810. std::vector<std::string> props;
  4811. std::string type = this->GetOutputTargetType(implib);
  4812. std::string configUpper = cmSystemTools::UpperCase(config? config : "");
  4813. if(!type.empty() && !configUpper.empty())
  4814. {
  4815. // <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG>
  4816. props.push_back(type + "_OUTPUT_NAME_" + configUpper);
  4817. }
  4818. if(!type.empty())
  4819. {
  4820. // <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME
  4821. props.push_back(type + "_OUTPUT_NAME");
  4822. }
  4823. if(!configUpper.empty())
  4824. {
  4825. // OUTPUT_NAME_<CONFIG>
  4826. props.push_back("OUTPUT_NAME_" + configUpper);
  4827. // <CONFIG>_OUTPUT_NAME
  4828. props.push_back(configUpper + "_OUTPUT_NAME");
  4829. }
  4830. // OUTPUT_NAME
  4831. props.push_back("OUTPUT_NAME");
  4832. for(std::vector<std::string>::const_iterator i = props.begin();
  4833. i != props.end(); ++i)
  4834. {
  4835. if(const char* outName = this->GetProperty(i->c_str()))
  4836. {
  4837. return outName;
  4838. }
  4839. }
  4840. return this->GetName();
  4841. }
  4842. //----------------------------------------------------------------------------
  4843. std::string cmTarget::GetFrameworkVersion()
  4844. {
  4845. if(const char* fversion = this->GetProperty("FRAMEWORK_VERSION"))
  4846. {
  4847. return fversion;
  4848. }
  4849. else if(const char* tversion = this->GetProperty("VERSION"))
  4850. {
  4851. return tversion;
  4852. }
  4853. else
  4854. {
  4855. return "A";
  4856. }
  4857. }
  4858. //----------------------------------------------------------------------------
  4859. const char* cmTarget::GetExportMacro()
  4860. {
  4861. // Define the symbol for targets that export symbols.
  4862. if(this->GetType() == cmTarget::SHARED_LIBRARY ||
  4863. this->GetType() == cmTarget::MODULE_LIBRARY ||
  4864. this->IsExecutableWithExports())
  4865. {
  4866. if(const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL"))
  4867. {
  4868. this->ExportMacro = custom_export_name;
  4869. }
  4870. else
  4871. {
  4872. std::string in = this->GetName();
  4873. in += "_EXPORTS";
  4874. this->ExportMacro = cmSystemTools::MakeCindentifier(in.c_str());
  4875. }
  4876. return this->ExportMacro.c_str();
  4877. }
  4878. else
  4879. {
  4880. return 0;
  4881. }
  4882. }
  4883. //----------------------------------------------------------------------------
  4884. bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p)
  4885. {
  4886. return this->LinkImplicitNullProperties.find(p)
  4887. != this->LinkImplicitNullProperties.end();
  4888. }
  4889. //----------------------------------------------------------------------------
  4890. template<typename PropertyType>
  4891. PropertyType getTypedProperty(cmTarget *tgt, const char *prop,
  4892. PropertyType *);
  4893. //----------------------------------------------------------------------------
  4894. template<>
  4895. bool getTypedProperty<bool>(cmTarget *tgt, const char *prop, bool *)
  4896. {
  4897. return tgt->GetPropertyAsBool(prop);
  4898. }
  4899. //----------------------------------------------------------------------------
  4900. template<>
  4901. const char *getTypedProperty<const char *>(cmTarget *tgt, const char *prop,
  4902. const char **)
  4903. {
  4904. return tgt->GetProperty(prop);
  4905. }
  4906. //----------------------------------------------------------------------------
  4907. template<typename PropertyType>
  4908. bool consistentProperty(PropertyType lhs, PropertyType rhs);
  4909. //----------------------------------------------------------------------------
  4910. template<>
  4911. bool consistentProperty(bool lhs, bool rhs)
  4912. {
  4913. return lhs == rhs;
  4914. }
  4915. //----------------------------------------------------------------------------
  4916. template<>
  4917. bool consistentProperty(const char *lhs, const char *rhs)
  4918. {
  4919. if (!lhs && !rhs)
  4920. return true;
  4921. if (!lhs || !rhs)
  4922. return false;
  4923. return strcmp(lhs, rhs) == 0;
  4924. }
  4925. //----------------------------------------------------------------------------
  4926. template<typename PropertyType>
  4927. PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt,
  4928. const std::string &p,
  4929. const char *config,
  4930. const char *defaultValue,
  4931. PropertyType *)
  4932. {
  4933. PropertyType propContent = getTypedProperty<PropertyType>(tgt, p.c_str(),
  4934. 0);
  4935. const bool explicitlySet = tgt->GetProperties()
  4936. .find(p.c_str())
  4937. != tgt->GetProperties().end();
  4938. const bool impliedByUse =
  4939. tgt->IsNullImpliedByLinkLibraries(p);
  4940. assert((impliedByUse ^ explicitlySet)
  4941. || (!impliedByUse && !explicitlySet));
  4942. cmComputeLinkInformation *info = tgt->GetLinkInformation(config);
  4943. if(!info)
  4944. {
  4945. return propContent;
  4946. }
  4947. const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
  4948. bool propInitialized = explicitlySet;
  4949. for(cmComputeLinkInformation::ItemVector::const_iterator li =
  4950. deps.begin();
  4951. li != deps.end(); ++li)
  4952. {
  4953. // An error should be reported if one dependency
  4954. // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other
  4955. // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the
  4956. // target itself has a POSITION_INDEPENDENT_CODE which disagrees
  4957. // with a dependency.
  4958. if (!li->Target)
  4959. {
  4960. continue;
  4961. }
  4962. const bool ifaceIsSet = li->Target->GetProperties()
  4963. .find("INTERFACE_" + p)
  4964. != li->Target->GetProperties().end();
  4965. PropertyType ifacePropContent =
  4966. getTypedProperty<PropertyType>(li->Target,
  4967. ("INTERFACE_" + p).c_str(), 0);
  4968. if (explicitlySet)
  4969. {
  4970. if (ifaceIsSet)
  4971. {
  4972. if (!consistentProperty(propContent, ifacePropContent))
  4973. {
  4974. cmOStringStream e;
  4975. e << "Property " << p << " on target \""
  4976. << tgt->GetName() << "\" does\nnot match the "
  4977. "INTERFACE_" << p << " property requirement\nof "
  4978. "dependency \"" << li->Target->GetName() << "\".\n";
  4979. cmSystemTools::Error(e.str().c_str());
  4980. break;
  4981. }
  4982. else
  4983. {
  4984. // Agree
  4985. continue;
  4986. }
  4987. }
  4988. else
  4989. {
  4990. // Explicitly set on target and not set in iface. Can't disagree.
  4991. continue;
  4992. }
  4993. }
  4994. else if (impliedByUse)
  4995. {
  4996. if (ifaceIsSet)
  4997. {
  4998. if (!consistentProperty(propContent, ifacePropContent))
  4999. {
  5000. cmOStringStream e;
  5001. e << "Property " << p << " on target \""
  5002. << tgt->GetName() << "\" is\nimplied to be " << defaultValue
  5003. << " because it was used to determine the link libraries\n"
  5004. "already. The INTERFACE_" << p << " property on\ndependency \""
  5005. << li->Target->GetName() << "\" is in conflict.\n";
  5006. cmSystemTools::Error(e.str().c_str());
  5007. break;
  5008. }
  5009. else
  5010. {
  5011. // Agree
  5012. continue;
  5013. }
  5014. }
  5015. else
  5016. {
  5017. // Implicitly set on target and not set in iface. Can't disagree.
  5018. continue;
  5019. }
  5020. }
  5021. else
  5022. {
  5023. if (ifaceIsSet)
  5024. {
  5025. if (propInitialized)
  5026. {
  5027. if (!consistentProperty(propContent, ifacePropContent))
  5028. {
  5029. cmOStringStream e;
  5030. e << "The INTERFACE_" << p << " property of \""
  5031. << li->Target->GetName() << "\" does\nnot agree with the value "
  5032. "of " << p << " already determined\nfor \""
  5033. << tgt->GetName() << "\".\n";
  5034. cmSystemTools::Error(e.str().c_str());
  5035. break;
  5036. }
  5037. else
  5038. {
  5039. // Agree.
  5040. continue;
  5041. }
  5042. }
  5043. else
  5044. {
  5045. propContent = ifacePropContent;
  5046. propInitialized = true;
  5047. }
  5048. }
  5049. else
  5050. {
  5051. // Not set. Nothing to agree on.
  5052. continue;
  5053. }
  5054. }
  5055. }
  5056. return propContent;
  5057. }
  5058. //----------------------------------------------------------------------------
  5059. bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p,
  5060. const char *config)
  5061. {
  5062. return checkInterfacePropertyCompatibility<bool>(this, p, config, "FALSE",
  5063. 0);
  5064. }
  5065. //----------------------------------------------------------------------------
  5066. const char * cmTarget::GetLinkInterfaceDependentStringProperty(
  5067. const std::string &p,
  5068. const char *config)
  5069. {
  5070. return checkInterfacePropertyCompatibility<const char *>(this,
  5071. p,
  5072. config,
  5073. "empty", 0);
  5074. }
  5075. //----------------------------------------------------------------------------
  5076. bool isLinkDependentProperty(cmTarget *tgt, const std::string &p,
  5077. const char *interfaceProperty,
  5078. const char *config)
  5079. {
  5080. cmComputeLinkInformation *info = tgt->GetLinkInformation(config);
  5081. if(!info)
  5082. {
  5083. return false;
  5084. }
  5085. const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
  5086. for(cmComputeLinkInformation::ItemVector::const_iterator li =
  5087. deps.begin();
  5088. li != deps.end(); ++li)
  5089. {
  5090. if (!li->Target)
  5091. {
  5092. continue;
  5093. }
  5094. const char *prop = li->Target->GetProperty(interfaceProperty);
  5095. if (!prop)
  5096. {
  5097. continue;
  5098. }
  5099. std::vector<std::string> props;
  5100. cmSystemTools::ExpandListArgument(prop, props);
  5101. for(std::vector<std::string>::iterator pi = props.begin();
  5102. pi != props.end(); ++pi)
  5103. {
  5104. if (*pi == p)
  5105. {
  5106. return true;
  5107. }
  5108. }
  5109. }
  5110. return false;
  5111. }
  5112. //----------------------------------------------------------------------------
  5113. bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p,
  5114. const char *config)
  5115. {
  5116. if (this->TargetTypeValue == OBJECT_LIBRARY)
  5117. {
  5118. return false;
  5119. }
  5120. return (p == "POSITION_INDEPENDENT_CODE") ||
  5121. isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_BOOL",
  5122. config);
  5123. }
  5124. //----------------------------------------------------------------------------
  5125. bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p,
  5126. const char *config)
  5127. {
  5128. if (this->TargetTypeValue == OBJECT_LIBRARY)
  5129. {
  5130. return false;
  5131. }
  5132. return isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_STRING",
  5133. config);
  5134. }
  5135. //----------------------------------------------------------------------------
  5136. void cmTarget::GetLanguages(std::set<cmStdString>& languages) const
  5137. {
  5138. for(std::vector<cmSourceFile*>::const_iterator
  5139. i = this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i)
  5140. {
  5141. if(const char* lang = (*i)->GetLanguage())
  5142. {
  5143. languages.insert(lang);
  5144. }
  5145. }
  5146. }
  5147. //----------------------------------------------------------------------------
  5148. bool cmTarget::IsChrpathUsed(const char* config)
  5149. {
  5150. // Only certain target types have an rpath.
  5151. if(!(this->GetType() == cmTarget::SHARED_LIBRARY ||
  5152. this->GetType() == cmTarget::MODULE_LIBRARY ||
  5153. this->GetType() == cmTarget::EXECUTABLE))
  5154. {
  5155. return false;
  5156. }
  5157. // If the target will not be installed we do not need to change its
  5158. // rpath.
  5159. if(!this->GetHaveInstallRule())
  5160. {
  5161. return false;
  5162. }
  5163. // Skip chrpath if skipping rpath altogether.
  5164. if(this->Makefile->IsOn("CMAKE_SKIP_RPATH"))
  5165. {
  5166. return false;
  5167. }
  5168. // Skip chrpath if it does not need to be changed at install time.
  5169. if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"))
  5170. {
  5171. return false;
  5172. }
  5173. // Allow the user to disable builtin chrpath explicitly.
  5174. if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH"))
  5175. {
  5176. return false;
  5177. }
  5178. if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
  5179. {
  5180. return true;
  5181. }
  5182. #if defined(CMAKE_USE_ELF_PARSER)
  5183. // Enable if the rpath flag uses a separator and the target uses ELF
  5184. // binaries.
  5185. if(const char* ll = this->GetLinkerLanguage(config, this))
  5186. {
  5187. std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
  5188. sepVar += ll;
  5189. sepVar += "_FLAG_SEP";
  5190. const char* sep = this->Makefile->GetDefinition(sepVar.c_str());
  5191. if(sep && *sep)
  5192. {
  5193. // TODO: Add ELF check to ABI detection and get rid of
  5194. // CMAKE_EXECUTABLE_FORMAT.
  5195. if(const char* fmt =
  5196. this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT"))
  5197. {
  5198. return strcmp(fmt, "ELF") == 0;
  5199. }
  5200. }
  5201. }
  5202. #endif
  5203. static_cast<void>(config);
  5204. return false;
  5205. }
  5206. //----------------------------------------------------------------------------
  5207. cmTarget::ImportInfo const*
  5208. cmTarget::GetImportInfo(const char* config, cmTarget *headTarget)
  5209. {
  5210. // There is no imported information for non-imported targets.
  5211. if(!this->IsImported())
  5212. {
  5213. return 0;
  5214. }
  5215. // Lookup/compute/cache the import information for this
  5216. // configuration.
  5217. std::string config_upper;
  5218. if(config && *config)
  5219. {
  5220. config_upper = cmSystemTools::UpperCase(config);
  5221. }
  5222. else
  5223. {
  5224. config_upper = "NOCONFIG";
  5225. }
  5226. TargetConfigPair key(headTarget, config_upper);
  5227. typedef cmTargetInternals::ImportInfoMapType ImportInfoMapType;
  5228. ImportInfoMapType::const_iterator i =
  5229. this->Internal->ImportInfoMap.find(key);
  5230. if(i == this->Internal->ImportInfoMap.end())
  5231. {
  5232. ImportInfo info;
  5233. this->ComputeImportInfo(config_upper, info, headTarget);
  5234. ImportInfoMapType::value_type entry(key, info);
  5235. i = this->Internal->ImportInfoMap.insert(entry).first;
  5236. }
  5237. // If the location is empty then the target is not available for
  5238. // this configuration.
  5239. if(i->second.Location.empty() && i->second.ImportLibrary.empty())
  5240. {
  5241. return 0;
  5242. }
  5243. // Return the import information.
  5244. return &i->second;
  5245. }
  5246. bool cmTarget::GetMappedConfig(std::string const& desired_config,
  5247. const char** loc,
  5248. const char** imp,
  5249. std::string& suffix)
  5250. {
  5251. // Track the configuration-specific property suffix.
  5252. suffix = "_";
  5253. suffix += desired_config;
  5254. std::vector<std::string> mappedConfigs;
  5255. {
  5256. std::string mapProp = "MAP_IMPORTED_CONFIG_";
  5257. mapProp += desired_config;
  5258. if(const char* mapValue = this->GetProperty(mapProp.c_str()))
  5259. {
  5260. cmSystemTools::ExpandListArgument(mapValue, mappedConfigs);
  5261. }
  5262. }
  5263. // If we needed to find one of the mapped configurations but did not
  5264. // On a DLL platform there may be only IMPORTED_IMPLIB for a shared
  5265. // library or an executable with exports.
  5266. bool allowImp = this->HasImportLibrary();
  5267. // If a mapping was found, check its configurations.
  5268. for(std::vector<std::string>::const_iterator mci = mappedConfigs.begin();
  5269. !*loc && !*imp && mci != mappedConfigs.end(); ++mci)
  5270. {
  5271. // Look for this configuration.
  5272. std::string mcUpper = cmSystemTools::UpperCase(mci->c_str());
  5273. std::string locProp = "IMPORTED_LOCATION_";
  5274. locProp += mcUpper;
  5275. *loc = this->GetProperty(locProp.c_str());
  5276. if(allowImp)
  5277. {
  5278. std::string impProp = "IMPORTED_IMPLIB_";
  5279. impProp += mcUpper;
  5280. *imp = this->GetProperty(impProp.c_str());
  5281. }
  5282. // If it was found, use it for all properties below.
  5283. if(*loc || *imp)
  5284. {
  5285. suffix = "_";
  5286. suffix += mcUpper;
  5287. }
  5288. }
  5289. // If we needed to find one of the mapped configurations but did not
  5290. // then the target is not found. The project does not want any
  5291. // other configuration.
  5292. if(!mappedConfigs.empty() && !*loc && !*imp)
  5293. {
  5294. return false;
  5295. }
  5296. // If we have not yet found it then there are no mapped
  5297. // configurations. Look for an exact-match.
  5298. if(!*loc && !*imp)
  5299. {
  5300. std::string locProp = "IMPORTED_LOCATION";
  5301. locProp += suffix;
  5302. *loc = this->GetProperty(locProp.c_str());
  5303. if(allowImp)
  5304. {
  5305. std::string impProp = "IMPORTED_IMPLIB";
  5306. impProp += suffix;
  5307. *imp = this->GetProperty(impProp.c_str());
  5308. }
  5309. }
  5310. // If we have not yet found it then there are no mapped
  5311. // configurations and no exact match.
  5312. if(!*loc && !*imp)
  5313. {
  5314. // The suffix computed above is not useful.
  5315. suffix = "";
  5316. // Look for a configuration-less location. This may be set by
  5317. // manually-written code.
  5318. *loc = this->GetProperty("IMPORTED_LOCATION");
  5319. if(allowImp)
  5320. {
  5321. *imp = this->GetProperty("IMPORTED_IMPLIB");
  5322. }
  5323. }
  5324. // If we have not yet found it then the project is willing to try
  5325. // any available configuration.
  5326. if(!*loc && !*imp)
  5327. {
  5328. std::vector<std::string> availableConfigs;
  5329. if(const char* iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS"))
  5330. {
  5331. cmSystemTools::ExpandListArgument(iconfigs, availableConfigs);
  5332. }
  5333. for(std::vector<std::string>::const_iterator
  5334. aci = availableConfigs.begin();
  5335. !*loc && !*imp && aci != availableConfigs.end(); ++aci)
  5336. {
  5337. suffix = "_";
  5338. suffix += cmSystemTools::UpperCase(*aci);
  5339. std::string locProp = "IMPORTED_LOCATION";
  5340. locProp += suffix;
  5341. *loc = this->GetProperty(locProp.c_str());
  5342. if(allowImp)
  5343. {
  5344. std::string impProp = "IMPORTED_IMPLIB";
  5345. impProp += suffix;
  5346. *imp = this->GetProperty(impProp.c_str());
  5347. }
  5348. }
  5349. }
  5350. // If we have not yet found it then the target is not available.
  5351. if(!*loc && !*imp)
  5352. {
  5353. return false;
  5354. }
  5355. return true;
  5356. }
  5357. //----------------------------------------------------------------------------
  5358. void cmTarget::ComputeImportInfo(std::string const& desired_config,
  5359. ImportInfo& info,
  5360. cmTarget *headTarget)
  5361. {
  5362. // This method finds information about an imported target from its
  5363. // properties. The "IMPORTED_" namespace is reserved for properties
  5364. // defined by the project exporting the target.
  5365. // Initialize members.
  5366. info.NoSOName = false;
  5367. const char* loc = 0;
  5368. const char* imp = 0;
  5369. std::string suffix;
  5370. if (!this->GetMappedConfig(desired_config, &loc, &imp, suffix))
  5371. {
  5372. return;
  5373. }
  5374. // A provided configuration has been chosen. Load the
  5375. // configuration's properties.
  5376. // Get the location.
  5377. if(loc)
  5378. {
  5379. info.Location = loc;
  5380. }
  5381. else
  5382. {
  5383. std::string impProp = "IMPORTED_LOCATION";
  5384. impProp += suffix;
  5385. if(const char* config_location = this->GetProperty(impProp.c_str()))
  5386. {
  5387. info.Location = config_location;
  5388. }
  5389. else if(const char* location = this->GetProperty("IMPORTED_LOCATION"))
  5390. {
  5391. info.Location = location;
  5392. }
  5393. }
  5394. // Get the soname.
  5395. if(this->GetType() == cmTarget::SHARED_LIBRARY)
  5396. {
  5397. std::string soProp = "IMPORTED_SONAME";
  5398. soProp += suffix;
  5399. if(const char* config_soname = this->GetProperty(soProp.c_str()))
  5400. {
  5401. info.SOName = config_soname;
  5402. }
  5403. else if(const char* soname = this->GetProperty("IMPORTED_SONAME"))
  5404. {
  5405. info.SOName = soname;
  5406. }
  5407. }
  5408. // Get the "no-soname" mark.
  5409. if(this->GetType() == cmTarget::SHARED_LIBRARY)
  5410. {
  5411. std::string soProp = "IMPORTED_NO_SONAME";
  5412. soProp += suffix;
  5413. if(const char* config_no_soname = this->GetProperty(soProp.c_str()))
  5414. {
  5415. info.NoSOName = cmSystemTools::IsOn(config_no_soname);
  5416. }
  5417. else if(const char* no_soname = this->GetProperty("IMPORTED_NO_SONAME"))
  5418. {
  5419. info.NoSOName = cmSystemTools::IsOn(no_soname);
  5420. }
  5421. }
  5422. // Get the import library.
  5423. if(imp)
  5424. {
  5425. info.ImportLibrary = imp;
  5426. }
  5427. else if(this->GetType() == cmTarget::SHARED_LIBRARY ||
  5428. this->IsExecutableWithExports())
  5429. {
  5430. std::string impProp = "IMPORTED_IMPLIB";
  5431. impProp += suffix;
  5432. if(const char* config_implib = this->GetProperty(impProp.c_str()))
  5433. {
  5434. info.ImportLibrary = config_implib;
  5435. }
  5436. else if(const char* implib = this->GetProperty("IMPORTED_IMPLIB"))
  5437. {
  5438. info.ImportLibrary = implib;
  5439. }
  5440. }
  5441. // Get the link interface.
  5442. {
  5443. std::string linkProp = "INTERFACE_LINK_LIBRARIES";
  5444. const char *propertyLibs = this->GetProperty(linkProp.c_str());
  5445. if (!propertyLibs)
  5446. {
  5447. linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
  5448. linkProp += suffix;
  5449. propertyLibs = this->GetProperty(linkProp.c_str());
  5450. }
  5451. if(!propertyLibs)
  5452. {
  5453. linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
  5454. propertyLibs = this->GetProperty(linkProp.c_str());
  5455. }
  5456. if(propertyLibs)
  5457. {
  5458. cmListFileBacktrace lfbt;
  5459. cmGeneratorExpression ge(lfbt);
  5460. cmGeneratorExpressionDAGChecker dagChecker(lfbt,
  5461. this->GetName(),
  5462. linkProp, 0, 0);
  5463. cmSystemTools::ExpandListArgument(ge.Parse(propertyLibs)
  5464. ->Evaluate(this->Makefile,
  5465. desired_config.c_str(),
  5466. false,
  5467. headTarget,
  5468. this,
  5469. &dagChecker),
  5470. info.LinkInterface.Libraries);
  5471. }
  5472. }
  5473. // Get the link dependencies.
  5474. {
  5475. std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES";
  5476. linkProp += suffix;
  5477. if(const char* config_libs = this->GetProperty(linkProp.c_str()))
  5478. {
  5479. cmSystemTools::ExpandListArgument(config_libs,
  5480. info.LinkInterface.SharedDeps);
  5481. }
  5482. else if(const char* libs =
  5483. this->GetProperty("IMPORTED_LINK_DEPENDENT_LIBRARIES"))
  5484. {
  5485. cmSystemTools::ExpandListArgument(libs, info.LinkInterface.SharedDeps);
  5486. }
  5487. }
  5488. // Get the link languages.
  5489. if(this->GetType() == cmTarget::STATIC_LIBRARY)
  5490. {
  5491. std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES";
  5492. linkProp += suffix;
  5493. if(const char* config_libs = this->GetProperty(linkProp.c_str()))
  5494. {
  5495. cmSystemTools::ExpandListArgument(config_libs,
  5496. info.LinkInterface.Languages);
  5497. }
  5498. else if(const char* libs =
  5499. this->GetProperty("IMPORTED_LINK_INTERFACE_LANGUAGES"))
  5500. {
  5501. cmSystemTools::ExpandListArgument(libs,
  5502. info.LinkInterface.Languages);
  5503. }
  5504. }
  5505. // Get the cyclic repetition count.
  5506. if(this->GetType() == cmTarget::STATIC_LIBRARY)
  5507. {
  5508. std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
  5509. linkProp += suffix;
  5510. if(const char* config_reps = this->GetProperty(linkProp.c_str()))
  5511. {
  5512. sscanf(config_reps, "%u", &info.LinkInterface.Multiplicity);
  5513. }
  5514. else if(const char* reps =
  5515. this->GetProperty("IMPORTED_LINK_INTERFACE_MULTIPLICITY"))
  5516. {
  5517. sscanf(reps, "%u", &info.LinkInterface.Multiplicity);
  5518. }
  5519. }
  5520. }
  5521. //----------------------------------------------------------------------------
  5522. cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config,
  5523. cmTarget *head)
  5524. {
  5525. // Imported targets have their own link interface.
  5526. if(this->IsImported())
  5527. {
  5528. if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, head))
  5529. {
  5530. return &info->LinkInterface;
  5531. }
  5532. return 0;
  5533. }
  5534. // Link interfaces are not supported for executables that do not
  5535. // export symbols.
  5536. if(this->GetType() == cmTarget::EXECUTABLE &&
  5537. !this->IsExecutableWithExports())
  5538. {
  5539. return 0;
  5540. }
  5541. // Lookup any existing link interface for this configuration.
  5542. TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : ""));
  5543. cmTargetInternals::LinkInterfaceMapType::iterator
  5544. i = this->Internal->LinkInterfaceMap.find(key);
  5545. if(i == this->Internal->LinkInterfaceMap.end())
  5546. {
  5547. // Compute the link interface for this configuration.
  5548. cmTargetInternals::OptionalLinkInterface iface;
  5549. iface.Exists = this->ComputeLinkInterface(config, iface, head);
  5550. // Store the information for this configuration.
  5551. cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface);
  5552. i = this->Internal->LinkInterfaceMap.insert(entry).first;
  5553. }
  5554. return i->second.Exists? &i->second : 0;
  5555. }
  5556. //----------------------------------------------------------------------------
  5557. void cmTarget::GetTransitivePropertyLinkLibraries(
  5558. const char* config,
  5559. cmTarget *headTarget,
  5560. std::vector<std::string> &libs)
  5561. {
  5562. cmTarget::LinkInterface const* iface = this->GetLinkInterface(config,
  5563. headTarget);
  5564. if (!iface)
  5565. {
  5566. return;
  5567. }
  5568. if(this->GetType() != STATIC_LIBRARY
  5569. || this->GetPolicyStatusCMP0022() == cmPolicies::WARN
  5570. || this->GetPolicyStatusCMP0022() == cmPolicies::OLD)
  5571. {
  5572. libs = iface->Libraries;
  5573. return;
  5574. }
  5575. const char* linkIfaceProp = "INTERFACE_LINK_LIBRARIES";
  5576. const char* interfaceLibs = this->GetProperty(linkIfaceProp);
  5577. if (!interfaceLibs)
  5578. {
  5579. return;
  5580. }
  5581. // The interface libraries have been explicitly set.
  5582. cmListFileBacktrace lfbt;
  5583. cmGeneratorExpression ge(lfbt);
  5584. cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(),
  5585. linkIfaceProp, 0, 0);
  5586. dagChecker.SetTransitivePropertiesOnly();
  5587. cmSystemTools::ExpandListArgument(ge.Parse(interfaceLibs)->Evaluate(
  5588. this->Makefile,
  5589. config,
  5590. false,
  5591. headTarget,
  5592. this, &dagChecker), libs);
  5593. }
  5594. //----------------------------------------------------------------------------
  5595. bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
  5596. cmTarget *headTarget)
  5597. {
  5598. // Construct the property name suffix for this configuration.
  5599. std::string suffix = "_";
  5600. if(config && *config)
  5601. {
  5602. suffix += cmSystemTools::UpperCase(config);
  5603. }
  5604. else
  5605. {
  5606. suffix += "NOCONFIG";
  5607. }
  5608. // An explicit list of interface libraries may be set for shared
  5609. // libraries and executables that export symbols.
  5610. const char* explicitLibraries = 0;
  5611. const char* newExplicitLibraries =
  5612. this->GetProperty("INTERFACE_LINK_LIBRARIES");
  5613. std::string linkIfaceProp;
  5614. if(this->GetType() == cmTarget::SHARED_LIBRARY ||
  5615. this->IsExecutableWithExports())
  5616. {
  5617. // Lookup the per-configuration property.
  5618. linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
  5619. linkIfaceProp += suffix;
  5620. explicitLibraries = this->GetProperty(linkIfaceProp.c_str());
  5621. // If not set, try the generic property.
  5622. if(!explicitLibraries)
  5623. {
  5624. linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
  5625. explicitLibraries = this->GetProperty(linkIfaceProp.c_str());
  5626. }
  5627. if (newExplicitLibraries
  5628. && (!explicitLibraries ||
  5629. (explicitLibraries
  5630. && strcmp(newExplicitLibraries, explicitLibraries) != 0)))
  5631. {
  5632. switch(this->GetPolicyStatusCMP0022())
  5633. {
  5634. case cmPolicies::WARN:
  5635. {
  5636. cmOStringStream w;
  5637. w << (this->Makefile->GetPolicies()
  5638. ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n"
  5639. << "Target \"" << this->GetName() << "\" has a "
  5640. "INTERFACE_LINK_LIBRARIES property which differs from its "
  5641. << linkIfaceProp << " properties.";
  5642. this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
  5643. }
  5644. // Fall through
  5645. case cmPolicies::OLD:
  5646. break;
  5647. case cmPolicies::REQUIRED_IF_USED:
  5648. case cmPolicies::REQUIRED_ALWAYS:
  5649. case cmPolicies::NEW:
  5650. explicitLibraries = newExplicitLibraries;
  5651. linkIfaceProp = "INTERFACE_LINK_LIBRARIES";
  5652. break;
  5653. }
  5654. }
  5655. }
  5656. else if(this->GetType() == cmTarget::STATIC_LIBRARY)
  5657. {
  5658. if (newExplicitLibraries)
  5659. {
  5660. cmListFileBacktrace lfbt;
  5661. cmGeneratorExpression ge(lfbt);
  5662. cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(),
  5663. "INTERFACE_LINK_LIBRARIES", 0, 0);
  5664. std::vector<std::string> ifaceLibs;
  5665. cmSystemTools::ExpandListArgument(
  5666. ge.Parse(newExplicitLibraries)->Evaluate(
  5667. this->Makefile,
  5668. config,
  5669. false,
  5670. headTarget,
  5671. this, &dagChecker), ifaceLibs);
  5672. LinkImplementation const* impl = this->GetLinkImplementation(config,
  5673. headTarget);
  5674. if (ifaceLibs != impl->Libraries)
  5675. {
  5676. switch(this->GetPolicyStatusCMP0022())
  5677. {
  5678. case cmPolicies::WARN:
  5679. {
  5680. cmOStringStream w;
  5681. w << (this->Makefile->GetPolicies()
  5682. ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n"
  5683. << "Static library target \"" << this->GetName() << "\" has a "
  5684. "INTERFACE_LINK_LIBRARIES property. This should be preferred "
  5685. "as the source of the link interface for this library. "
  5686. "Ignoring the property and using the link implementation "
  5687. "as the link interface instead.";
  5688. this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
  5689. }
  5690. // Fall through
  5691. case cmPolicies::OLD:
  5692. break;
  5693. case cmPolicies::REQUIRED_IF_USED:
  5694. case cmPolicies::REQUIRED_ALWAYS:
  5695. case cmPolicies::NEW:
  5696. explicitLibraries = newExplicitLibraries;
  5697. linkIfaceProp = "INTERFACE_LINK_LIBRARIES";
  5698. break;
  5699. }
  5700. }
  5701. }
  5702. }
  5703. // There is no implicit link interface for executables or modules
  5704. // so if none was explicitly set then there is no link interface.
  5705. // Note that CMake versions 2.2 and below allowed linking to modules.
  5706. bool canLinkModules = this->Makefile->NeedBackwardsCompatibility(2,2);
  5707. if(!explicitLibraries &&
  5708. (this->GetType() == cmTarget::EXECUTABLE ||
  5709. (this->GetType() == cmTarget::MODULE_LIBRARY && !canLinkModules)))
  5710. {
  5711. return false;
  5712. }
  5713. if(explicitLibraries)
  5714. {
  5715. // The interface libraries have been explicitly set.
  5716. cmListFileBacktrace lfbt;
  5717. cmGeneratorExpression ge(lfbt);
  5718. cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(),
  5719. linkIfaceProp, 0, 0);
  5720. cmSystemTools::ExpandListArgument(ge.Parse(explicitLibraries)->Evaluate(
  5721. this->Makefile,
  5722. config,
  5723. false,
  5724. headTarget,
  5725. this, &dagChecker), iface.Libraries);
  5726. if(this->GetType() == cmTarget::SHARED_LIBRARY)
  5727. {
  5728. // Shared libraries may have runtime implementation dependencies
  5729. // on other shared libraries that are not in the interface.
  5730. std::set<cmStdString> emitted;
  5731. for(std::vector<std::string>::const_iterator
  5732. li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li)
  5733. {
  5734. emitted.insert(*li);
  5735. }
  5736. LinkImplementation const* impl = this->GetLinkImplementation(config,
  5737. headTarget);
  5738. for(std::vector<std::string>::const_iterator
  5739. li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li)
  5740. {
  5741. if(emitted.insert(*li).second)
  5742. {
  5743. if(cmTarget* tgt = this->Makefile->FindTargetToUse(li->c_str()))
  5744. {
  5745. // This is a runtime dependency on another shared library.
  5746. if(tgt->GetType() == cmTarget::SHARED_LIBRARY)
  5747. {
  5748. iface.SharedDeps.push_back(*li);
  5749. }
  5750. }
  5751. else
  5752. {
  5753. // TODO: Recognize shared library file names. Perhaps this
  5754. // should be moved to cmComputeLinkInformation, but that creates
  5755. // a chicken-and-egg problem since this list is needed for its
  5756. // construction.
  5757. }
  5758. }
  5759. }
  5760. }
  5761. }
  5762. else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN
  5763. || this->GetPolicyStatusCMP0022() == cmPolicies::OLD)
  5764. // The implementation shouldn't be the interface if CMP0022 is NEW. That
  5765. // way, the LINK_LIBRARIES property can be set directly without having to
  5766. // empty the INTERFACE_LINK_LIBRARIES
  5767. {
  5768. // The link implementation is the default link interface.
  5769. LinkImplementation const* impl = this->GetLinkImplementation(config,
  5770. headTarget);
  5771. iface.ImplementationIsInterface = true;
  5772. iface.Libraries = impl->Libraries;
  5773. iface.WrongConfigLibraries = impl->WrongConfigLibraries;
  5774. if(this->GetType() == cmTarget::STATIC_LIBRARY)
  5775. {
  5776. // Targets using this archive need its language runtime libraries.
  5777. iface.Languages = impl->Languages;
  5778. }
  5779. }
  5780. if(this->GetType() == cmTarget::STATIC_LIBRARY)
  5781. {
  5782. // How many repetitions are needed if this library has cyclic
  5783. // dependencies?
  5784. std::string propName = "LINK_INTERFACE_MULTIPLICITY";
  5785. propName += suffix;
  5786. if(const char* config_reps = this->GetProperty(propName.c_str()))
  5787. {
  5788. sscanf(config_reps, "%u", &iface.Multiplicity);
  5789. }
  5790. else if(const char* reps =
  5791. this->GetProperty("LINK_INTERFACE_MULTIPLICITY"))
  5792. {
  5793. sscanf(reps, "%u", &iface.Multiplicity);
  5794. }
  5795. }
  5796. return true;
  5797. }
  5798. //----------------------------------------------------------------------------
  5799. cmTarget::LinkImplementation const*
  5800. cmTarget::GetLinkImplementation(const char* config, cmTarget *head)
  5801. {
  5802. // There is no link implementation for imported targets.
  5803. if(this->IsImported())
  5804. {
  5805. return 0;
  5806. }
  5807. // Lookup any existing link implementation for this configuration.
  5808. TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : ""));
  5809. cmTargetInternals::LinkImplMapType::iterator
  5810. i = this->Internal->LinkImplMap.find(key);
  5811. if(i == this->Internal->LinkImplMap.end())
  5812. {
  5813. // Compute the link implementation for this configuration.
  5814. LinkImplementation impl;
  5815. this->ComputeLinkImplementation(config, impl, head);
  5816. // Store the information for this configuration.
  5817. cmTargetInternals::LinkImplMapType::value_type entry(key, impl);
  5818. i = this->Internal->LinkImplMap.insert(entry).first;
  5819. }
  5820. return &i->second;
  5821. }
  5822. //----------------------------------------------------------------------------
  5823. void cmTarget::ComputeLinkImplementation(const char* config,
  5824. LinkImplementation& impl,
  5825. cmTarget *head)
  5826. {
  5827. // Compute which library configuration to link.
  5828. cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config);
  5829. // Collect libraries directly linked in this configuration.
  5830. std::vector<std::string> llibs;
  5831. this->GetDirectLinkLibraries(config, llibs, head);
  5832. for(std::vector<std::string>::const_iterator li = llibs.begin();
  5833. li != llibs.end(); ++li)
  5834. {
  5835. // Skip entries that resolve to the target itself or are empty.
  5836. std::string item = this->CheckCMP0004(*li);
  5837. if(item == this->GetName() || item.empty())
  5838. {
  5839. continue;
  5840. }
  5841. // The entry is meant for this configuration.
  5842. impl.Libraries.push_back(item);
  5843. }
  5844. LinkLibraryVectorType const& oldllibs = this->GetOriginalLinkLibraries();
  5845. for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin();
  5846. li != oldllibs.end(); ++li)
  5847. {
  5848. if(li->second != cmTarget::GENERAL && li->second != linkType)
  5849. {
  5850. std::string item = this->CheckCMP0004(li->first);
  5851. if(item == this->GetName() || item.empty())
  5852. {
  5853. continue;
  5854. }
  5855. // Support OLD behavior for CMP0003.
  5856. impl.WrongConfigLibraries.push_back(item);
  5857. }
  5858. }
  5859. // This target needs runtime libraries for its source languages.
  5860. std::set<cmStdString> languages;
  5861. // Get languages used in our source files.
  5862. this->GetLanguages(languages);
  5863. // Get languages used in object library sources.
  5864. for(std::vector<std::string>::iterator i = this->ObjectLibraries.begin();
  5865. i != this->ObjectLibraries.end(); ++i)
  5866. {
  5867. if(cmTarget* objLib = this->Makefile->FindTargetToUse(i->c_str()))
  5868. {
  5869. if(objLib->GetType() == cmTarget::OBJECT_LIBRARY)
  5870. {
  5871. objLib->GetLanguages(languages);
  5872. }
  5873. }
  5874. }
  5875. // Copy the set of langauges to the link implementation.
  5876. for(std::set<cmStdString>::iterator li = languages.begin();
  5877. li != languages.end(); ++li)
  5878. {
  5879. impl.Languages.push_back(*li);
  5880. }
  5881. }
  5882. //----------------------------------------------------------------------------
  5883. std::string cmTarget::CheckCMP0004(std::string const& item)
  5884. {
  5885. // Strip whitespace off the library names because we used to do this
  5886. // in case variables were expanded at generate time. We no longer
  5887. // do the expansion but users link to libraries like " ${VAR} ".
  5888. std::string lib = item;
  5889. std::string::size_type pos = lib.find_first_not_of(" \t\r\n");
  5890. if(pos != lib.npos)
  5891. {
  5892. lib = lib.substr(pos, lib.npos);
  5893. }
  5894. pos = lib.find_last_not_of(" \t\r\n");
  5895. if(pos != lib.npos)
  5896. {
  5897. lib = lib.substr(0, pos+1);
  5898. }
  5899. if(lib != item)
  5900. {
  5901. cmake* cm = this->Makefile->GetCMakeInstance();
  5902. switch(this->PolicyStatusCMP0004)
  5903. {
  5904. case cmPolicies::WARN:
  5905. {
  5906. cmOStringStream w;
  5907. w << (this->Makefile->GetPolicies()
  5908. ->GetPolicyWarning(cmPolicies::CMP0004)) << "\n"
  5909. << "Target \"" << this->GetName() << "\" links to item \""
  5910. << item << "\" which has leading or trailing whitespace.";
  5911. cm->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
  5912. this->GetBacktrace());
  5913. }
  5914. case cmPolicies::OLD:
  5915. break;
  5916. case cmPolicies::NEW:
  5917. {
  5918. cmOStringStream e;
  5919. e << "Target \"" << this->GetName() << "\" links to item \""
  5920. << item << "\" which has leading or trailing whitespace. "
  5921. << "This is now an error according to policy CMP0004.";
  5922. cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
  5923. }
  5924. break;
  5925. case cmPolicies::REQUIRED_IF_USED:
  5926. case cmPolicies::REQUIRED_ALWAYS:
  5927. {
  5928. cmOStringStream e;
  5929. e << (this->Makefile->GetPolicies()
  5930. ->GetRequiredPolicyError(cmPolicies::CMP0004)) << "\n"
  5931. << "Target \"" << this->GetName() << "\" links to item \""
  5932. << item << "\" which has leading or trailing whitespace.";
  5933. cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
  5934. }
  5935. break;
  5936. }
  5937. }
  5938. return lib;
  5939. }
  5940. template<typename PropertyType>
  5941. PropertyType getLinkInterfaceDependentProperty(cmTarget *tgt,
  5942. const std::string prop,
  5943. const char *config,
  5944. PropertyType *);
  5945. template<>
  5946. bool getLinkInterfaceDependentProperty(cmTarget *tgt,
  5947. const std::string prop,
  5948. const char *config, bool *)
  5949. {
  5950. return tgt->GetLinkInterfaceDependentBoolProperty(prop, config);
  5951. }
  5952. template<>
  5953. const char * getLinkInterfaceDependentProperty(cmTarget *tgt,
  5954. const std::string prop,
  5955. const char *config,
  5956. const char **)
  5957. {
  5958. return tgt->GetLinkInterfaceDependentStringProperty(prop, config);
  5959. }
  5960. //----------------------------------------------------------------------------
  5961. template<typename PropertyType>
  5962. void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee,
  5963. const char *propName,
  5964. std::set<cmStdString> &emitted,
  5965. const char *config,
  5966. PropertyType *)
  5967. {
  5968. const char *prop = dependee->GetProperty(propName);
  5969. if (!prop)
  5970. {
  5971. return;
  5972. }
  5973. std::vector<std::string> props;
  5974. cmSystemTools::ExpandListArgument(prop, props);
  5975. for(std::vector<std::string>::iterator pi = props.begin();
  5976. pi != props.end(); ++pi)
  5977. {
  5978. if (depender->GetMakefile()->GetCMakeInstance()
  5979. ->GetIsPropertyDefined(pi->c_str(),
  5980. cmProperty::TARGET))
  5981. {
  5982. cmOStringStream e;
  5983. e << "Target \"" << dependee->GetName() << "\" has property \""
  5984. << *pi << "\" listed in its " << propName << " property. "
  5985. "This is not allowed. Only user-defined properties may appear "
  5986. "listed in the " << propName << " property.";
  5987. depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str());
  5988. return;
  5989. }
  5990. if(emitted.insert(*pi).second)
  5991. {
  5992. getLinkInterfaceDependentProperty<PropertyType>(depender, *pi, config,
  5993. 0);
  5994. if (cmSystemTools::GetErrorOccuredFlag())
  5995. {
  5996. return;
  5997. }
  5998. }
  5999. }
  6000. }
  6001. //----------------------------------------------------------------------------
  6002. void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info,
  6003. const char* config)
  6004. {
  6005. const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
  6006. std::set<cmStdString> emittedBools;
  6007. std::set<cmStdString> emittedStrings;
  6008. for(cmComputeLinkInformation::ItemVector::const_iterator li =
  6009. deps.begin();
  6010. li != deps.end(); ++li)
  6011. {
  6012. if (!li->Target)
  6013. {
  6014. continue;
  6015. }
  6016. checkPropertyConsistency<bool>(this, li->Target,
  6017. "COMPATIBLE_INTERFACE_BOOL",
  6018. emittedBools, config, 0);
  6019. if (cmSystemTools::GetErrorOccuredFlag())
  6020. {
  6021. return;
  6022. }
  6023. checkPropertyConsistency<const char *>(this, li->Target,
  6024. "COMPATIBLE_INTERFACE_STRING",
  6025. emittedStrings, config, 0);
  6026. if (cmSystemTools::GetErrorOccuredFlag())
  6027. {
  6028. return;
  6029. }
  6030. }
  6031. for(std::set<cmStdString>::const_iterator li = emittedBools.begin();
  6032. li != emittedBools.end(); ++li)
  6033. {
  6034. const std::set<cmStdString>::const_iterator si = emittedStrings.find(*li);
  6035. if (si != emittedStrings.end())
  6036. {
  6037. cmOStringStream e;
  6038. e << "Property \"" << *li << "\" appears in both the "
  6039. "COMPATIBLE_INTERFACE_BOOL and the COMPATIBLE_INTERFACE_STRING "
  6040. "property in the dependencies of target \"" << this->GetName() <<
  6041. "\". This is not allowed. A property may only require compatibility "
  6042. "in a boolean interpretation or a string interpretation, but not both.";
  6043. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  6044. break;
  6045. }
  6046. }
  6047. }
  6048. //----------------------------------------------------------------------------
  6049. cmComputeLinkInformation*
  6050. cmTarget::GetLinkInformation(const char* config, cmTarget *head)
  6051. {
  6052. cmTarget *headTarget = head ? head : this;
  6053. // Lookup any existing information for this configuration.
  6054. TargetConfigPair key(headTarget,
  6055. cmSystemTools::UpperCase(config?config:""));
  6056. cmTargetLinkInformationMap::iterator
  6057. i = this->LinkInformation.find(key);
  6058. if(i == this->LinkInformation.end())
  6059. {
  6060. // Compute information for this configuration.
  6061. cmComputeLinkInformation* info =
  6062. new cmComputeLinkInformation(this, config, headTarget);
  6063. if(!info || !info->Compute())
  6064. {
  6065. delete info;
  6066. info = 0;
  6067. }
  6068. // Store the information for this configuration.
  6069. cmTargetLinkInformationMap::value_type entry(key, info);
  6070. i = this->LinkInformation.insert(entry).first;
  6071. if (info)
  6072. {
  6073. this->CheckPropertyCompatibility(info, config);
  6074. }
  6075. }
  6076. return i->second;
  6077. }
  6078. //----------------------------------------------------------------------------
  6079. std::string cmTarget::GetFrameworkDirectory(const char* config,
  6080. bool rootDir)
  6081. {
  6082. std::string fpath;
  6083. fpath += this->GetOutputName(config, false);
  6084. fpath += ".framework";
  6085. if(!rootDir)
  6086. {
  6087. fpath += "/Versions/";
  6088. fpath += this->GetFrameworkVersion();
  6089. }
  6090. return fpath;
  6091. }
  6092. //----------------------------------------------------------------------------
  6093. std::string cmTarget::GetCFBundleDirectory(const char* config,
  6094. bool contentOnly)
  6095. {
  6096. std::string fpath;
  6097. fpath += this->GetOutputName(config, false);
  6098. fpath += ".";
  6099. const char *ext = this->GetProperty("BUNDLE_EXTENSION");
  6100. if (!ext)
  6101. {
  6102. ext = "bundle";
  6103. }
  6104. fpath += ext;
  6105. fpath += "/Contents";
  6106. if(!contentOnly)
  6107. fpath += "/MacOS";
  6108. return fpath;
  6109. }
  6110. //----------------------------------------------------------------------------
  6111. std::string cmTarget::GetAppBundleDirectory(const char* config,
  6112. bool contentOnly)
  6113. {
  6114. std::string fpath = this->GetFullName(config, false);
  6115. fpath += ".app/Contents";
  6116. if(!contentOnly)
  6117. fpath += "/MacOS";
  6118. return fpath;
  6119. }
  6120. //----------------------------------------------------------------------------
  6121. std::string cmTarget::BuildMacContentDirectory(const std::string& base,
  6122. const char* config,
  6123. bool contentOnly)
  6124. {
  6125. std::string fpath = base;
  6126. if(this->IsAppBundleOnApple())
  6127. {
  6128. fpath += this->GetAppBundleDirectory(config, contentOnly);
  6129. }
  6130. if(this->IsFrameworkOnApple())
  6131. {
  6132. fpath += this->GetFrameworkDirectory(config, contentOnly);
  6133. }
  6134. if(this->IsCFBundleOnApple())
  6135. {
  6136. fpath += this->GetCFBundleDirectory(config, contentOnly);
  6137. }
  6138. return fpath;
  6139. }
  6140. //----------------------------------------------------------------------------
  6141. std::string cmTarget::GetMacContentDirectory(const char* config,
  6142. bool implib)
  6143. {
  6144. // Start with the output directory for the target.
  6145. std::string fpath = this->GetDirectory(config, implib);
  6146. fpath += "/";
  6147. bool contentOnly = true;
  6148. if(this->IsFrameworkOnApple())
  6149. {
  6150. // additional files with a framework go into the version specific
  6151. // directory
  6152. contentOnly = false;
  6153. }
  6154. fpath = this->BuildMacContentDirectory(fpath, config, contentOnly);
  6155. return fpath;
  6156. }
  6157. //----------------------------------------------------------------------------
  6158. cmTargetLinkInformationMap
  6159. ::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived()
  6160. {
  6161. // Ideally cmTarget instances should never be copied. However until
  6162. // we can make a sweep to remove that, this copy constructor avoids
  6163. // allowing the resources (LinkInformation) from getting copied. In
  6164. // the worst case this will lead to extra cmComputeLinkInformation
  6165. // instances. We also enforce in debug mode that the map be emptied
  6166. // when copied.
  6167. static_cast<void>(r);
  6168. assert(r.empty());
  6169. }
  6170. //----------------------------------------------------------------------------
  6171. cmTargetLinkInformationMap::~cmTargetLinkInformationMap()
  6172. {
  6173. for(derived::iterator i = this->begin(); i != this->end(); ++i)
  6174. {
  6175. delete i->second;
  6176. }
  6177. }
  6178. //----------------------------------------------------------------------------
  6179. cmTargetInternalPointer::cmTargetInternalPointer()
  6180. {
  6181. this->Pointer = new cmTargetInternals;
  6182. }
  6183. //----------------------------------------------------------------------------
  6184. cmTargetInternalPointer
  6185. ::cmTargetInternalPointer(cmTargetInternalPointer const& r)
  6186. {
  6187. // Ideally cmTarget instances should never be copied. However until
  6188. // we can make a sweep to remove that, this copy constructor avoids
  6189. // allowing the resources (Internals) to be copied.
  6190. this->Pointer = new cmTargetInternals(*r.Pointer);
  6191. }
  6192. //----------------------------------------------------------------------------
  6193. cmTargetInternalPointer::~cmTargetInternalPointer()
  6194. {
  6195. deleteAndClear(this->Pointer->IncludeDirectoriesEntries);
  6196. deleteAndClear(this->Pointer->CompileOptionsEntries);
  6197. delete this->Pointer;
  6198. }
  6199. //----------------------------------------------------------------------------
  6200. cmTargetInternalPointer&
  6201. cmTargetInternalPointer::operator=(cmTargetInternalPointer const& r)
  6202. {
  6203. if(this == &r) { return *this; } // avoid warning on HP about self check
  6204. // Ideally cmTarget instances should never be copied. However until
  6205. // we can make a sweep to remove that, this copy constructor avoids
  6206. // allowing the resources (Internals) to be copied.
  6207. cmTargetInternals* oldPointer = this->Pointer;
  6208. this->Pointer = new cmTargetInternals(*r.Pointer);
  6209. delete oldPointer;
  6210. return *this;
  6211. }